blob: 3f8da9ecdfecb5636fb47b7139bb9c6ea4182e22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
from django.core.management.base import NoArgsCommand
from django.db import connection
from django.db.models import Q, F
from forum.models import *
from django.core.mail import EmailMessage
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
import datetime
import settings
class Command(NoArgsCommand):
def handle_noargs(self,**options):
try:
self.subscribe_everyone()
except Exception, e:
print e
finally:
connection.close()
def subscribe_everyone(self):
feed_type_info = EmailFeedSetting.FEED_TYPES
for user in User.objects.all():
for feed_type in feed_type_info:
try:
feed_setting = EmailFeedSetting.objects.get(subscriber=user,feed_type = feed_type[0])
except EmailFeedSetting.DoesNotExist:
feed_setting = EmailFeedSetting(subscriber=user,feed_type=feed_type[0])
feed_setting.frequency = 'w'
feed_setting.reported_at = None
feed_setting.save()
|