mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Remove obsolete management commands from various field additions.
(imported from commit b44a2b683768c790839e82e2e9c9a18827670113)
This commit is contained in:
		@@ -1,38 +0,0 @@
 | 
			
		||||
#!/usr/bin/python
 | 
			
		||||
 | 
			
		||||
from __future__ import absolute_import
 | 
			
		||||
 | 
			
		||||
from django.core.management.base import BaseCommand
 | 
			
		||||
 | 
			
		||||
from zerver.models import Realm
 | 
			
		||||
 | 
			
		||||
import datetime
 | 
			
		||||
 | 
			
		||||
# Pulled from event logs on staging.
 | 
			
		||||
 | 
			
		||||
times = """"""
 | 
			
		||||
 | 
			
		||||
# Pulled from event logs on prod.
 | 
			
		||||
 | 
			
		||||
times = times + """"""
 | 
			
		||||
 | 
			
		||||
times = times + """"""
 | 
			
		||||
 | 
			
		||||
times_dict = {}
 | 
			
		||||
for row in times.split("\n"):
 | 
			
		||||
    domain, timestr = row.split(" ")
 | 
			
		||||
    timestamp = datetime.datetime.fromtimestamp(int(timestr))
 | 
			
		||||
    times_dict[domain] = timestamp
 | 
			
		||||
 | 
			
		||||
class Command(BaseCommand):
 | 
			
		||||
    help = """Set the realm creation time for all existing realms."""
 | 
			
		||||
 | 
			
		||||
    def handle(self, **options):
 | 
			
		||||
        for realm in Realm.objects.all():
 | 
			
		||||
            timestamp = times_dict.get(realm.domain)
 | 
			
		||||
            if timestamp:
 | 
			
		||||
                print "Saving", realm.domain, timestamp
 | 
			
		||||
                realm.date_created = timestamp
 | 
			
		||||
                realm.save()
 | 
			
		||||
            else:
 | 
			
		||||
                print "Couldn't find data for", realm.domain
 | 
			
		||||
@@ -1,17 +0,0 @@
 | 
			
		||||
#!/usr/bin/python
 | 
			
		||||
 | 
			
		||||
from __future__ import absolute_import
 | 
			
		||||
 | 
			
		||||
from django.core.management.base import BaseCommand
 | 
			
		||||
 | 
			
		||||
from zerver.lib.utils import generate_random_token
 | 
			
		||||
from zerver.models import Stream
 | 
			
		||||
 | 
			
		||||
class Command(BaseCommand):
 | 
			
		||||
    help = """Set a token for all streams that don't have one."""
 | 
			
		||||
 | 
			
		||||
    def handle(self, **options):
 | 
			
		||||
        streams_needing_tokens = Stream.objects.filter(email_token=None)
 | 
			
		||||
        for stream in streams_needing_tokens:
 | 
			
		||||
            stream.email_token = generate_random_token(32)
 | 
			
		||||
            stream.save()
 | 
			
		||||
		Reference in New Issue
	
	Block a user