From c1ef5d12f93813e2ca50207b8081566ca24353dc Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sat, 13 Jul 2013 21:26:09 +0200 Subject: [PATCH] add jqchat mess move script --- .../teleforma-move-jqchat-messages.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 teleforma/management/commands/teleforma-move-jqchat-messages.py diff --git a/teleforma/management/commands/teleforma-move-jqchat-messages.py b/teleforma/management/commands/teleforma-move-jqchat-messages.py new file mode 100644 index 00000000..48215393 --- /dev/null +++ b/teleforma/management/commands/teleforma-move-jqchat-messages.py @@ -0,0 +1,28 @@ +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from jqchat.models import * +import datetime + + +class Command(BaseCommand): + help = "Move some jqchat messages from one room to another past to a given date" + args = "from_room to_room year month day" + + def handle(self, *args, **options): + day = args[-1] + month = args[-2] + year = args[-3] + to_room_name = args[-4] + from_room_name = args[-5] + + date = datetime.datetime(int(year), int(month), int(day)) + to_room = Room.objects.get(name=to_room_name) + from_room = Room.objects.get(name=from_room_name) + + messages = Message.objects.filter(room=from_room, created__gte=date) + for message in messages: + message.room = to_room + message.save() + -- 2.39.5