コード例 #1
0
ファイル: notifiers.py プロジェクト: BGCX262/zzheng-hg-to-git
def activity_created(activity):
    # Do nothing if this group is not associated with a Google Group.
    google_group = activity.group.google_group or None
    if not google_group:
        logging.info("Group is not associated with a Google Group.")
        return
    # Otherwise, send a mail to the associated Google Group.
    _TEMPLATE_NAME = "activity_created"
    try:
        author = activity.submitter
        recipient = "*****@*****.**" % google_group
        data = {
            "activity": activity,
            "http_host": getattr(settings, "MY_HTTP_HOST", None),
        }
        message = _render_message(_TEMPLATE_NAME, data)
        something_happened.send(
            sender=Activity.__name__,
            subject=None,
            message=message,
            author=author,
            recipients=[recipient]
        )
    except Exception, exc:
        logging.error("Failed to send notification for activity_created: %s" % exc)
        logging.exception(exc)
コード例 #2
0
ファイル: views.py プロジェクト: BGCX262/zzheng-hg-to-git
 def _send_top_posters(self, group):
     group_stat = GroupStat.get_unique(group=group, date=datetime.date.today(), month_delta=-1)
     if not group_stat:
         return 0
     top_posters = PosterStat.find_by_group_stat(group_stat=group_stat, limit=3)
     if not top_posters:
         return 0
     data = {
         "group_stat": group_stat,
         "top_posters": top_posters,
         "http_host": getattr(settings, "MY_HTTP_HOST", None),
     }
     message = render_to_string("cronjobs/mails/top_posters.txt", data)
     author = users.get_user(self.FROM_EMAIL)
     recipient = "*****@*****.**" % group.google_group
     something_happened.send(
         sender=Group.__name__,
         subject=None,
         message=message,
         author=author,
         recipients=[recipient]
     )
     return 1