From 20f007453302d07b788ef2c3a65b5d232a6b1d5a Mon Sep 17 00:00:00 2001 From: hannahgooden Date: Tue, 17 Jan 2023 09:30:41 -0500 Subject: [PATCH] #387 Allow skipping is now a namespace setting (#391) * #387 Allow skipping is now a namespace setting * Change skipability to integer number that skipping decrements priority by * Cover negative priority edge case --- neuvue_project/workspace/admin.py | 1 + .../0017_namespace_decrement_priority.py | 18 ++++++++++++++++++ neuvue_project/workspace/models.py | 1 + neuvue_project/workspace/views/workspace.py | 6 ++++-- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 neuvue_project/workspace/migrations/0017_namespace_decrement_priority.py diff --git a/neuvue_project/workspace/admin.py b/neuvue_project/workspace/admin.py index 1cfe29df..5d57756e 100644 --- a/neuvue_project/workspace/admin.py +++ b/neuvue_project/workspace/admin.py @@ -41,6 +41,7 @@ class NamespaceAdmin(admin.ModelAdmin): "number_of_tasks_users_can_self_assign", "max_number_of_pending_tasks_per_user", "track_selected_segments", + "decrement_priority" ] }, ), diff --git a/neuvue_project/workspace/migrations/0017_namespace_decrement_priority.py b/neuvue_project/workspace/migrations/0017_namespace_decrement_priority.py new file mode 100644 index 00000000..c3716956 --- /dev/null +++ b/neuvue_project/workspace/migrations/0017_namespace_decrement_priority.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.7 on 2023-01-16 22:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('workspace', '0016_forcedchoicebuttongroup_number_of_selected_segments_expected'), + ] + + operations = [ + migrations.AddField( + model_name='namespace', + name='decrement_priority', + field=models.IntegerField(default=100, verbose_name='When skipped, decrement priority by'), + ), + ] diff --git a/neuvue_project/workspace/models.py b/neuvue_project/workspace/models.py index a59a4c8a..cb6e4480 100644 --- a/neuvue_project/workspace/models.py +++ b/neuvue_project/workspace/models.py @@ -135,6 +135,7 @@ class Namespace(models.Model): number_of_tasks_users_can_self_assign = models.IntegerField(default=10) max_number_of_pending_tasks_per_user = models.IntegerField(default=200) track_selected_segments = models.BooleanField(default=False) + decrement_priority = models.IntegerField(default=100, verbose_name="When skipped, decrement priority by") """Pull From Push To Novice""" novice_pull_from = models.CharField( diff --git a/neuvue_project/workspace/views/workspace.py b/neuvue_project/workspace/views/workspace.py index 4ac27073..f58c3d95 100644 --- a/neuvue_project/workspace/views/workspace.py +++ b/neuvue_project/workspace/views/workspace.py @@ -48,7 +48,7 @@ def get(self, request, namespace=None, **kwargs): "seg_id": "", "is_open": False, "tasks_available": True, - "skipable": True, + "skipable": True if namespace_obj.decrement_priority > 0 else False, "instructions": "", "display_name": namespace_obj.display_name, "submission_method": submission_method, @@ -291,10 +291,12 @@ def post(self, request, *args, **kwargs): metadata["skipped"] = 1 try: + new_priority = task_df["priority"] - namespace_obj.decrement_priority + if new_priority < 0: new_priority = 0 client.patch_task( task_df["_id"], duration=duration, - priority=task_df["priority"] - 100, + priority=new_priority, status="pending", metadata=metadata, ng_state=ng_state,