Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 4
0
 def test_find_template_none_exists(self):
     self.assertEqual(None, utils.find_template(['baser.html', 'basest.html']))
Esempio n. 5
0
 def test_find_template_first_exists(self):
     self.assertEqual('base.html',
                      utils.find_template(['base.html', 'baser.html', 'basest.html']))
Esempio n. 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",
     ])
Esempio n. 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",
     ])
Esempio n. 8
0
 def test_find_template_none_exists(self):
     self.assertEqual(None, utils.find_template(['baser.html', 'basest.html']))
Esempio n. 9
0
 def test_find_template_first_exists(self):
     self.assertEqual('base.html',
                      utils.find_template(['base.html', 'baser.html', 'basest.html']))