示例#1
0
def pf_swahili_sms(report_schedule, run_frequency):
    """ 
    Generates an sms report of the form:
    'Number of visits this week: DeRenzi(5), Jackson(3), Lesh(1)'
    """
    usr = report_schedule.recipient_user
    organization = report_schedule.organization
    org_domain = organization.domain
    transport = report_schedule.report_delivery
    if organization != None:
        from hq import reporter
        (startdate, enddate) = reporter.get_daterange(run_frequency)
        
        root_orgs = Organization.objects.filter(parent=None, domain=org_domain)
        # note: this pretty sneakily decides for you that you only care
        # about one root organization per domain.  should we lift this 
        # restriction?  otherwise this may hide data from you 
        root_org = root_orgs[0]
        # this call makes the meat of the report.
        report_payload = repinspector.get_data_below(root_org, startdate, enddate, 0)
        
        if transport == 'email':
            do_separate = True
        else:
            do_separate=False
            
        rendered_text = reporter.render_reportstring(org_domain, 
                   report_payload, 
                   run_frequency,
                   template_name="hq/reports/hack_sms_swahili.txt",                                       
                   transport=transport)
        reporter.deliver_report(usr, rendered_text, report_schedule.report_delivery,params={'startdate': startdate, 'enddate': enddate, 'frequency': run_frequency})                
示例#2
0
def get_data_for_organization(run_frequency, transport, org_domain):
    (startdate, enddate) = get_daterange(run_frequency)
    return repinspector.get_data_below(org_domain, startdate, enddate, 0)