From bed2a26c2046f8f0fbb25cab5d1824691be4068b Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Fri, 24 Sep 2021 22:48:13 +0530 Subject: [PATCH] add manual label (#9516) --- app/grants/utils.py | 2 ++ app/quests/quest_types/quiz_style.py | 2 +- .../migrations/0026_auto_20210923_1428.py | 18 ++++++++++++++++++ app/townsquare/models.py | 5 +++-- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 app/townsquare/migrations/0026_auto_20210923_1428.py diff --git a/app/grants/utils.py b/app/grants/utils.py index 48fc253cb05..c9ccd099803 100644 --- a/app/grants/utils.py +++ b/app/grants/utils.py @@ -350,6 +350,8 @@ def toggle_user_sybil(sybil_users, non_sybil_users): print(f"error: unable to mark user ${user.get('handle')} as sybil. {e}") if non_sybil_users: + # exclude squelches added by manual + squelched_profiles = squelched_profiles.exclude(label='Manual') # iterate and remove sybil from user for user in non_sybil_users: try: diff --git a/app/quests/quest_types/quiz_style.py b/app/quests/quest_types/quiz_style.py index 4c8cf56f6bd..5ffe19ada86 100644 --- a/app/quests/quest_types/quiz_style.py +++ b/app/quests/quest_types/quiz_style.py @@ -80,7 +80,7 @@ def details(request, quest): answer_level_seconds_to_respond = payload.get('seconds_to_respond', None) if answer_level_seconds_to_respond: this_time_per_answer = answer_level_seconds_to_respond - time_used = (timezone.now() - qa.modified_on).seconds + time_used = (timezone.now() - qa.modified_on).seconds if qa else timezone.now() is_out_of_time = time_used > this_time_per_answer + time_per_answer_buffer if is_out_of_time: # fix for silly issue where the time used is almost exactly diff --git a/app/townsquare/migrations/0026_auto_20210923_1428.py b/app/townsquare/migrations/0026_auto_20210923_1428.py new file mode 100644 index 00000000000..b66c8034ea7 --- /dev/null +++ b/app/townsquare/migrations/0026_auto_20210923_1428.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2021-09-23 14:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('townsquare', '0025_squelchprofile_label'), + ] + + operations = [ + migrations.AlterField( + model_name='squelchprofile', + name='label', + field=models.CharField(choices=[('Human', 'Human'), ('Heuristic', 'Heuristic'), ('Prediction', 'Prediction'), ('Manual', 'Manual')], default='Manual', help_text='means used to mark user as sybil', max_length=20), + ), + ] diff --git a/app/townsquare/models.py b/app/townsquare/models.py index 04aa3d6874a..f5e8cf1a868 100644 --- a/app/townsquare/models.py +++ b/app/townsquare/models.py @@ -442,7 +442,8 @@ class SquelchProfile(SuperModel): LABEL_CHOICES = ( ('Human', 'Human'), ('Heuristic', 'Heuristic'), - ('Prediction', 'Prediction') + ('Prediction', 'Prediction'), + ('Manual', 'Manual') ) profile = models.ForeignKey( 'dashboard.Profile', @@ -451,7 +452,7 @@ class SquelchProfile(SuperModel): ) label = models.CharField( choices=LABEL_CHOICES, - default='Human', + default='Manual', help_text='means used to mark user as sybil', max_length=20 )