]> git.parisson.com Git - teleforma.git/commitdiff
add room broadcast command
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 6 Dec 2013 20:37:44 +0000 (21:37 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 6 Dec 2013 20:37:44 +0000 (21:37 +0100)
teleforma/management/commands/teleforma-broadcast-message.py [new file with mode: 0644]

diff --git a/teleforma/management/commands/teleforma-broadcast-message.py b/teleforma/management/commands/teleforma-broadcast-message.py
new file mode 100644 (file)
index 0000000..77b691d
--- /dev/null
@@ -0,0 +1,19 @@
+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 *
+
+
+class Command(BaseCommand):
+    help = "Broadcast a jqchat message on the main site room by the admin"
+    args = "username text"
+
+    def handle(self, *args, **options):
+        text = args[1]
+        username = args[0]
+        user = User.objects.get(username=username)
+        rooms = Room.objects.filter(name__contains='site')
+        for room in rooms:
+            message = Message.objects.create_message(user, room, text)
+