18
18
from profile .forms import RegistrationForm
19
19
from hypatio .auth0authenticate import public_user_auth_and_jwt
20
20
from hypatio .auth0authenticate import user_auth_and_jwt
21
- from projects .models import AGREEMENT_FORM_TYPE_EXTERNAL_LINK , TEAM_ACTIVE , TEAM_READY
21
+ from projects .models import AGREEMENT_FORM_TYPE_EXTERNAL_LINK , TEAM_ACTIVE , TEAM_READY , TEAM_PENDING
22
22
from projects .models import AGREEMENT_FORM_TYPE_STATIC
23
23
from projects .models import AGREEMENT_FORM_TYPE_MODEL
24
24
from projects .models import AGREEMENT_FORM_TYPE_FILE
32
32
from projects .panels import SIGNUP_STEP_CURRENT_STATUS
33
33
from projects .panels import SIGNUP_STEP_FUTURE_STATUS
34
34
from projects .panels import SIGNUP_STEP_PERMANENT_STATUS
35
+ from projects .panels import SIGNUP_STEP_PENDING_STATUS
35
36
from projects .panels import DataProjectInformationalPanel
36
37
from projects .panels import DataProjectSignupPanel
37
38
from projects .panels import DataProjectActionablePanel
@@ -220,6 +221,7 @@ def get_context_data(self, **kwargs):
220
221
context ['SIGNUP_STEP_CURRENT_STATUS' ] = SIGNUP_STEP_CURRENT_STATUS
221
222
context ['SIGNUP_STEP_FUTURE_STATUS' ] = SIGNUP_STEP_FUTURE_STATUS
222
223
context ['SIGNUP_STEP_PERMANENT_STATUS' ] = SIGNUP_STEP_PERMANENT_STATUS
224
+ context ['SIGNUP_STEP_PENDING_STATUS' ] = SIGNUP_STEP_PENDING_STATUS
223
225
224
226
# If this project is informational only, just show them the description without requiring an account.
225
227
if self .project .informational_only :
@@ -386,7 +388,7 @@ def get_manager_context(self, context):
386
388
387
389
return context
388
390
389
- def get_step_status (self , step_name , step_complete , is_permanent = False ):
391
+ def get_step_status (self , step_name , step_complete , is_permanent = False , is_pending = False ):
390
392
"""
391
393
Returns the status this step should have. If the given step is incomplete and we do not
392
394
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):
399
401
if is_permanent :
400
402
return SIGNUP_STEP_PERMANENT_STATUS
401
403
404
+ if is_pending :
405
+ return SIGNUP_STEP_PENDING_STATUS
406
+
402
407
logger .debug (f"{ self .project .project_key } /{ step_name } : Completed step" )
403
408
return SIGNUP_STEP_COMPLETED_STATUS
404
409
@@ -611,10 +616,7 @@ def setup_panel_request_access(self, context):
611
616
prior_current_step = next ((s for s in context ["setup_panels" ] if s .status == SIGNUP_STEP_CURRENT_STATUS ), None )
612
617
613
618
# This step is never completed, it is usually the last step.
614
- step_status = self .get_step_status ('request_access' , requested_access and not prior_current_step )
615
-
616
- # Always show expanded when completed, unless a prior step is current
617
- expanded = requested_access and not prior_current_step
619
+ step_status = self .get_step_status ('request_access' , requested_access and not prior_current_step , is_pending = True )
618
620
619
621
panel = DataProjectSignupPanel (
620
622
title = 'Request Access' ,
@@ -623,7 +625,6 @@ def setup_panel_request_access(self, context):
623
625
status = step_status ,
624
626
additional_context = {
625
627
'requested_access' : requested_access ,
626
- 'expanded' : expanded ,
627
628
}
628
629
)
629
630
@@ -650,8 +651,21 @@ def setup_panel_team(self, context):
650
651
team_approved = False
651
652
)
652
653
653
- # This step is never completed.
654
- step_status = self .get_step_status ('setup_team' , False )
654
+ # This step is completed/pending if the participant has been associated
655
+ # with a team, or for a team leader, request for access has been made.
656
+ if team and self .participant .user == team .team_leader :
657
+
658
+ # Step is completed if awaiting access
659
+ completed = team .status == TEAM_READY
660
+ elif team and self .participant .user != team .team_leader :
661
+
662
+ # Step is completed if awaiting access
663
+ completed = True
664
+ else :
665
+ completed = False
666
+
667
+ # Determine step status
668
+ step_status = self .get_step_status ('setup_team' , completed , is_pending = True )
655
669
656
670
panel = DataProjectSignupPanel (
657
671
title = 'Join or Create a Team' ,
0 commit comments