From 0ee28554fb18317b9da230a70e221ff88e25254b Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Wed, 14 Aug 2024 10:15:19 +0200 Subject: [PATCH] Allow displaying assigned_user field in Report Form via conf if needed (#4085) --- docs/changelog.rst | 1 + docs/install/advanced-configuration.rst | 3 +++ geotrek/feedback/forms.py | 1 - geotrek/feedback/tests/test_suricate_sync.py | 2 +- geotrek/settings/base.py | 5 ++++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e5ec377961..ed1bf1b17d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,7 @@ CHANGELOG **Improvements** - Allow use of Annotation Categories on annotations other than Points (#4032)" +- Allow using custom.py to make assigned_user field in Report Form available (#4085) 2.109.0 (2024-08-08) diff --git a/docs/install/advanced-configuration.rst b/docs/install/advanced-configuration.rst index 82d4878a74..f859f30317 100644 --- a/docs/install/advanced-configuration.rst +++ b/docs/install/advanced-configuration.rst @@ -2600,6 +2600,9 @@ An exhaustive list of form fields hideable in each module. HIDDEN_FORM_FIELDS["circulationedge"] = [ ] +.. note:: + ``assigned_user`` is hidden by default in ``HIDDEN_FORM_FIELDS["report"]``, it is possible to force it to appear using ``HIDDEN_FORM_FIELDS["report"] = []``. + Configure form fields required or needed for review or publication ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/geotrek/feedback/forms.py b/geotrek/feedback/forms.py index beb5f57353..298df6273f 100644 --- a/geotrek/feedback/forms.py +++ b/geotrek/feedback/forms.py @@ -121,7 +121,6 @@ def __init__(self, *args, **kwargs): self.fields["assigned_user"].widget = HiddenInput() self.fields["uses_timers"].widget = HiddenInput() else: # Do not use these fields outside of worflow - self.fields["assigned_user"].widget = HiddenInput() self.fields["uses_timers"].widget = HiddenInput() def save(self, *args, **kwargs): diff --git a/geotrek/feedback/tests/test_suricate_sync.py b/geotrek/feedback/tests/test_suricate_sync.py index 4818402ddc..c13c1c93a2 100644 --- a/geotrek/feedback/tests/test_suricate_sync.py +++ b/geotrek/feedback/tests/test_suricate_sync.py @@ -580,7 +580,7 @@ def inner(self, *args, **kwargs): def test_for_workflow_mode(test_func): def inner(self, *args, **kwargs): try: - with override_settings(SURICATE_REPORT_ENABLED=True, SURICATE_WORKFLOW_ENABLED=True): + with override_settings(SURICATE_REPORT_ENABLED=True, SURICATE_WORKFLOW_ENABLED=True, HIDDEN_FORM_FIELDS={}): test_func(self, *args, **kwargs) except AssertionError as e: e.args += ("Failed for 'Suricate Workflow' mode",) diff --git a/geotrek/settings/base.py b/geotrek/settings/base.py index 3b6557e3e4..a40188181f 100644 --- a/geotrek/settings/base.py +++ b/geotrek/settings/base.py @@ -842,7 +842,7 @@ def api_bbox(bbox, buffer): PARSER_RETRY_HTTP_STATUS = [503] USE_BOOKLET_PDF = False -HIDDEN_FORM_FIELDS = {} +HIDDEN_FORM_FIELDS = {'report': ['assigned_user']} COLUMNS_LISTS = {} ENABLE_JOBS_COSTS_DETAILED_EXPORT = False @@ -925,3 +925,6 @@ def api_bbox(bbox, buffer): ] LEAFLET_CONFIG['TILES_EXTENT'] = SPATIAL_EXTENT LEAFLET_CONFIG['SPATIAL_EXTENT'] = api_bbox(SPATIAL_EXTENT, VIEWPORT_MARGIN) + +if SURICATE_WORKFLOW_ENABLED and 'report' in HIDDEN_FORM_FIELDS.keys() and "assigned_user" in HIDDEN_FORM_FIELDS['report']: + HIDDEN_FORM_FIELDS['report'].remove("assigned_user")