]> git.openstreetmap.org Git - osqa.git/blob - forum/management/commands/subscribe_everyone.py
deleting the test file
[osqa.git] / forum / management / commands / subscribe_everyone.py
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
8 import datetime
9 from django.conf import settings
10
11 class Command(NoArgsCommand):
12     def handle_noargs(self,**options):
13         try:
14             try:
15                 self.subscribe_everyone()
16             except Exception, e:
17                 print e
18         finally:
19             connection.close()
20
21     def subscribe_everyone(self):
22
23         feed_type_info = EmailFeedSetting.FEED_TYPES
24         for user in User.objects.all():
25             for feed_type in feed_type_info:
26                 try:
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
32                 feed_setting.save()