From d991314a54ed66cbad2c2d3e78c2699c4ff43bb6 Mon Sep 17 00:00:00 2001 From: Bryan Larson Date: Mon, 18 Sep 2023 14:07:08 -0600 Subject: [PATCH] HYP-300 - Added another panel header status for pending actions --- app/projects/panels.py | 3 ++ app/projects/views.py | 32 +++++++++++++------ app/static/custom.css | 8 ++++- app/templates/projects/project.html | 4 ++- .../projects/signup/request-access.html | 2 +- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/projects/panels.py b/app/projects/panels.py index c3e4b000..f07c595b 100644 --- a/app/projects/panels.py +++ b/app/projects/panels.py @@ -10,6 +10,9 @@ # For signup steps that will always be displayed no matter what actions are taken. SIGNUP_STEP_PERMANENT_STATUS = 'permanent' +# For signup steps that have already been completed but are pending admin action. +SIGNUP_STEP_PENDING_STATUS = 'pending' + class DataProjectPanel(): """ The base class that holds information needed to when displaying a panel diff --git a/app/projects/views.py b/app/projects/views.py index 9e652bc5..e8db2cd5 100644 --- a/app/projects/views.py +++ b/app/projects/views.py @@ -18,7 +18,7 @@ from profile.forms import RegistrationForm from hypatio.auth0authenticate import public_user_auth_and_jwt from hypatio.auth0authenticate import user_auth_and_jwt -from projects.models import AGREEMENT_FORM_TYPE_EXTERNAL_LINK, TEAM_ACTIVE, TEAM_READY +from projects.models import AGREEMENT_FORM_TYPE_EXTERNAL_LINK, TEAM_ACTIVE, TEAM_READY, TEAM_PENDING from projects.models import AGREEMENT_FORM_TYPE_STATIC from projects.models import AGREEMENT_FORM_TYPE_MODEL from projects.models import AGREEMENT_FORM_TYPE_FILE @@ -32,6 +32,7 @@ from projects.panels import SIGNUP_STEP_CURRENT_STATUS from projects.panels import SIGNUP_STEP_FUTURE_STATUS from projects.panels import SIGNUP_STEP_PERMANENT_STATUS +from projects.panels import SIGNUP_STEP_PENDING_STATUS from projects.panels import DataProjectInformationalPanel from projects.panels import DataProjectSignupPanel from projects.panels import DataProjectActionablePanel @@ -220,6 +221,7 @@ def get_context_data(self, **kwargs): context['SIGNUP_STEP_CURRENT_STATUS'] = SIGNUP_STEP_CURRENT_STATUS context['SIGNUP_STEP_FUTURE_STATUS'] = SIGNUP_STEP_FUTURE_STATUS context['SIGNUP_STEP_PERMANENT_STATUS'] = SIGNUP_STEP_PERMANENT_STATUS + context['SIGNUP_STEP_PENDING_STATUS'] = SIGNUP_STEP_PENDING_STATUS # If this project is informational only, just show them the description without requiring an account. if self.project.informational_only: @@ -386,7 +388,7 @@ def get_manager_context(self, context): return context - def get_step_status(self, step_name, step_complete, is_permanent=False): + def get_step_status(self, step_name, step_complete, is_permanent=False, is_pending=False): """ Returns the status this step should have. If the given step is incomplete and we do not already have a current_step, then this step is the current step and update @@ -399,6 +401,9 @@ def get_step_status(self, step_name, step_complete, is_permanent=False): if is_permanent: return SIGNUP_STEP_PERMANENT_STATUS + if is_pending: + return SIGNUP_STEP_PENDING_STATUS + logger.debug(f"{self.project.project_key}/{step_name}: Completed step") return SIGNUP_STEP_COMPLETED_STATUS @@ -611,10 +616,7 @@ def setup_panel_request_access(self, context): prior_current_step = next((s for s in context["setup_panels"] if s.status == SIGNUP_STEP_CURRENT_STATUS ), None) # This step is never completed, it is usually the last step. - step_status = self.get_step_status('request_access', requested_access and not prior_current_step) - - # Always show expanded when completed, unless a prior step is current - expanded = requested_access and not prior_current_step + step_status = self.get_step_status('request_access', requested_access and not prior_current_step, is_pending=True) panel = DataProjectSignupPanel( title='Request Access', @@ -623,7 +625,6 @@ def setup_panel_request_access(self, context): status=step_status, additional_context={ 'requested_access': requested_access, - 'expanded': expanded, } ) @@ -650,8 +651,21 @@ def setup_panel_team(self, context): team_approved=False ) - # This step is never completed. - step_status = self.get_step_status('setup_team', False) + # This step is completed/pending if the participant has been associated + # with a team, or for a team leader, request for access has been made. + if team and self.participant.user == team.team_leader: + + # Step is completed if awaiting access + completed = team.status == TEAM_READY + elif team and self.participant.user != team.team_leader: + + # Step is completed if awaiting access + completed = True + else: + completed = False + + # Determine step status + step_status = self.get_step_status('setup_team', completed, is_pending=True) panel = DataProjectSignupPanel( title='Join or Create a Team', diff --git a/app/static/custom.css b/app/static/custom.css index a019b63a..2e292e50 100644 --- a/app/static/custom.css +++ b/app/static/custom.css @@ -17,6 +17,12 @@ float: right; color: gray; } +.pending-step-header span:after { + font-family:'Glyphicons Halflings'; + content:"\e023"; + float: right; + color: #1F1C18; +} .accordion-step-header span:after { font-family:'Glyphicons Halflings'; content:"\e234"; @@ -41,4 +47,4 @@ /* Colors the asterisks detail on the form red */ .required-field-tip { color: rgb(153, 8, 8); -} \ No newline at end of file +} diff --git a/app/templates/projects/project.html b/app/templates/projects/project.html index 0c7c5762..b540239e 100644 --- a/app/templates/projects/project.html +++ b/app/templates/projects/project.html @@ -62,6 +62,8 @@

current-step-header {% elif panel.status == SIGNUP_STEP_PERMANENT_STATUS %} current-step-header + {% elif panel.status == SIGNUP_STEP_PENDING_STATUS %} + pending-step-header {% else %} blocked-step-header {% endif %}"> @@ -69,7 +71,7 @@

- {% if panel.status == SIGNUP_STEP_CURRENT_STATUS or panel.status == SIGNUP_STEP_PERMANENT_STATUS or panel.additional_context.expanded %} + {% if panel.status == SIGNUP_STEP_CURRENT_STATUS or panel.status == SIGNUP_STEP_PERMANENT_STATUS or panel.status == SIGNUP_STEP_PENDING_STATUS %}
{% include panel.template %}
diff --git a/app/templates/projects/signup/request-access.html b/app/templates/projects/signup/request-access.html index eca58dd5..7c014db4 100644 --- a/app/templates/projects/signup/request-access.html +++ b/app/templates/projects/signup/request-access.html @@ -41,7 +41,7 @@ notify('success', 'Access request submitted', 'thumbs-up'); // Update panel class - $(".container").find(".current-step-header").toggleClass("current-step-header completed-step-header"); + $(".container").find(".current-step-header").toggleClass("current-step-header pending-step-header"); } function onAccessRequestError() {