diff --git a/app/projects/api.py b/app/projects/api.py index f3f3dd11..8d6c4257 100644 --- a/app/projects/api.py +++ b/app/projects/api.py @@ -15,6 +15,7 @@ from django.http import QueryDict from django.shortcuts import get_object_or_404 from django.shortcuts import redirect +from django.shortcuts import render from dal import autocomplete from contact.views import email_send @@ -774,7 +775,7 @@ def submit_user_permission_request(request): # Check if there are administrators to notify. if project.project_supervisors is None or project.project_supervisors == "": - return HttpResponse(200) + return render(request, 'projects/signup/request-access.html', {"panel": {"additional_context": {"requested_access": True}}}) # Convert the comma separated string of emails into a list. supervisor_emails = project.project_supervisors.split(",") @@ -798,7 +799,7 @@ def submit_user_permission_request(request): except Exception as e: logger.exception(e) - return HttpResponse(200) + return render(request, 'projects/signup/request-access.html', {"panel": {"additional_context": {"requested_access": True}}}) 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 0d0a708b..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 @@ -603,19 +608,23 @@ def setup_panel_request_access(self, context): if not self.project.requires_authorization or self.project.has_teams: return - # This step is never completed, it is usually the last step. - step_status = self.get_step_status('request_access', False) - # If the user does not have a participant record, they have not yet requested access. requested_access = self.participant is not None + # Check for a prior current step which is possible even when this step is complete + # due to rejection of signed agreement forms + 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, is_pending=True) + panel = DataProjectSignupPanel( title='Request Access', bootstrap_color='default', template='projects/signup/request-access.html', status=step_status, additional_context={ - 'requested_access': requested_access + 'requested_access': requested_access, } ) @@ -642,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 5d4327cd..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 %} + {% if panel.status == SIGNUP_STEP_CURRENT_STATUS or panel.status == SIGNUP_STEP_PERMANENT_STATUS or panel.status == SIGNUP_STEP_PENDING_STATUS %}
{% include panel.template %}
@@ -235,8 +237,15 @@ "); + + // Reset button and update to indicate success + $(submit_button).button("reset"); + setTimeout(function() { + // Do this in a timeout since Bootstrap's 'button' function breaks jQuery methods in same iteration + $(submit_button).html("Form Saved  ").prop("disabled", "disabled").toggleClass("btn-primary btn-success"); + }, 0); // Refresh the page so the user does not see this button again setTimeout(function(){ @@ -299,8 +308,16 @@ "); + + // Notify + notify('success', "Agreement form submitted!", 'thumbs-up'); + + // Reset button and update to indicate success + $(submit_button).button("reset"); + setTimeout(function() { + // Do this in a timeout since Bootstrap's 'button' function breaks jQuery methods in same iteration + $(submit_button).html("Form Saved  ").prop("disabled", "disabled").toggleClass("btn-primary btn-success"); + }, 0); // Refresh the page so the user does not see this button again setTimeout(function(){ diff --git a/app/templates/projects/signup/request-access.html b/app/templates/projects/signup/request-access.html index 46e81010..7c014db4 100644 --- a/app/templates/projects/signup/request-access.html +++ b/app/templates/projects/signup/request-access.html @@ -3,7 +3,10 @@ {% if panel.additional_context.requested_access %} Your request is being reviewed. Please use the 'Contact Us' link for any further questions. {% else %} -
+
@@ -16,9 +19,9 @@
- - -
+
@@ -28,22 +31,22 @@ {% endif %}