コード例 #1
0
ファイル: views.py プロジェクト: BGCX262/zzheng-hg-to-git
 def get_page(self):
     if self.category:
         kwargs = {"category": self.category}
     else:
         kwargs = {}
     notifications = Notification.find(**kwargs)
     data = {"category": self.category, "notifications": notifications}
     return render_to_response(self.get_page_template(), data, RequestContext(self.request))
コード例 #2
0
ファイル: forms.py プロジェクト: BGCX262/zzheng-hg-to-git
 def send(self, author):
     if not self.is_valid():
         raise InvalidFormError(self.errors)
     notification = Notification.send(
         category="TODO",
         subject=self.cleaned_data["subject"],
         message=self.cleaned_data["message"],
         author=author,
         recipients=self.cleaned_data["recipients"]
     )
     return notification
コード例 #3
0
ファイル: views.py プロジェクト: BGCX262/zzheng-hg-to-git
 def post_page(self):
     notification_id_list = self.request.POST.getlist("notification_id")
     deleted, failed = 0, 0
     for notification_id in notification_id_list:
         try:
             notification = Notification.get_unique(id=int(notification_id))
             if not notification:
                 message = "searched by notification ID %s." % notification_id
                 raise EntityNotFoundError(Notification, message)
             notification.delete()
             deleted += 1
         except Exception, exc:
             message = "Failed to delete notification %s: %s" % (notification_id, exc)
             logging.error(message)
             logging.exception(exc)
             failed += 1
コード例 #4
0
ファイル: views.py プロジェクト: BGCX262/zzheng-hg-to-git
 def get_notification(self):
     notification = Notification.get_unique(id=self.notification_id)
     if not notification:
         message = "searched by notification ID %s." % self.notification_id
         raise EntityNotFoundError(Notification, message)
     return notification