Пример #1
0
 def apply_filter_idnums(self, form: cgi.FieldStorage) -> None:
     """Apply the ID number filter. Only one ID number filter at a time."""
     self.clear_filter_idnums()  # Only filter on one ID at a time.
     which_idnum = ws.get_cgi_parameter_int(form, PARAM.WHICH_IDNUM)
     idnum_value = ws.get_cgi_parameter_int(form, PARAM.IDNUM_VALUE)
     if 1 <= which_idnum <= NUMBER_OF_IDNUMS:
         setattr(self, "filter_idnum" + str(which_idnum), idnum_value)
         self.reset_pagination()
Пример #2
0
 def apply_filters(self, form: cgi.FieldStorage) -> None:
     """Apply filters from details in the CGI form."""
     filter_surname = ws.get_cgi_parameter_str_or_none(form, PARAM.SURNAME)
     if filter_surname:
         self.filter_surname = filter_surname.upper()
     filter_forename = ws.get_cgi_parameter_str_or_none(form,
                                                        PARAM.FORENAME)
     if filter_forename:
         self.filter_forename = filter_forename.upper()
     dt = ws.get_cgi_parameter_datetime(form, PARAM.DOB)
     if dt:
         self.filter_dob_iso8601 = cc_dt.format_datetime(
             dt, DATEFORMAT.ISO8601_DATE_ONLY)  # NB date only
     filter_sex = ws.get_cgi_parameter_str_or_none(form, PARAM.SEX)
     if filter_sex:
         self.filter_sex = filter_sex.upper()
     which_idnum = ws.get_cgi_parameter_int(form, PARAM.WHICH_IDNUM)
     idnum_value = ws.get_cgi_parameter_int(form, PARAM.IDNUM_VALUE)
     if (which_idnum and
             idnum_value is not None and
             1 <= which_idnum <= NUMBER_OF_IDNUMS):
         self.clear_filter_idnums()  # Only filter on one ID at a time.
         setattr(self, "filter_idnum" + str(which_idnum), idnum_value)
     filter_task = ws.get_cgi_parameter_str_or_none(form, PARAM.TASK)
     if filter_task:
         self.filter_task = filter_task
     filter_complete = ws.get_cgi_parameter_bool_or_none(form,
                                                         PARAM.COMPLETE)
     if filter_complete is not None:
         self.filter_complete = filter_complete
     filter_include_old_versions = ws.get_cgi_parameter_bool_or_none(
         form, PARAM.INCLUDE_OLD_VERSIONS)
     if filter_include_old_versions is not None:
         self.filter_include_old_versions = filter_include_old_versions
     filter_device_id = ws.get_cgi_parameter_int(form, PARAM.DEVICE)
     if filter_device_id is not None:
         self.filter_device_id = filter_device_id
     filter_user_id = ws.get_cgi_parameter_int(form, PARAM.USER)
     if filter_user_id:
         self.filter_user_id = filter_user_id
     dt = ws.get_cgi_parameter_datetime(form, PARAM.START_DATETIME)
     if dt:
         self.filter_start_datetime_iso8601 = cc_dt.format_datetime(
             dt, DATEFORMAT.ISO8601)
     dt = ws.get_cgi_parameter_datetime(form, PARAM.END_DATETIME)
     if dt:
         self.filter_end_datetime_iso8601 = cc_dt.format_datetime(
             dt, DATEFORMAT.ISO8601)
     filter_text = ws.get_cgi_parameter_str_or_none(form, PARAM.TEXT)
     if filter_text:
         self.filter_text = filter_text
     self.reset_pagination()
Пример #3
0
def get_params_from_form(paramspeclist: List[ReportParamSpec],
                         form: cgi.FieldStorage) -> Dict:
    """Returns key/value dictionary of applicable parameters from form."""
    kwargs = {}
    for paramspec in paramspeclist:
        if paramspec.type == PARAM.WHICH_IDNUM:
            idnum = ws.get_cgi_parameter_int(form, paramspec.name)
            if idnum is None or idnum < 1 or idnum > NUMBER_OF_IDNUMS:
                continue
            kwargs[paramspec.name] = idnum
        else:
            # Invalid paramtype
            continue
    return kwargs
Пример #4
0
 def change_number_to_view(self, form: cgi.FieldStorage) -> None:
     """Set how many tasks to view per page (from CGI form)."""
     self.number_to_view = ws.get_cgi_parameter_int(form,
                                                    PARAM.NUMBER_TO_VIEW)
     self.reset_pagination()
Пример #5
0
 def apply_filter_user(self, form: cgi.FieldStorage) -> None:
     """Apply the uploading user filter."""
     self.filter_user_id = ws.get_cgi_parameter_int(form, PARAM.USER)
     self.reset_pagination()
Пример #6
0
 def apply_filter_device(self, form: cgi.FieldStorage) -> None:
     """Apply the device filter."""
     self.filter_device_id = ws.get_cgi_parameter_int(form, PARAM.DEVICE)
     self.reset_pagination()