From 444ff0e983c39b70bf89141e797f7f8731093e24 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 27 Feb 2024 15:07:42 +0000 Subject: [PATCH] add exam authors to collection/exam base --- .../migrations/0016_alter_exam_authors_only.py | 18 ++++++++++++++++++ .../0045_casecollection_authors_only.py | 18 ++++++++++++++++++ generic/mixins.py | 8 ++++++++ generic/models.py | 10 +++++----- .../migrations/0022_alter_exam_authors_only.py | 18 ++++++++++++++++++ .../migrations/0009_alter_exam_authors_only.py | 18 ++++++++++++++++++ .../migrations/0008_alter_exam_authors_only.py | 18 ++++++++++++++++++ .../migrations/0009_alter_exam_authors_only.py | 18 ++++++++++++++++++ 8 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 anatomy/migrations/0016_alter_exam_authors_only.py create mode 100644 atlas/migrations/0045_casecollection_authors_only.py create mode 100644 longs/migrations/0022_alter_exam_authors_only.py create mode 100644 physics/migrations/0009_alter_exam_authors_only.py create mode 100644 rapids/migrations/0008_alter_exam_authors_only.py create mode 100644 sbas/migrations/0009_alter_exam_authors_only.py diff --git a/anatomy/migrations/0016_alter_exam_authors_only.py b/anatomy/migrations/0016_alter_exam_authors_only.py new file mode 100644 index 00000000..7b0c47a8 --- /dev/null +++ b/anatomy/migrations/0016_alter_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('anatomy', '0015_alter_exam_exam_questions'), + ] + + operations = [ + migrations.AlterField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ] diff --git a/atlas/migrations/0045_casecollection_authors_only.py b/atlas/migrations/0045_casecollection_authors_only.py new file mode 100644 index 00000000..8b5305d7 --- /dev/null +++ b/atlas/migrations/0045_casecollection_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('atlas', '0044_seriesfinding_conditions'), + ] + + operations = [ + migrations.AddField( + model_name='casecollection', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ] diff --git a/generic/mixins.py b/generic/mixins.py index f2d668d1..0fd682a6 100644 --- a/generic/mixins.py +++ b/generic/mixins.py @@ -29,3 +29,11 @@ class AuthorMixin(): if not authors: return "None" return authors + + def add_author(self, user: User): + """Add an author to the object""" + self.author.add(user) + + def remove_author(self, user: User): + """Remove an author from the object""" + self.author.remove(user) diff --git a/generic/models.py b/generic/models.py index 012221b6..e5d32a4e 100644 --- a/generic/models.py +++ b/generic/models.py @@ -572,6 +572,11 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin): default=True, ) + authors_only = models.BooleanField( + help_text="If true only exam/collection authors will be able to view.", + default=False, + ) + class Meta: abstract = True @@ -803,11 +808,6 @@ class ExamBase(ExamOrCollectionGenericBase): default=1, help_text="auto incrementing field when json recreated" ) - authors_only = models.BooleanField( - help_text="If true only exam authors will be able to view.", - default=False, - ) - stats_mean = models.FloatField(default=0) stats_mode = models.CharField(default=0, max_length=25) stats_median = models.FloatField(default=0) diff --git a/longs/migrations/0022_alter_exam_authors_only.py b/longs/migrations/0022_alter_exam_authors_only.py new file mode 100644 index 00000000..edc72d53 --- /dev/null +++ b/longs/migrations/0022_alter_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0021_rename_rapid_examquestiondetail_question'), + ] + + operations = [ + migrations.AlterField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ] diff --git a/physics/migrations/0009_alter_exam_authors_only.py b/physics/migrations/0009_alter_exam_authors_only.py new file mode 100644 index 00000000..05b409ba --- /dev/null +++ b/physics/migrations/0009_alter_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('physics', '0008_alter_exam_exam_questions'), + ] + + operations = [ + migrations.AlterField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ] diff --git a/rapids/migrations/0008_alter_exam_authors_only.py b/rapids/migrations/0008_alter_exam_authors_only.py new file mode 100644 index 00000000..86e7b89b --- /dev/null +++ b/rapids/migrations/0008_alter_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rapids', '0007_alter_exam_exam_questions'), + ] + + operations = [ + migrations.AlterField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ] diff --git a/sbas/migrations/0009_alter_exam_authors_only.py b/sbas/migrations/0009_alter_exam_authors_only.py new file mode 100644 index 00000000..4a53bbef --- /dev/null +++ b/sbas/migrations/0009_alter_exam_authors_only.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-27 14:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sbas', '0008_alter_exam_exam_questions'), + ] + + operations = [ + migrations.AlterField( + model_name='exam', + name='authors_only', + field=models.BooleanField(default=False, help_text='If true only exam/collection authors will be able to view.'), + ), + ]