SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 317be6f2 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Improve journals migration scripts

parent 500cec2e
No related branches found
No related tags found
No related merge requests found
...@@ -10,37 +10,55 @@ def auto_remove_scipost_physics_proc(apps, schema_editor): ...@@ -10,37 +10,55 @@ def auto_remove_scipost_physics_proc(apps, schema_editor):
try: try:
journal = Journal.objects.get(name='SciPostPhysProc') journal = Journal.objects.get(name='SciPostPhysProc')
journal.delete() journal.delete()
print('\n...SciPost Physics Proceedings deleted.') print('\n - SciPost Physics Proceedings deleted...')
except Journal.DoesNotExist: except Journal.DoesNotExist:
print('\n...No SciPost Physics Proceedings does not exist.') print(' - No SciPost Physics Proceedings does not exist...')
def auto_add_scipost_physics_proc(apps, schema_editor): def auto_add_scipost_physics_proc(apps, schema_editor):
Journal = apps.get_model('journals', 'Journal') Journal = apps.get_model('journals', 'Journal')
Journal.objects.create(name='SciPostPhysProc', doi_string='SciPostPhysProc') Journal.objects.create(name='SciPostPhysProc', doi_string='SciPostPhysProc')
print('\n...SciPost Physics Proceedings created.') print(' - SciPost Physics Proceedings created...')
def alter_existing_journal_name(apps, schema_editor): def alter_existing_journal_name(apps, schema_editor):
Journal = apps.get_model('journals', 'Journal') Journal = apps.get_model('journals', 'Journal')
Submission = apps.get_model('submissions', 'Submission')
try: try:
journal = Journal.objects.get(name='SciPost Physics') journal = Journal.objects.get(name='SciPost Physics')
journal.name = 'SciPostPhys' journal.name = 'SciPostPhys'
journal.save() journal.save()
print('\n...SciPost Physics name updated.') print('\n - SciPost Physics name updated...')
Submission.objects.filter(submitted_to_journal='SciPost Physics').update(
submitted_to_journal='SciPostPhys'
)
Submission.objects.filter(submitted_to_journal='SciPost Physics Lecture Notes').update(
submitted_to_journal='SciPostPhysLectNotes'
)
print(' - Submission `submitted_to_journal` keys updated...')
except Journal.DoesNotExist: except Journal.DoesNotExist:
print('\n...No Journal Names altered.') print(' - No Journal Names altered...')
def reverse_alter_existing_journal_name(apps, schema_editor): def reverse_alter_existing_journal_name(apps, schema_editor):
Journal = apps.get_model('journals', 'Journal') Journal = apps.get_model('journals', 'Journal')
Submission = apps.get_model('submissions', 'Submission')
try: try:
journal = Journal.objects.get(name='SciPostPhys') journal = Journal.objects.get(name='SciPostPhys')
journal.name = 'SciPost Physics' journal.name = 'SciPost Physics'
journal.save() journal.save()
print('\n...SciPost Physics name updated.') print(' - SciPost Physics name updated...')
Submission.objects.filter(submitted_to_journal='SciPostPhys').update(
submitted_to_journal='SciPost Physics'
)
Submission.objects.filter(submitted_to_journal='SciPostPhysLectNotes').update(
submitted_to_journal='SciPost Physics Lecture Notes'
)
print(' - Submission `submitted_to_journal` keys updated...')
except Journal.DoesNotExist: except Journal.DoesNotExist:
print('\n...No Journal Names altered.') print(' - No Journal Names altered...')
class Migration(migrations.Migration): class Migration(migrations.Migration):
......
...@@ -15,7 +15,7 @@ def auto_deactivate_scipost_physics_proc(apps, schema_editor): ...@@ -15,7 +15,7 @@ def auto_deactivate_scipost_physics_proc(apps, schema_editor):
journal = Journal.objects.get(name='SciPostPhysProc', doi_string='SciPostPhysProc') journal = Journal.objects.get(name='SciPostPhysProc', doi_string='SciPostPhysProc')
journal.active = False journal.active = False
journal.save() journal.save()
print('\n...SciPost Physics Proceedings deactivated.') print('\n - SciPost Physics Proceedings deactivated...')
except Journal.DoesNotExist: except Journal.DoesNotExist:
pass pass
......
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