def activity_report(router, domain, send_chv_report=True, send_super_report=True, send_summary_chv_report=True): """ Sends weekly activity reports to CHV's and CHW's Later: we can always break this out into its own schedule at a later date """ logging.info("Running brac sms activity report") orgs = Organization.objects.filter(domain=domain) for org in orgs: members = org.get_members().filter(active=True) for member in members: form_count = forms_submitted(member.chw_username, weeks=1) if send_chv_report: # tell individual chv's of their usage this past week send_activity_to_reporter(router, member, member.chw_username, form_count) if send_super_report: supervisors = org.get_supervisors().filter(active=True) for supe in supervisors: # each supervisor gets one activity report for each chv supervised send_activity_to_super(router, supe, {'chv':member, 'count': form_count} ) member.forms_this_week = form_count if send_summary_chv_report: for member in members: # each chv receives a summary of activity within their branch send_summary_activity_to_reporter(router, member, {'group_members':members} )
def brac_sms_report(router, reporter_map = {}): """Send to manually-coded numbers, set via the args in the scheduler app. If nothing is set, nothign will be sent. """ for chw_name, reporter_name in reporter_map.items(): count = forms_submitted(chw_name, weeks=1) rep = Reporter.objects.get(alias__iexact=reporter_name) send_activity_to_reporter(router, rep, chw_name, count)