示例#1
0
 def run_cron_job(self, is_scheduled):
     # Ensure that the webapp is properly configured for this cron job.
     if not self.FROM_EMAIL:
         raise ImproperlyConfigured("DEFAULT_FROM_EMAIL not defined in settings.py")
     # If the job is scheduled, run only on the 1st day of month.
     if is_scheduled:
         today = datetime.date.today()
         if today.day != 1:
             message = "Nothing is done: %s is not the 1st day of month." % today.isoformat()
             return message
     # Send top posters to Google Groups.
     groups = [group for group in Group.find_all() if group.google_group]
     mail_sent = 0
     for group in groups:
         try:
             mail_sent += self._send_top_posters(group)
         except Exception, exc:
             logging.error("Failed to send top posters of group %s: %s" % (group.uid, exc))
             logging.exception(exc)
示例#2
0
 def get_page(self):
     data = self.update_data({"groups": Group.find_all()})
     return render_to_response(self.get_page_template(), data, RequestContext(self.request))