From fbe32f75dc4da93ed562ac7f561b6867cb9c9638 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sat, 21 Sep 2019 20:37:16 +0200 Subject: [PATCH] Add approaches fields to sub, pub, commentary, theses --- .../migrations/0007_commentary_approaches.py | 44 +++++++++++++++++++ commentaries/models.py | 7 ++- .../migrations/0070_publication_approaches.py | 44 +++++++++++++++++++ journals/models.py | 5 ++- scipost/constants.py | 19 ++++++++ submissions/admin.py | 1 + submissions/forms.py | 1 + .../migrations/0060_submission_approaches.py | 44 +++++++++++++++++++ submissions/models.py | 5 ++- .../submissions/submission_summary.html | 10 ++++- .../migrations/0004_thesislink_approaches.py | 44 +++++++++++++++++++ theses/models.py | 6 ++- 12 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 commentaries/migrations/0007_commentary_approaches.py create mode 100644 journals/migrations/0070_publication_approaches.py create mode 100644 submissions/migrations/0060_submission_approaches.py create mode 100644 theses/migrations/0004_thesislink_approaches.py diff --git a/commentaries/migrations/0007_commentary_approaches.py b/commentaries/migrations/0007_commentary_approaches.py new file mode 100644 index 000000000..d12b8e9b3 --- /dev/null +++ b/commentaries/migrations/0007_commentary_approaches.py @@ -0,0 +1,44 @@ +# Generated by Django 2.1.8 on 2019-09-21 17:17 + +from django.db import migrations, models +import scipost.fields + + +def domains_to_approaches(apps, schema_editor): + Commentary = apps.get_model('commentaries.Commentary') + + for commentary in Commentary.objects.filter(domain__contains='E'): + if commentary.approaches: + commentary.approaches.append('experimental') + else: + commentary.approaches = ('experimental',) + commentary.save() + for commentary in Commentary.objects.filter(domain__contains='T'): + if commentary.approaches: + commentary.approaches.append('theoretical') + else: + commentary.approaches = ('theoretical',) + commentary.save() + for commentary in Commentary.objects.filter(domain__contains='C'): + if commentary.approaches: + commentary.approaches.append('computational') + else: + commentary.approaches = ('computational',) + commentary.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('commentaries', '0006_auto_20190522_1120'), + ] + + operations = [ + migrations.AddField( + model_name='commentary', + name='approaches', + field=scipost.fields.ChoiceArrayField(base_field=models.CharField(choices=[('theoretical', 'Theoretical'), ('experimental', 'Experimental'), ('computational', 'Computational'), ('phenomenological', 'Phenomenological'), ('observational', 'Observational'), ('clinical', 'Clinical')], max_length=24), blank=True, null=True, size=None, verbose_name='approach(es) [optional]'), + ), + migrations.RunPython(domains_to_approaches, + reverse_code=migrations.RunPython.noop), + ] diff --git a/commentaries/models.py b/commentaries/models.py index b64ec5930..7e683eeda 100644 --- a/commentaries/models.py +++ b/commentaries/models.py @@ -9,7 +9,9 @@ from django.urls import reverse from journals.constants import SCIPOST_JOURNALS_DOMAINS from scipost.behaviors import TimeStampedModel -from scipost.constants import SCIPOST_DISCIPLINES, DISCIPLINE_PHYSICS, SCIPOST_SUBJECT_AREAS +from scipost.constants import SCIPOST_DISCIPLINES, DISCIPLINE_PHYSICS,\ + SCIPOST_APPROACHES, SCIPOST_SUBJECT_AREAS +from scipost.fields import ChoiceArrayField from .constants import COMMENTARY_TYPES from .managers import CommentaryManager @@ -31,6 +33,9 @@ class Commentary(TimeStampedModel): domain = models.CharField(max_length=3, choices=SCIPOST_JOURNALS_DOMAINS) subject_area = models.CharField(max_length=10, choices=SCIPOST_SUBJECT_AREAS, default='Phys:QP') + approaches = ChoiceArrayField( + models.CharField(max_length=24, choices=SCIPOST_APPROACHES), + blank=True, null=True, verbose_name='approach(es) [optional]') open_for_commenting = models.BooleanField(default=True) # Article/publication data diff --git a/journals/migrations/0070_publication_approaches.py b/journals/migrations/0070_publication_approaches.py new file mode 100644 index 000000000..c5b8aa04a --- /dev/null +++ b/journals/migrations/0070_publication_approaches.py @@ -0,0 +1,44 @@ +# Generated by Django 2.1.8 on 2019-09-21 17:17 + +from django.db import migrations, models +import scipost.fields + + +def domains_to_approaches(apps, schema_editor): + Publication = apps.get_model('journals.Publication') + + for publication in Publication.objects.filter(domain__contains='E'): + if publication.approaches: + publication.approaches.append('experimental') + else: + publication.approaches = ('experimental',) + publication.save() + for publication in Publication.objects.filter(domain__contains='T'): + if publication.approaches: + publication.approaches.append('theoretical') + else: + publication.approaches = ('theoretical',) + publication.save() + for publication in Publication.objects.filter(domain__contains='C'): + if publication.approaches: + publication.approaches.append('computational') + else: + publication.approaches = ('computational',) + publication.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0069_auto_20190911_0547'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='approaches', + field=scipost.fields.ChoiceArrayField(base_field=models.CharField(choices=[('theoretical', 'Theoretical'), ('experimental', 'Experimental'), ('computational', 'Computational'), ('phenomenological', 'Phenomenological'), ('observational', 'Observational'), ('clinical', 'Clinical')], max_length=24), blank=True, null=True, size=None, verbose_name='approach(es) [optional]'), + ), + migrations.RunPython(domains_to_approaches, + reverse_code=migrations.RunPython.noop), + ] diff --git a/journals/models.py b/journals/models.py index 11c73884a..03be2db6f 100644 --- a/journals/models.py +++ b/journals/models.py @@ -25,7 +25,7 @@ from .constants import ( from .helpers import paper_nr_string from .managers import IssueQuerySet, PublicationQuerySet, JournalQuerySet -from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS +from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS, SCIPOST_APPROACHES from scipost.fields import ChoiceArrayField from proceedings.models import Proceedings @@ -426,6 +426,9 @@ class Publication(models.Model): verbose_name='Primary subject area', default='Phys:QP') secondary_areas = ChoiceArrayField( models.CharField(max_length=10, choices=SCIPOST_SUBJECT_AREAS), blank=True, null=True) + approaches = ChoiceArrayField( + models.CharField(max_length=24, choices=SCIPOST_APPROACHES), + blank=True, null=True, verbose_name='approach(es) [optional]') # Authors authors_claims = models.ManyToManyField('scipost.Contributor', blank=True, diff --git a/scipost/constants.py b/scipost/constants.py index 9c423f8b3..0c5772dc3 100644 --- a/scipost/constants.py +++ b/scipost/constants.py @@ -15,6 +15,7 @@ SCIPOST_DISCIPLINES = ( (DISCIPLINE_COMPUTERSCIENCE, 'Computer Science'), ) + SCIPOST_SUBJECT_AREAS = ( ('Physics', ( ('Phys:AE', 'Atomic, Molecular and Optical Physics - Experiment'), @@ -139,6 +140,24 @@ subject_areas_dict = {} for k in subject_areas_raw_dict.keys(): subject_areas_dict.update(dict(subject_areas_raw_dict[k])) + +APPROACH_THEORETICAL = 'theoretical' +APPROACH_EXPERIMENTAL = 'experimental' +APPROACH_COMPUTATIONAL = 'computational' +APPROACH_PHENOMENOLOGICAL = 'phenomenological' +APPROACH_OBSERVATIONAL = 'observational' +APPROACH_CLINICAL = 'clinical' + +SCIPOST_APPROACHES = ( + (APPROACH_THEORETICAL, 'Theoretical'), + (APPROACH_EXPERIMENTAL, 'Experimental'), + (APPROACH_COMPUTATIONAL, 'Computational'), + (APPROACH_PHENOMENOLOGICAL, 'Phenomenological'), + (APPROACH_OBSERVATIONAL, 'Observational'), + (APPROACH_CLINICAL, 'Clinical'), +) + + # Contributor types NEWLY_REGISTERED, NORMAL_CONTRIBUTOR = 'newly_registered', 'normal' UNVERIFIABLE_CREDENTIALS, NO_SCIENTIST = 'unverifiable', 'no_scientist' diff --git a/submissions/admin.py b/submissions/admin.py index a98d34377..cc5230c19 100644 --- a/submissions/admin.py +++ b/submissions/admin.py @@ -103,6 +103,7 @@ class SubmissionAdmin(GuardedModelAdmin): 'domain', 'subject_area', 'secondary_areas', + 'approaches', 'proceedings'), }), ('Authors', { diff --git a/submissions/forms.py b/submissions/forms.py index 3f91fad3b..2780f3115 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -341,6 +341,7 @@ class SubmissionForm(forms.ModelForm): 'domain', 'subject_area', 'secondary_areas', + 'approaches', 'title', 'author_list', 'abstract', diff --git a/submissions/migrations/0060_submission_approaches.py b/submissions/migrations/0060_submission_approaches.py new file mode 100644 index 000000000..bd231fa88 --- /dev/null +++ b/submissions/migrations/0060_submission_approaches.py @@ -0,0 +1,44 @@ +# Generated by Django 2.1.8 on 2019-09-21 17:17 + +from django.db import migrations, models +import scipost.fields + + +def domains_to_approaches(apps, schema_editor): + Submission = apps.get_model('submissions.Submission') + + for submission in Submission.objects.filter(domain__contains='E'): + if submission.approaches: + submission.approaches.append('experimental') + else: + submission.approaches = ('experimental',) + submission.save() + for submission in Submission.objects.filter(domain__contains='T'): + if submission.approaches: + submission.approaches.append('theoretical') + else: + submission.approaches = ('theoretical',) + submission.save() + for submission in Submission.objects.filter(domain__contains='C'): + if submission.approaches: + submission.approaches.append('computational') + else: + submission.approaches = ('computational',) + submission.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0059_auto_20190912_0906'), + ] + + operations = [ + migrations.AddField( + model_name='submission', + name='approaches', + field=scipost.fields.ChoiceArrayField(base_field=models.CharField(choices=[('theoretical', 'Theoretical'), ('experimental', 'Experimental'), ('computational', 'Computational'), ('phenomenological', 'Phenomenological'), ('observational', 'Observational'), ('clinical', 'Clinical')], max_length=24), blank=True, null=True, size=None, verbose_name='approach(es) [optional]'), + ), + migrations.RunPython(domains_to_approaches, + reverse_code=migrations.RunPython.noop), + ] diff --git a/submissions/models.py b/submissions/models.py index fcfb1e36f..2e9040d87 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -36,7 +36,7 @@ from comments.behaviors import validate_file_extension, validate_max_file_size from comments.models import Comment from scipost.behaviors import TimeStampedModel from scipost.constants import TITLE_CHOICES -from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS +from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS, SCIPOST_APPROACHES from scipost.fields import ChoiceArrayField from scipost.models import Contributor from scipost.storage import SecureFileStorage @@ -61,6 +61,9 @@ class Submission(models.Model): author_list = models.CharField(max_length=10000, verbose_name="author list") discipline = models.CharField(max_length=20, choices=SCIPOST_DISCIPLINES, default='physics') domain = models.CharField(max_length=3, choices=SCIPOST_JOURNALS_DOMAINS) + approaches = ChoiceArrayField( + models.CharField(max_length=24, choices=SCIPOST_APPROACHES), + blank=True, null=True, verbose_name='approach(es) [optional]') editor_in_charge = models.ForeignKey('scipost.Contributor', related_name='EIC', blank=True, null=True, on_delete=models.CASCADE) diff --git a/submissions/templates/partials/submissions/submission_summary.html b/submissions/templates/partials/submissions/submission_summary.html index 212770224..3375f44ad 100644 --- a/submissions/templates/partials/submissions/submission_summary.html +++ b/submissions/templates/partials/submissions/submission_summary.html @@ -59,13 +59,19 @@ </tr> {% endif %} <tr> - <td>Domain(s):</td> - <td>{{submission.get_domain_display}}</td> + <td>Discipline:</td> + <td>{{ submission.get_discipline_display }}</td> </tr> <tr> <td>Subject area:</td> <td>{{submission.get_subject_area_display}}</td> </tr> + {% if submission.approaches %} + <tr> + <td>Approach{% if submission.approaches|length > 1 %}es{% endif %}:</td> + <td>{% for approach in submission.approaches %}{% if not forloop.first %}, {% endif %}{{ approach|capfirst }}{% endfor %}</td> + </tr> + {% endif %} </table> {% if show_abstract %} diff --git a/theses/migrations/0004_thesislink_approaches.py b/theses/migrations/0004_thesislink_approaches.py new file mode 100644 index 000000000..2557d30b1 --- /dev/null +++ b/theses/migrations/0004_thesislink_approaches.py @@ -0,0 +1,44 @@ +# Generated by Django 2.1.8 on 2019-09-21 17:17 + +from django.db import migrations, models +import scipost.fields + + +def domains_to_approaches(apps, schema_editor): + ThesisLink = apps.get_model('theses.ThesisLink') + + for thesis in ThesisLink.objects.filter(domain__contains='E'): + if thesis.approaches: + thesis.approaches.append('experimental') + else: + thesis.approaches = ('experimental',) + thesis.save() + for thesis in ThesisLink.objects.filter(domain__contains='T'): + if thesis.approaches: + thesis.approaches.append('theoretical') + else: + thesis.approaches = ('theoretical',) + thesis.save() + for thesis in ThesisLink.objects.filter(domain__contains='C'): + if thesis.approaches: + thesis.approaches.append('computational') + else: + thesis.approaches = ('computational',) + thesis.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('theses', '0003_auto_20190522_1120'), + ] + + operations = [ + migrations.AddField( + model_name='thesislink', + name='approaches', + field=scipost.fields.ChoiceArrayField(base_field=models.CharField(choices=[('theoretical', 'Theoretical'), ('experimental', 'Experimental'), ('computational', 'Computational'), ('phenomenological', 'Phenomenological'), ('observational', 'Observational'), ('clinical', 'Clinical')], max_length=24), blank=True, null=True, size=None, verbose_name='approach(es) [optional]'), + ), + migrations.RunPython(domains_to_approaches, + reverse_code=migrations.RunPython.noop), + ] diff --git a/theses/models.py b/theses/models.py index e50026a80..4e192ecfc 100644 --- a/theses/models.py +++ b/theses/models.py @@ -8,7 +8,8 @@ from django.urls import reverse from django.utils import timezone from journals.constants import SCIPOST_JOURNALS_DOMAINS -from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS +from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS, SCIPOST_APPROACHES +from scipost.fields import ChoiceArrayField from .constants import THESIS_TYPES from .managers import ThesisLinkManager @@ -35,6 +36,9 @@ class ThesisLink(models.Model): max_length=10, choices=SCIPOST_SUBJECT_AREAS, default='Phys:QP') + approaches = ChoiceArrayField( + models.CharField(max_length=24, choices=SCIPOST_APPROACHES), + blank=True, null=True, verbose_name='approach(es) [optional]') open_for_commenting = models.BooleanField(default=True) title = models.CharField(max_length=300, verbose_name='title') pub_link = models.URLField(verbose_name='URL (external repository)') -- GitLab