diff options
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r-- | ishtar_common/forms.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 1497a97b9..e29e4ca0f 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -22,6 +22,7 @@ Forms definition """ from collections import OrderedDict import datetime +from markdown import markdown import re import types @@ -184,6 +185,7 @@ class CustomForm(BSForm): def __init__(self, *args, **kwargs): self.current_user = None + self.custom_header = "" if "user" in kwargs: try: self.current_user = kwargs.pop("user").ishtaruser @@ -194,7 +196,9 @@ class CustomForm(BSForm): self.custom_form_ordering() def custom_form_ordering(self): - available, excluded, json_fields = self.check_custom_form(self.current_user) + available, header, excluded, json_fields = self.check_custom_form( + self.current_user) + self.custom_header = header for exc in excluded: if hasattr(self, "fields"): self.remove_field(exc) @@ -329,10 +333,10 @@ class CustomForm(BSForm): """ Check form customization :param current_user: - :return: available, excluded_fields, json_fields + :return: available, custom header, excluded_fields, json_fields """ if not current_user: - return True, [], [] + return True, "", [], [] base_q = {"form": cls.form_slug, "available": True} # order is important : try for user, profile type, user type then all query_dicts = [] @@ -362,15 +366,18 @@ class CustomForm(BSForm): form = q.all()[0] break if not form: - return True, [], [] + return True, "", [], [] if not form.enabled: - return False, [], [] + return False, "", [], [] excluded_lst = [] for excluded in form.excluded_fields.all(): # could have be filtered previously excluded_lst.append(excluded.field) json_fields = cls._get_json_fields(form) - return True, excluded_lst, json_fields + header = form.header + if header: + header = markdown(header) + return True, header, excluded_lst, json_fields @classmethod def get_custom_fields(cls): |