summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-03-16 11:41:22 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-03-16 14:42:16 +0100
commit63c96b0484661419c30a830e2d7ab52c209cf0f0 (patch)
tree9337e16f9d05b6231e153201d5e86e2334b5c307 /ishtar_common/forms.py
parentf5796cb2bf4e3bbe3a71b9cdf9320aea690ddfd9 (diff)
downloadIshtar-63c96b0484661419c30a830e2d7ab52c209cf0f0.tar.bz2
Ishtar-63c96b0484661419c30a830e2d7ab52c209cf0f0.zip
Custom form: can add header message - Profile: custom footer message
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py19
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):