Пример #1
0
    def process_children(self, request, parameters, arguments, include=None):
        """
            Allows to process the children questions for the current question
        """
        if include is None:
            include = []
        children = {}
        report = arguments['report']
        children_parameters = {}

        if 'children' in parameters and parameters['children'] is not None:
            children_parameters = OrderedDict(parameters['children'])
            for child, value in children_parameters.items():
                if not include or child in include:
                    children[child] = {
                        'state':
                        'ok',
                        'text':
                        question_loader.process_questions(
                            request,
                            report.report.pk,
                            value,
                            view_type=self.view_type,
                            reportbyproj=report)
                    }
Пример #2
0
    def process_children(self, request, parameters, arguments, include=None):
        '''
            Gets the rendered template (HTML code) for every child question of the current question

            :param request:
            :param dict parameters: context parameters passed to the template, generally self.question.answer_options
            :param dict arguments: parameters passed to the function additional_template_parameters
            :return: list of string with the rendered templates for the child questions
        '''

        if include is None:
            include = []
        return_value = {}
        report = arguments['report']
        form = arguments['form']
        children = get_children(form)
        if children is None and parameters and 'children' in parameters and parameters[
                'children']:
            children = parameters['children']
        if children:
            for child in children:
                return_value[child] = process_questions(
                    request,
                    report.pk,
                    children[child],
                    view_type=self.view_type)
        return return_value
Пример #3
0
 def process_children(self, request, parameters, arguments, include=[]):
     """
         TODO: docstring
     """
     return_value = {}
     report = arguments['report']
     form = arguments['form']
     children = get_children(form)
     if children is None and parameters and 'children' in parameters and parameters[
             'children']:
         children = parameters['children']
     if children:
         for child in children:
             return_value[child] = process_questions(
                 request,
                 report.pk,
                 children[child],
                 view_type=self.view_type)
     return return_value
Пример #4
0
def process_template(request, report, view_type, reportbyproj=None):
    '''
        Loads the questions of the given report, works both for the admin and responsable views

        If ``reportbyproj`` is provided, it also loads the answers of the questions in this report
    '''
    categories = report.template
    i = 0
    for category in categories:
        ii = 0
        for subcategory in category['subcategories']:
            if subcategory['questions']:
                questions = process_questions(request,
                                              report.pk,
                                              subcategory['questions'],
                                              view_type=view_type,
                                              reportbyproj=reportbyproj)
                categories[i]['subcategories'][ii]['questions'] = questions
            ii += 1
        i += 1
    return categories