mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
Cut out duplicated code between clear_database and populate_db.
(imported from commit 4bb44c20d2f0477d8a3db72788f82b0cf8572b2d)
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
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, Client
|
||||
from django.contrib.sessions.models import Session
|
||||
from zephyr.models import clear_database
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
help = "Clear only tables we change: messages, accounts + sessions"
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
for model in [Message, Stream, UserProfile, User, Recipient,
|
||||
Realm, Subscription, Huddle, UserMessage, Client]:
|
||||
model.objects.all().delete()
|
||||
Session.objects.all().delete()
|
||||
|
||||
clear_database()
|
||||
self.stdout.write("Successfully cleared the database.\n")
|
||||
|
||||
Reference in New Issue
Block a user