Пример #1
0
def digest(request, team):
    start_of_report_day = _get_report_day()
    
    users = utils.get_users(team)
    absents = []
    reporters = []
    
    for user in users:
        reports = user.report_set.filter('added_date >', start_of_report_day).filter('team', team).fetch(models.ALL)
        if reports:
            report = reports[-1]
            user.message = report.body
            user.local_time = dating.getLocalTime(report.added_date)
            reporters.append(user)
        else:
            absents.append(user)
    
    data = {
                 'homepage':request.build_absolute_uri("/"),
                 'absents':absents,
                 'reporters':reporters,
                 }
    html = render_to_string(request, 'base_summary_mail.html', data=data)
    text = render_to_string(request, 'base_summary_mail.txt', data=data)
    send_team_common_mail('%s - daily digest (%s)' % (team.name, start_of_report_day.strftime("%A, %m/%d/%Y")), 
                          team, 
                          html, 
                          text,
                          reply_to=False
                          )
Пример #2
0
def _get_report_day():
    now = dating.getLocalTime()
    #logging.error("Now is %s", now.strftime("%A, %m/%d/%Y at %H:%M %Z"))
    # amendment for possible job start delay
    recently = now - FIVE_MINUTES
    start_of_report_day = recently.replace(hour=0, minute=0, second=0, microsecond=0)
    #logging.error("start_of_report_day is %s", start_of_report_day.strftime("%A, %m/%d/%Y at %H:%M %Z"))
    return start_of_report_day
Пример #3
0
def user_reports(user):
    recent_list = models.Report.all().filter('user', user).order('-added_date').fetch(20)
    for report in recent_list:
        report.local_time = dating.getLocalTime(report.added_date)
    return {'reports': recent_list,}