Files
zulip/zephyr/management/commands/clear_db.py
Tim Abbott 8daff2e05e Rename ZephyrClass to Stream.
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00

18 lines
689 B
Python

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User
from zephyr.models import Message, UserProfile, Stream, Recipient, \
Subscription, Huddle, Realm, UserMessage
from django.contrib.sessions.models import Session
class Command(NoArgsCommand):
help = "Clear only tables we change: messages, accounts + sessions"
def handle_noargs(self, **options):
for klass in [Message, Stream, UserProfile, User, Recipient,
Realm, Subscription, Huddle, UserMessage]:
klass.objects.all().delete()
Session.objects.all().delete()
self.stdout.write("Successfully cleared the database.\n")