Exemplo n.º 1
0
 def test_form_submitted_by_none_filter(self):
     """
     Confirm that the FormSubmittedByFilter works when None is one of the
     arguments.
     """
     doc_generator = get_export_documents(
         FormExportInstance(domain=DOMAIN, app_id=DEFAULT_APP_ID, xmlns=DEFAULT_XMLNS),
         [FormSubmittedByFilter([uuid.uuid4().hex, None, uuid.uuid4().hex])]
     )
     self.assertEqual(1, len([x for x in doc_generator]))
Exemplo n.º 2
0
 def _get_user_type_filter(self, mobile_user_and_group_slugs):
     """
     :param mobile_user_and_group_slugs: ['t__0', 't__1']
     :return: FormSubmittedByFilter with user_ids for selected user types
     """
     user_types = self._get_selected_es_user_types(mobile_user_and_group_slugs)
     if user_types:
         form_filters = []
         if HQUserType.REGISTERED in user_types:
             form_filters.append(UserTypeFilter(self._USER_MOBILE))
         user_ids = self.get_user_ids_for_user_types(
             admin=HQUserType.ADMIN in user_types,
             unknown=HQUserType.UNKNOWN in user_types,
             demo=HQUserType.DEMO_USER in user_types,
             commtrack=False,
         )
         form_filters.append(FormSubmittedByFilter(user_ids))
         return form_filters
Exemplo n.º 3
0
 def _get_user_type_filters(self, user_types):
     """
     :return: FormSubmittedByFilter with user_ids for selected user types
     """
     if user_types:
         form_filters = []
         # Select all mobile workers if both active and deactivated users are selected
         if HQUserType.ACTIVE in user_types and HQUserType.DEACTIVATED in user_types:
             form_filters.append(UserTypeFilter(BaseFilterExportDownloadForm._USER_MOBILE))
         user_ids = self.get_user_ids_for_user_types(
             admin=HQUserType.ADMIN in user_types,
             unknown=HQUserType.UNKNOWN in user_types,
             web=HQUserType.WEB in user_types,
             demo=HQUserType.DEMO_USER in user_types,
             commtrack=False,
             active=HQUserType.ACTIVE in user_types,
             deactivated=HQUserType.DEACTIVATED in user_types,
         )
         form_filters.append(FormSubmittedByFilter(user_ids))
         return form_filters
Exemplo n.º 4
0
 def _scope_filter(self, accessible_location_ids):
     # Filter to be applied in AND with filters for export for restricted user
     # Restricts to forms submitted by users at accessible locations
     accessible_user_ids = user_ids_at_locations(
         list(accessible_location_ids))
     return FormSubmittedByFilter(accessible_user_ids)