def FillTeacherDictForMonth(ht_or_vt, offset, index, teachers): HtmlReuse.CalcDateOffset(offset) year = HtmlReuse.year month = HtmlReuse.month reports = DataModule.GetReports(ht_or_vt, year, month) assignments = DataModule.GetAssignments(ht_or_vt, year, month) for d in assignments: district = assignments[d] for c in district.companionships: comp = district.companionships[c] s = comp.senior_comp.first_name + " " + comp.senior_comp.last_name j = comp.junior_comp.first_name + " " + comp.junior_comp.last_name if not teachers.has_key(s): teachers[s] = {} if not teachers.has_key(j): teachers[j] = {} for teachee in comp.assignments: if reports[teachee.first_name + " " + teachee.last_name].visited: teachers[s][index] = "visited" teachers[j][index] = "visited" break elif reports[teachee.first_name + " " + teachee.last_name].reported: teachers[s][index] = "not_visited" teachers[j][index] = "not_visited" if not teachers[s].has_key(index): teachers[s][index] = "not_reported" teachers[j][index] = "not_reported"
def StubReportInfo(ht_or_vt, districts): reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) for d in districts: comps = districts[d].companionships for c in comps: as = comps[c].assignments for a in as: name = a.first_name + " " + a.last_name if not reports.has_key(name): reports[name] = Sm3Ht.ReportInfo()
def UpdateReportInfo(ht_or_vt, teachee, reporter, visited, comment, contact_type): reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) r = reports[teachee] r.visited = visited r.reported = True r.report_notes = comment r.reported_by = reporter r.contact_type = contact_type DataModule.PutReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month, reports)
def GetDictByAssignment(ht_or_vt, month_diff): assignment_reports = {} offset = month_diff reports = {} while offset > month_diff - 12: HtmlReuse.CalcDateOffset(offset) reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) for key in reports: if not assignment_reports.has_key(key): assignment_reports[key] = {} assignment_reports[key][11 - (month_diff - offset)] = reports[key] offset -= 1 FillEmptyMonths(ht_or_vt, assignment_reports) return assignment_reports
def PrintTotalVisits(ht_or_vt, month_diff): HtmlReuse.CalcDateOffset(month_diff) reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) total_visits = 0 total_houses = 0 for key in reports: total_houses += 1 if reports[key].visited: total_visits += 1 if total_visits == 0: print "No visits recorded yet" elif total_houses == 0: print "No Report Yet" else: perc = 100 * total_visits / total_houses print "Total visits for this month: %d" % total_visits, "out of %d" % total_houses, ": %.1f" % perc, "%"
def PrintTotalReported(ht_or_vt, month_diff): HtmlReuse.CalcDateOffset(month_diff) reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) total_reported = 0 total_houses = 0 for key in reports: total_houses += 1 if reports[key].reported: total_reported += 1 if total_reported == 0: print "No visits recorded yet" elif total_houses == 0: print "" else: perc2 = 100 * total_reported / total_houses print "Total reported: %d" % total_reported, "out of %d" % total_houses, ": %.1f" % perc2, "%"
def PrintCsvReports(ht_or_vt): import csv districts = DataModule.GetAssignments(ht_or_vt, HtmlReuse.year, HtmlReuse.month) reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) writer = csv.writer(sys.stdout) writer.writerow(["Name", "Visited", "Reported", "Reported By", "Report Notes", "Contact Type", "Senior Companion", "Junior Companion"]) for d in districts: comps = districts[d].companionships for c in comps: as = comps[c].assignments for a in as: name = a.first_name + " " + a.last_name if reports.has_key(name): report = reports[name] else: report = Sm3Ht.ReportInfo() writer.writerow([name, report.visited, report.reported, report.reported_by, report.report_notes, report.contact_types, comps[c].senior_comp.first_name + " " + comps[c].senior_comp.last_name, comps[c].junior_comp.first_name + " " + comps[c].junior_comp.last_name])
if ht_or_vt == None: print "Don't know what type of page this is!" sys.exit(0) month_diff = 0 if form.has_key("chm"): month_diff = int(form["chm"].value) HtmlReuse.CalcDateOffset(month_diff) d = -1 c = -1 if form.has_key("d"): d = int(form["d"].value) if form.has_key("c"): c = int(form["c"].value) assignments = DataModule.GetAssignments(ht_or_vt, HtmlReuse.year, HtmlReuse.month) reports = DataModule.GetReports(ht_or_vt, HtmlReuse.year, HtmlReuse.month) # # # HtmlReuse.PrintCal("contact?group=%s&d=%d&c=%d" % (ht_or_vt, d, c), month_diff) print "<br><br>" if len(assignments) > 0 and d != -1 and c != -1: DisplayContactDynamic.PrintHtml(d, c, ht_or_vt, assignments, reports, month_diff) else: print "<h2>Assignments for this month have not been uploaded yet.</h2>"