From 58c1ced16a85fb21d30fc2eab8abfa76c6ef1e13 Mon Sep 17 00:00:00 2001 From: Segilola Mustapha <54508387+SegiNyn@users.noreply.github.com> Date: Tue, 8 Nov 2022 14:04:37 +0100 Subject: [PATCH] Add method to get form --- .../events/sessions/controllers/management/sessions.py | 5 ++++- indico/modules/events/timetable/controllers/legacy.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/indico/modules/events/sessions/controllers/management/sessions.py b/indico/modules/events/sessions/controllers/management/sessions.py index f6247ad1bb3..e2716bf5f8c 100644 --- a/indico/modules/events/sessions/controllers/management/sessions.py +++ b/indico/modules/events/sessions/controllers/management/sessions.py @@ -91,13 +91,16 @@ def _process(self): class RHModifySession(RHManageSessionBase): """Modify a session.""" + def render_form(self, form): + return jsonify_form(form) + def _process(self): form = SessionForm(obj=self.session, event=self.event) if form.validate_on_submit(): with track_location_changes(): update_session(self.session, form.data) return jsonify_data(html=_render_session_list(self.event)) - return jsonify_form(form) + return self.render_form(form) class RHDeleteSessions(RHManageSessionsActionsBase): diff --git a/indico/modules/events/timetable/controllers/legacy.py b/indico/modules/events/timetable/controllers/legacy.py index 6d908fd0e01..d92f2af98b5 100644 --- a/indico/modules/events/timetable/controllers/legacy.py +++ b/indico/modules/events/timetable/controllers/legacy.py @@ -176,6 +176,9 @@ def _process_args(self): RHManageTimetableEntryBase._process_args(self) self.edit_session = request.args.get('edit_session') == '1' + def render_form(self, form): + return jsonify_form(form, fields=getattr(form, '_display_fields', None)) + def _process(self): form = None parent_session_block = self.entry.parent.object if self.entry.parent else None @@ -238,7 +241,7 @@ def _process(self): return jsonify_data(update=serialize_entry_update(self.entry, session_=self.session), notifications=notifications, flash=False) self.commit = False - return jsonify_form(form, fields=getattr(form, '_display_fields', None)) + return self.render_form(form) class RHLegacyTimetableEditEntryTime(RHManageTimetableEntryBase):