SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit da7e15ff authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add fields college and specialties to Journal

parent 09257dd5
No related branches found
No related tags found
No related merge requests found
# Generated by Django 2.2.11 on 2020-09-06 07:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('colleges', '0016_populate_colleges'),
('ontology', '0007_Branch_Field_Specialty'),
('journals', '0091_auto_20200821_1427'),
]
operations = [
migrations.AddField(
model_name='journal',
name='college',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='journals', to='colleges.College'),
),
migrations.AddField(
model_name='journal',
name='specialties',
field=models.ManyToManyField(blank=True, related_name='journals', to='ontology.Specialty'),
),
]
# Generated by Django 2.2.11 on 2020-09-06 07:03
from django.db import migrations
def populate_journal_college(apps, schema_editor):
College = apps.get_model('colleges.College')
Journal = apps.get_model('journals.Journal')
for journal in Journal.objects.all():
field_name = journal.name.split(' ')[1]
if field_name != 'Selections':
college = College.objects.get(name=field_name)
journal.college = college
journal.save()
class Migration(migrations.Migration):
dependencies = [
('journals', '0092_auto_20200906_0903'),
]
operations = [
migrations.RunPython(populate_journal_college,
reverse_code=migrations.RunPython.noop),
]
......@@ -21,11 +21,35 @@ def cost_default_value():
class Journal(models.Model):
"""Journal is a container of Publications with a unique issn and doi_label.
"""Journal is a container of Publications, with a unique issn and doi_label.
Publications may be categorized into issues or issues and volumes.
Each Journal falls under the auspices of a specific College, which is ForeignKeyed.
The only exception is Selections, which does not point to any College
(in fact: it falls under the auspices of all colleges at the same time).
A Journal's AcademicField is indirectly specified via the College, since
College has a ForeignKey to AcademicField.
Specialties can optionally be specified (and should be consistent with the
College's `acad_field`). If none are given, the Journal operates field-wide.
"""
college = models.ForeignKey(
'colleges.College',
on_delete=models.PROTECT,
related_name='journals',
blank=True, null=True
)
specialties = models.ManyToManyField(
'ontology.Specialty',
blank=True,
related_name='journals'
)
# TODO: remove discipline
discipline = models.CharField(max_length=20, choices=SCIPOST_DISCIPLINES, default='physics')
name = models.CharField(max_length=256, unique=True)
name_abbrev = models.CharField(max_length=128, default='SciPost [abbrev]',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment