From 0f8520cd9a486d7005309fdd8b6eb44f786b2fc7 Mon Sep 17 00:00:00 2001 From: "ashwin.sp" Date: Tue, 28 May 2024 09:55:11 -0400 Subject: [PATCH] fix: Approval header now not displayed for already approved entities --- civictechprojects/models.py | 6 ++++-- .../controllers/CreateEventController.jsx | 14 ++++++++++---- .../controllers/CreateGroupController.jsx | 11 ++++++++--- .../controllers/CreateProjectController.jsx | 8 +++++++- common/components/utils/EventAPIUtils.js | 1 + common/components/utils/GroupAPIUtils.js | 1 + 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/civictechprojects/models.py b/civictechprojects/models.py index 116f17ff2..90ebeb8f0 100644 --- a/civictechprojects/models.py +++ b/civictechprojects/models.py @@ -349,7 +349,8 @@ def _hydrate_to_json(self): 'group_short_description': self.group_short_description, 'group_project_count': projects.count(), 'group_slug': self.group_slug, - 'is_private': self.is_private + 'is_private': self.is_private, + 'group_approved': self.is_searchable } if len(projects) > 0: @@ -499,7 +500,8 @@ def _hydrate_to_json(self): 'event_slug': self.event_slug, 'is_private': self.is_private, 'show_headers': self.show_headers, - "is_activated": self.is_activated + "is_activated": self.is_activated, + 'event_approved': self.is_searchable } if event_room is not None: diff --git a/common/components/controllers/CreateEventController.jsx b/common/components/controllers/CreateEventController.jsx index 71779304a..f2e366120 100644 --- a/common/components/controllers/CreateEventController.jsx +++ b/common/components/controllers/CreateEventController.jsx @@ -122,10 +122,16 @@ class CreateEventController extends React.PureComponent<{||}, State> { } onFinalSubmitSuccess(event: EventData): void { - window.location.href = url.section(Section.AboutEvent, { - id: event.event_id, - eventAwaitingApproval: url.encodeNameForUrlPassing(event.event_name), - }); + + if(!event.event_approved){ + window.location.href = url.section(Section.AboutEvent, { + id: event.event_id, + eventAwaitingApproval: url.encodeNameForUrlPassing(event.event_name), + }); + } else { + window.location.href = url.section(Section.AboutEvent, null); + } + } render(): React$Node { diff --git a/common/components/controllers/CreateGroupController.jsx b/common/components/controllers/CreateGroupController.jsx index ad28141ad..b30dc6934 100644 --- a/common/components/controllers/CreateGroupController.jsx +++ b/common/components/controllers/CreateGroupController.jsx @@ -129,9 +129,14 @@ class CreateGroupController extends React.PureComponent<{||}, State> { onFinalSubmitSuccess(group: GroupDetailsAPIData): void { // metrics.logGroupCreated(CurrentUser.userID()); // TODO: Fix bug with switching to this section without page reload - window.location.href = url.section(Section.MyGroups, { - groupAwaitingApproval: url.encodeNameForUrlPassing(group.group_name), - }); + if(!group.group_approved){ + window.location.href = url.section(Section.MyGroups, { + groupAwaitingApproval: url.encodeNameForUrlPassing(group.group_name), + }); + } else{ + window.location.href = url.section(Section.MyGroups, null); + } + } render(): React$Node { diff --git a/common/components/controllers/CreateProjectController.jsx b/common/components/controllers/CreateProjectController.jsx index 07050bcce..3e87c4df1 100644 --- a/common/components/controllers/CreateProjectController.jsx +++ b/common/components/controllers/CreateProjectController.jsx @@ -191,7 +191,13 @@ class CreateProjectController extends React.PureComponent<{||}, State> { fromEventId: project.event_created_from, }); } - window.location.href = url.section(Section.MyProjects, urlArgs); + if(!project.project_approved){ + window.location.href = url.section(Section.MyProjects, urlArgs); + } else { + window.location.href = url.section(Section.MyProjects, null); + + } + } render(): React$Node { diff --git a/common/components/utils/EventAPIUtils.js b/common/components/utils/EventAPIUtils.js index 2131e63ab..85e3d2dbe 100644 --- a/common/components/utils/EventAPIUtils.js +++ b/common/components/utils/EventAPIUtils.js @@ -41,6 +41,7 @@ export type EventData = {| event_conference_admin_url: ?string, event_conference_participants: ?string, event_time_zones: $ReadOnlyArray, + event_approved: boolean, |}; export type EventTileAPIData = {| diff --git a/common/components/utils/GroupAPIUtils.js b/common/components/utils/GroupAPIUtils.js index 9a2cca917..61666905b 100644 --- a/common/components/utils/GroupAPIUtils.js +++ b/common/components/utils/GroupAPIUtils.js @@ -34,6 +34,7 @@ export type GroupDetailsAPIData = {| group_links: $ReadOnlyArray, group_files: $ReadOnlyArray, is_private: boolean, + group_approved: boolean, |} & GroupTileAPIData; export type ProjectRelationshipAPIData = {|