def assess_clinics(self): user = self.request.user clinics = [] if user.location: clinics = user.location.clinics period = get_period_from_request(self.request) sample_frames = {} client_tools = {} _dict = { '2017': (constants.RECOMMENDED_SAMPLE_FRAMES, constants.CLIENT_TOOLS) } sample_frames, client_tools_cont = _dict.get( period.form_xpath, (constants.RECOMMENDED_SAMPLE_FRAMES_V2, constants.CLIENT_TOOLS_V2)) client_tools = tuple_to_dict_list(("id", "name"), client_tools_cont) return { 'clinics': clinics, 'period': period, 'periods': ReportingPeriod.get_active_periods(), 'client_tools': client_tools, 'recommended_sample_frame': sample_frames, }
def show(self): period = self.request.context clinic = period.__parent__ # if clinic is not assigned, throw a bad request # if not clinic.is_assigned: # raise HTTPBadRequest("The clinic is not yet assigned") scores = clinic.get_scores(period.form_xpath) return { 'period': period, 'periods': ReportingPeriod.get_active_periods(), 'clinic': clinic, 'characteristics': tuple_to_dict_list(("id", "description", "number"), constants.CHARACTERISTICS), 'client_tools': tuple_to_dict_list(("id", "name"), constants.CLIENT_TOOLS), 'recommended_sample_frame': constants.RECOMMENDED_SAMPLE_FRAMES, 'key_indicators': constants.KEY_INDICATORS, 'scores': scores }
def push_report_periods(request): header = ['reporting_period'] rows = [] reporting_periods = ReportingPeriod.get_active_periods() [rows.append([period.form_xpath]) for period in reporting_periods] return {'header': header, 'rows': rows}
def test_get_active_period_when_month_is_jan(self): with patch('whoahqa.models.reporting_period.get_current_date') as mock: mock.return_value = datetime.date(2017, 7, 10) active_periods = ReportingPeriod.get_active_periods() self.assertEqual(len(active_periods), 4) self.assertIn(self.reporting_period_v3, active_periods)
def __init__(self, request): self.request = request self.period = get_period_from_request(request) self.periods = ReportingPeriod.get_active_periods() self.key_indicators_key_labels = constants.INDICATOR_LABELS