Skip to content

Commit

Permalink
HYP-300 - Added another panel header status for pending actions
Browse files Browse the repository at this point in the history
  • Loading branch information
b32147 committed Sep 18, 2023
1 parent 97359f4 commit d991314
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
3 changes: 3 additions & 0 deletions app/projects/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 23 additions & 9 deletions app/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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',
Expand All @@ -623,7 +625,6 @@ def setup_panel_request_access(self, context):
status=step_status,
additional_context={
'requested_access': requested_access,
'expanded': expanded,
}
)

Expand All @@ -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',
Expand Down
8 changes: 7 additions & 1 deletion app/static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -41,4 +47,4 @@
/* Colors the asterisks detail on the form red */
.required-field-tip {
color: rgb(153, 8, 8);
}
}
4 changes: 3 additions & 1 deletion app/templates/projects/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ <h2 class="panel-title">
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 %}">
<span>{{ panel.title }}</span>
</div>
</h2>
</div>
{% 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 %}
<div class="panel-body">
{% include panel.template %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/projects/signup/request-access.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d991314

Please sign in to comment.