From: Guillaume Pellerin Date: Sat, 13 Jul 2013 19:26:09 +0000 (+0200) Subject: add jqchat mess move script X-Git-Tag: 1.3-TC~37 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6513ea37bd7c4932bbd7c58dc6b5b45487e71521;p=teleforma.git add jqchat mess move script --- 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() +