diff --git a/hypha/apply/funds/migrations/0095_only_external_review_option.py b/hypha/apply/funds/migrations/0095_only_external_review_option.py new file mode 100644 index 0000000000000000000000000000000000000000..04f995f420912d2ff131766d296db84e5becb276 --- /dev/null +++ b/hypha/apply/funds/migrations/0095_only_external_review_option.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.13 on 2022-04-25 07:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('funds', '0094_auto_20220406_0800'), + ] + + operations = [ + migrations.AlterField( + model_name='reviewersettings', + name='state', + field=models.CharField(choices=[('all', 'All States'), ('ext_state_or_higher', 'Only External review and higher'), ('ext_state_only', 'Only External review')], default='all', help_text='Submissions states for which reviewers should have access to', max_length=20), + ), + ] diff --git a/hypha/apply/funds/models/reviewer_role.py b/hypha/apply/funds/models/reviewer_role.py index 4226124cfc3e8ad575e0c2d17d2317eef84468f5..a895bd691fd2e42c58e23068c1caf3a6dae41180 100644 --- a/hypha/apply/funds/models/reviewer_role.py +++ b/hypha/apply/funds/models/reviewer_role.py @@ -44,7 +44,8 @@ class ReviewerSettings(BaseSetting): STATES = [ ('all', 'All States'), - ('ext_state_or_higher', 'Only External review and higher') + ('ext_state_or_higher', 'Only External review and higher'), + ('ext_state_only', 'Only External review') ] OUTCOMES = [ diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index a0299f60efa9b50b7f84585d242eb4d1c9966b53..596841360cb4144c427146b796fc3773ba17fe73 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -57,6 +57,7 @@ from ..workflow import ( active_statuses, dismissed_statuses, ext_or_higher_statuses, + ext_review_statuses, get_review_active_statuses, review_statuses, ) @@ -146,6 +147,8 @@ class ApplicationSubmissionQueryset(JSONOrderable): qs = qs.reviewed_by(user) if reviewer_settings.state == 'ext_state_or_higher': qs = qs.filter(status__in=ext_or_higher_statuses) + if reviewer_settings.state == 'ext_state_only': + qs = qs.filter(status__in=ext_review_statuses) if reviewer_settings.outcome == 'accepted': qs = qs.filter(status__in=accepted_statuses) if reviewer_settings.outcome == 'all_except_dismissed': diff --git a/hypha/apply/funds/workflow.py b/hypha/apply/funds/workflow.py index c79c373a752e35101b673000b0633da6e06ff0df..c5f7a387d232a34285ba5efcd61a12a6b72ad5cd 100644 --- a/hypha/apply/funds/workflow.py +++ b/hypha/apply/funds/workflow.py @@ -1013,25 +1013,34 @@ def get_review_statuses(user=None): return reviews +def get_ext_review_statuses(): + reviews = set() + + for phase_name, phase in PHASES: + if phase_name.endswith('external_review'): + reviews.add(phase_name) + return reviews + + def get_ext_or_higher_statuses(): """ Returns a set of all the statuses for all workflow which are External Review or higher than that. """ - ext_review_or_higher_statuses = set() + reviews = set() for workflow in WORKFLOWS.values(): step = None for phase in workflow.values(): - if phase.display_name == 'External Review': + if phase.name.endswith('external_review'): # Update the step for this workflow as External review state step = phase.step # Phase should have step higher or equal than External # review state for this workflow if step and phase.step >= step: - ext_review_or_higher_statuses.add(phase.name) - return ext_review_or_higher_statuses + reviews.add(phase.name) + return reviews def get_accepted_statuses(): @@ -1050,8 +1059,9 @@ def get_dismissed_statuses(): return dismissed_statuses -ext_or_higher_statuses = get_ext_or_higher_statuses() review_statuses = get_review_statuses() +ext_review_statuses = get_ext_review_statuses() +ext_or_higher_statuses = get_ext_or_higher_statuses() accepted_statuses = get_accepted_statuses() dismissed_statuses = get_dismissed_statuses()