Exemple #1
0
    def get_detail_template(cls, prefixes=None):
        """
        Return the active detail template for our record
        """
        file_locations = [
            os.path.join('records', '{0}_detail.html'),
            os.path.join('records', '{0}.html'),
        ]

        if prefixes is None:
            prefixes = []

        templates = []

        for prefix in prefixes:
            for file_location in file_locations:
                templates.append(file_location.format(
                    os.path.join(prefix, cls.get_api_name())
                ))

        for file_location in file_locations:
            templates.append(
                file_location.format(cls.get_api_name())
            )
        return find_template(templates)
Exemple #2
0
    def _get_template(cls, template, prefixes=None):
        template_locations = []

        if prefixes is None:
            prefixes = []

        for prefix in prefixes:
            template_locations.append(
                template.format(os.path.join(prefix, cls.get_api_name()))
            )

        template_locations.append(template.format(cls.get_api_name()))
        return find_template(template_locations)
Exemple #3
0
    def get_modal_template(cls, prefixes=None):
        """
        Return the active form template for our record
        """
        if prefixes is None:
            prefixes = []

        result = cls._get_template(
            template=os.path.join("modals", "{}_modal.html"),
            prefixes=prefixes
        )

        if not result and cls.get_form_template():
            result = find_template(["base_templates/form_modal_base.html"])

        return result
Exemple #4
0
 def test_find_template_none_exists(self):
     self.assertEqual(None, utils.find_template(['baser.html', 'basest.html']))
Exemple #5
0
 def test_find_template_first_exists(self):
     self.assertEqual('base.html',
                      utils.find_template(['base.html', 'baser.html', 'basest.html']))
Exemple #6
0
 def get_form_template(cls):
     return find_template([
         "lab_tests/forms/{}_form.html".format(cls.get_api_name()),
         "lab_tests/forms/generic_lab_test.html",
     ])
Exemple #7
0
 def get_form_template(cls):
     return find_template([
         "lab_tests/forms/{}_form.html".format(cls.get_api_name()),
         "lab_tests/forms/generic_lab_test.html",
     ])
Exemple #8
0
 def test_find_template_none_exists(self):
     self.assertEqual(None, utils.find_template(['baser.html', 'basest.html']))
Exemple #9
0
 def test_find_template_first_exists(self):
     self.assertEqual('base.html',
                      utils.find_template(['base.html', 'baser.html', 'basest.html']))