Author: brosner
Date: Fri Sep 12 23:27:00 2008
New Revision: 96
Modified:
trunk/notification/models.py
trunk/notification/views.py
Log:
Removed issue_notice flag and replaced with on_site flag. This is backward
incompatible in that SQL migration is needed and the keyword argument
changed.
Its default value is the same. Due to the backward incompatible change here,
the recipient argument name changed to users. That is backward incompatible
if
you relied on the old name.
Modified: trunk/notification/models.py
==============================================================================
--- trunk/notification/models.py (original)
+++ trunk/notification/models.py Fri Sep 12 23:27:00 2008
@@ -82,7 +82,7 @@
class NoticeManager(models.Manager):
- def notices_for(self, user, archived=False, unseen=None):
+ def notices_for(self, user, archived=False, unseen=None, on_site=None):
"""
returns Notice objects for the given user.
@@ -99,6 +99,8 @@
qs = self.filter(user=user, archived=archived)
if unseen is not None:
qs = qs.filter(unseen=unseen)
+ if on_site is not None:
+ qs = qs.filter(on_site=on_site)
return qs
def unseen_count_for(self, user):
@@ -116,6 +118,7 @@
added = models.DateTimeField(_('added'), default=datetime.datetime.now)
unseen = models.BooleanField(_('unseen'), default=True)
archived = models.BooleanField(_('archived'), default=False)
+ on_site = models.BooleanField(_('on site'))
objects = NoticeManager()
@@ -186,7 +189,7 @@
'notification/%s' % format), context)
return format_templates
-def send(recipient, label, extra_context={}, issue_notice=True):
+def send(users, label, extra_context={}, on_site=True):
"""
Creates a new notice.
@@ -196,6 +199,9 @@
'spam': 'eggs',
'foo': 'bar',
)
+
+ You can pass in on_site=False to prevent the notice emitted from being
+ displayed on the site.
"""
notice_type = NoticeType.objects.get(label=label)
@@ -214,7 +220,7 @@
'full.html',
) # TODO make formats configurable
- for user in recipient:
+ for user in users:
recipients = []
# get user profiles if available
try:
@@ -251,8 +257,8 @@
'message': messages['plain'],
}, context)
- if issue_notice:
- notice = Notice.objects.create(user=user,
message=messages['teaser'], notice_type=notice_type)
+ notice = Notice.objects.create(user=user,
message=messages['teaser'],
+ notice_type=notice_type, on_site=on_site)
if should_send(user, notice_type, "1") and user.email: # Email
recipients.append(user.email)
send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, recipients)
Modified: trunk/notification/views.py
==============================================================================
--- trunk/notification/views.py (original)
+++ trunk/notification/views.py Fri Sep 12 23:27:00 2008
@@ -19,7 +19,7 @@
@login_required
def notices(request):
notice_types = NoticeType.objects.all()
- notices = Notice.objects.notices_for(request.user)
+ notices = Notice.objects.notices_for(request.user, on_site=True)
settings_table = []
for notice_type in NoticeType.objects.all():
settings_row = []
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---