Пример #1
0
    def get_columns(self):
        header = HeaderFactory(self._form_model, self.language).create_header(
            self.submission_type)
        header_dict = header.get_header_field_dict()
        result = OrderedDict()
        for key in header_dict:
            if key != SubmissionIndexConstants.DATASENDER_ID_KEY:
                result.update({key: {"label": header_dict[key]}})
                if key == SubmissionIndexConstants.DATASENDER_NAME_KEY:  # add key column after name
                    self.add_datasender_id_column(header_dict, result)

        if self.submission_type == 'analysis':
            self._add_type_to_datasender_fields(result)
        self._update_with_field_meta(self._form_model.fields,
                                     result,
                                     header=header)
        unique_id_fields = [
            field for field in self._form_model.fields
            if isinstance(field, UniqueIdField)
        ]
        self._update_with_id_fields_meta(self._form_model.id,
                                         unique_id_fields,
                                         result,
                                         header=header)
        return result
Пример #2
0
 def get_column_title(self):
     header = HeaderFactory(self._form_model).create_header(
         self.submission_type)
     header_dict = header.get_header_field_dict()
     header_dict.pop('ds_id', None)
     header_dict.pop("entity_short_code", None)
     return header_dict.values()
Пример #3
0
 def test_should_return_header_instance_based_on_submission_type(self):
     form_model = Mock(spec=FormModel)
     form_model.fields = []
     self.assertIsInstance(HeaderFactory(form_model).create_header("all"), AllSubmissionHeader)
     self.assertIsInstance(HeaderFactory(form_model).create_header("success"), SuccessSubmissionHeader)
     self.assertIsInstance(HeaderFactory(form_model).create_header("error"), ErroredSubmissionHeader)
     self.assertIsInstance(HeaderFactory(form_model).create_header("analysis"), SubmissionAnalysisHeader)
Пример #4
0
 def get_column_title(self):
     header = HeaderFactory(self._form_model).create_header(self.submission_type)
     header_dict = header.get_header_field_dict()
     header_dict.pop('ds_id', None)
     unique_question_field_names = [es_unique_id_code_field_name(es_questionnaire_field_name(field.code, self._form_model.id, field.parent_field_code)) for
                                    field in
                                    self._form_model.entity_questions]
     for field_name in unique_question_field_names:
         header_dict.pop(field_name, None)
     return header_dict.values()
def _get_field_to_sort_on(post_dict, form_model, filter_type):
    order_by = int(post_dict.get('iSortCol_0')) - 1
    header = HeaderFactory(form_model).create_header(filter_type)
    headers = header.get_header_field_names()
    try:
        #Remove extra meta fields with which ordering in submission values
        #and submission headers will not match
        headers.remove('ds_id')
        headers.remove('entity_short_code')
    except ValueError:
        pass
    return headers[order_by]
Пример #6
0
    def get_columns(self):
        header = HeaderFactory(self._form_model, self.language).create_header(self.submission_type)
        header_dict = header.get_header_field_dict()
        result = OrderedDict()
        for key in header_dict:
            if key != SubmissionIndexConstants.DATASENDER_ID_KEY:
                result.update({key: {"label": header_dict[key]}})
                if key == SubmissionIndexConstants.DATASENDER_NAME_KEY: #add key column after name
                    self.add_datasender_id_column(header_dict, result)

        self._update_with_field_meta(self._form_model.fields, result, header=header)
        return result
Пример #7
0
    def query(self, database_name):
        query_all_results = self.query_builder.query_all(
            database_name, self.form_model.id)
        submission_type = self.query_params.get('filter')

        header = HeaderFactory(self.form_model).create_header(submission_type)
        submission_headers = header.get_header_field_names()
        query_by_submission_type = self.query_builder.filter_by_submission_type(
            query_all_results, self.query_params)
        filtered_query = self.query_builder.add_query_criteria(
            submission_headers,
            query_by_submission_type,
            self.query_params.get('search_filters').get('search_text'),
            query_params=self.query_params)
        submissions = self.response_creator.create_response(
            submission_headers, filtered_query)
        return submissions
Пример #8
0
    def get_columns(self):
        header = HeaderFactory(self._form_model).create_header(
            self.submission_type)
        header_dict = header.get_header_field_dict()
        # header_dict = OrderedDict({'name':"Name"}, {"p":"Place", "})
        if self._form_model.entity_type == ["reporter"]:
            header_dict.pop("entity_short_code", None)

        result = OrderedDict()
        for key in header_dict:
            if key != SubmissionIndexConstants.DATASENDER_ID_KEY:
                result.update({key: {"label": header_dict[key]}})
                if key == SubmissionIndexConstants.DATASENDER_NAME_KEY:  #add key column after name
                    self.add_datasender_id_column(header_dict, result)

        for field in self._form_model.fields:
            field_name = es_field_name(field.code.lower(), self._form_model.id)
            if result.has_key(field_name):
                result.get(field_name).update({"type": field.type})
                if field.type == "date":
                    result.get(field_name).update(
                        {"format": field.date_format})

        return result
Пример #9
0
 def get_headers(self, user=None, entity_type=None):
     submission_type = self.query_params.get('filter')
     header = HeaderFactory(self.form_model).create_header(submission_type)
     return header.get_header_field_names()
Пример #10
0
def _get_query_fields(form_model, submission_type):
    header = HeaderFactory(form_model).create_header(submission_type)
    return header.get_header_field_names()