1 from django.core.management.base import NoArgsCommand
2 from django.db import connection
3 from django.db.models import Q, F
4 from forum.models import *
5 from django.core.mail import EmailMessage
6 from django.utils.translation import ugettext as _
7 from django.utils.translation import ungettext
9 from django.conf import settings
11 class Command(NoArgsCommand):
12 def handle_noargs(self,**options):
15 self.subscribe_everyone()
21 def subscribe_everyone(self):
23 feed_type_info = EmailFeedSetting.FEED_TYPES
24 for user in User.objects.all():
25 for feed_type in feed_type_info:
27 feed_setting = EmailFeedSetting.objects.get(subscriber=user,feed_type = feed_type[0])
28 except EmailFeedSetting.DoesNotExist:
29 feed_setting = EmailFeedSetting(subscriber=user,feed_type=feed_type[0])
30 feed_setting.frequency = 'w'
31 feed_setting.reported_at = None