From d5120d5c799fafdbecb6ffb217793b8746e2a1b1 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Tue, 7 Nov 2017 14:00:33 +0100 Subject: [PATCH] Rename institute->institution --- affiliations/constants.py | 2 +- affiliations/forms.py | 41 ++++++++++--------- affiliations/migrations/0001_initial.py | 2 +- .../migrations/0002_affiliation_acronym.py | 2 +- .../migrations/0003_auto_20171101_2022.py | 8 ++-- .../migrations/0004_auto_20171101_2208.py | 2 +- affiliations/migrations/0005_affiliation.py | 2 +- .../migrations/0008_auto_20171107_1337.py | 19 --------- .../migrations/0008_auto_20171107_1354.py | 24 +++++++++++ affiliations/models.py | 20 ++++----- affiliations/signals.py | 2 +- .../affiliations/institute_form.html | 24 +++++------ .../affiliations/institute_list.html | 12 +++--- affiliations/urls.py | 10 ++--- affiliations/views.py | 24 +++++------ .../migrations/0050_publication_institutes.py | 2 +- .../migrations/0052_auto_20171107_1354.py | 20 +++++++++ journals/models.py | 4 +- .../journals/publication_detail.html | 6 +-- journals/views.py | 6 +-- scipost/forms.py | 4 +- .../0066_contributor__affiliation.py | 2 +- scipost/migrations/0067_auto_20171101_2132.py | 2 +- scipost/models.py | 2 - .../scipost/_private_info_as_table.html | 2 +- .../scipost/_public_info_as_table.html | 2 +- scipost/templates/scipost/personal_page.html | 2 +- .../scipost/update_personal_data.html | 18 ++++---- scipost/views.py | 8 ++-- 29 files changed, 149 insertions(+), 125 deletions(-) delete mode 100644 affiliations/migrations/0008_auto_20171107_1337.py create mode 100644 affiliations/migrations/0008_auto_20171107_1354.py create mode 100644 journals/migrations/0052_auto_20171107_1354.py diff --git a/affiliations/constants.py b/affiliations/constants.py index d1da522fd..579a66e75 100644 --- a/affiliations/constants.py +++ b/affiliations/constants.py @@ -1,4 +1,4 @@ TYPE_UNIVERSITY = 'university' -INSTITUTE_TYPES = ( +INSTITUTION_TYPES = ( (TYPE_UNIVERSITY, 'University'), ) diff --git a/affiliations/forms.py b/affiliations/forms.py index 648c13826..088fb0125 100644 --- a/affiliations/forms.py +++ b/affiliations/forms.py @@ -35,40 +35,40 @@ class AffiliationForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.contributor = kwargs.pop('contributor') affiliation = kwargs.get('instance') - if hasattr(affiliation, 'institute'): - institute = affiliation.institute + if hasattr(affiliation, 'institution'): + institution = affiliation.institution kwargs['initial'] = { - 'name': institute.name, - 'country': institute.country + 'name': institution.name, + 'country': institution.country } super().__init__(*args, **kwargs) def save(self, commit=True): """ - Save the Affiliation and Institute if neccessary. + Save the Affiliation and Institution if neccessary. """ affiliation = super().save(commit=False) affiliation.contributor = self.contributor if commit: - if hasattr(affiliation, 'institute') and affiliation.institute.affiliations.count() == 1: - # Just update if there are no other people using this Institute - institute = affiliation.institute - institute.name = self.cleaned_data['name'] - institute.country = self.cleaned_data['country'] - institute.save() + if hasattr(affiliation, 'institution') and affiliation.institution.affiliations.count() == 1: + # Just update if there are no other people using this Institution + institution = affiliation.institution + institution.name = self.cleaned_data['name'] + institution.country = self.cleaned_data['country'] + institution.save() else: - institute, __ = Institution.objects.get_or_create( + institution, __ = Institution.objects.get_or_create( name=self.cleaned_data['name'], country=self.cleaned_data['country']) - affiliation.institute = institute + affiliation.institution = institution affiliation.save() return affiliation class AffiliationsFormSet(BaseModelFormSet): """ - This formset helps update the Institutes for the Contributor at specific time periods. + This formset helps update the Institutions for the Contributor at specific time periods. """ def __init__(self, *args, **kwargs): self.contributor = kwargs.pop('contributor') @@ -96,8 +96,8 @@ AffiliationsFormset = modelformset_factory(Affiliation, form=AffiliationForm, ca formset=AffiliationsFormSet, extra=0) -class InstituteMergeForm(forms.ModelForm): - institute = forms.ModelChoiceField(queryset=Institution.objects.none()) +class InstitutionMergeForm(forms.ModelForm): + institution = forms.ModelChoiceField(queryset=Institution.objects.none()) class Meta: model = Institution @@ -105,11 +105,12 @@ class InstituteMergeForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields['institute'].queryset = Institution.objects.exclude(id=self.instance.id) + self.fields['institution'].queryset = Institution.objects.exclude(id=self.instance.id) def save(self, commit=True): - old_institute = self.cleaned_data['institute'] + old_institution = self.cleaned_data['institution'] if commit: - Affiliation.objects.filter(institute=old_institute).update(institute=self.instance) - old_institute.delete() + Affiliation.objects.filter( + institution=old_institution).update(institution=self.instance) + old_institution.delete() return self.instance diff --git a/affiliations/migrations/0001_initial.py b/affiliations/migrations/0001_initial.py index c6f23fbf3..88b931b8d 100644 --- a/affiliations/migrations/0001_initial.py +++ b/affiliations/migrations/0001_initial.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Institute', + name='Institution', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255)), diff --git a/affiliations/migrations/0002_affiliation_acronym.py b/affiliations/migrations/0002_affiliation_acronym.py index 01d4fb277..496c9a430 100644 --- a/affiliations/migrations/0002_affiliation_acronym.py +++ b/affiliations/migrations/0002_affiliation_acronym.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( - model_name='institute', + model_name='institution', name='acronym', field=models.CharField(blank=True, max_length=16), ), diff --git a/affiliations/migrations/0003_auto_20171101_2022.py b/affiliations/migrations/0003_auto_20171101_2022.py index 65eda86a2..412b9733f 100644 --- a/affiliations/migrations/0003_auto_20171101_2022.py +++ b/affiliations/migrations/0003_auto_20171101_2022.py @@ -5,11 +5,11 @@ from __future__ import unicode_literals from django.db import migrations -def fill_institutes(apps, schema_editor): +def fill_institutions(apps, schema_editor): Contributor = apps.get_model('scipost', 'Contributor') - Institute = apps.get_model('affiliations', 'Institute') + Institution = apps.get_model('affiliations', 'Institution') for contributor in Contributor.objects.all(): - affiliation, __ = Institute.objects.get_or_create( + affiliation, __ = Institution.objects.get_or_create( name=contributor.affiliation, country=contributor.country_of_employment) contributor._affiliation = affiliation contributor.save() @@ -27,5 +27,5 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(fill_institutes, return_none), + migrations.RunPython(fill_institutions, return_none), ] diff --git a/affiliations/migrations/0004_auto_20171101_2208.py b/affiliations/migrations/0004_auto_20171101_2208.py index be2b86fd2..53343a60c 100644 --- a/affiliations/migrations/0004_auto_20171101_2208.py +++ b/affiliations/migrations/0004_auto_20171101_2208.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterModelOptions( - name='institute', + name='institution', options={'ordering': ['country']}, ), ] diff --git a/affiliations/migrations/0005_affiliation.py b/affiliations/migrations/0005_affiliation.py index 7d4a84394..9396c865d 100644 --- a/affiliations/migrations/0005_affiliation.py +++ b/affiliations/migrations/0005_affiliation.py @@ -21,7 +21,7 @@ class Migration(migrations.Migration): ('begin_date', models.DateField(blank=True, null=True)), ('end_date', models.DateField(blank=True, null=True)), ('contributor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='affiliations', to='scipost.Contributor')), - ('institute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='affiliations', to='affiliations.Institute')), + ('institute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='affiliations', to='affiliations.Institution')), ], options={ 'default_related_name': 'affiliations', diff --git a/affiliations/migrations/0008_auto_20171107_1337.py b/affiliations/migrations/0008_auto_20171107_1337.py deleted file mode 100644 index 8f10974f9..000000000 --- a/affiliations/migrations/0008_auto_20171107_1337.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.4 on 2017-11-07 12:37 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('affiliations', '0007_auto_20171102_1256'), - ] - - operations = [ - migrations.RenameModel( - old_name='Institute', - new_name='Institution', - ), - ] diff --git a/affiliations/migrations/0008_auto_20171107_1354.py b/affiliations/migrations/0008_auto_20171107_1354.py new file mode 100644 index 000000000..9ed49e1c5 --- /dev/null +++ b/affiliations/migrations/0008_auto_20171107_1354.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-11-07 12:54 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('affiliations', '0007_auto_20171102_1256'), + ] + + operations = [ + migrations.AlterModelOptions( + name='affiliation', + options={'ordering': ['begin_date', 'end_date', 'institution']}, + ), + migrations.RenameField( + model_name='affiliation', + old_name='institute', + new_name='institution', + ), + ] diff --git a/affiliations/models.py b/affiliations/models.py index be224dc0d..3806e939d 100644 --- a/affiliations/models.py +++ b/affiliations/models.py @@ -3,36 +3,36 @@ from django.urls import reverse from django_countries.fields import CountryField -from .constants import INSTITUTE_TYPES, TYPE_UNIVERSITY +from .constants import INSTITUTION_TYPES, TYPE_UNIVERSITY from .managers import AffiliationQuerySet class Institution(models.Model): """ - Any (scientific) Institute in the world should ideally have a SciPost registration. + Any (scientific) Institution in the world should ideally have a SciPost registration. """ name = models.CharField(max_length=255) acronym = models.CharField(max_length=16, blank=True) country = CountryField() - type = models.CharField(max_length=16, choices=INSTITUTE_TYPES, default=TYPE_UNIVERSITY) + type = models.CharField(max_length=16, choices=INSTITUTION_TYPES, default=TYPE_UNIVERSITY) class Meta: - default_related_name = 'institutes' + default_related_name = 'institutions' ordering = ['country'] def __str__(self): return '{name} ({country})'.format(name=self.name, country=self.get_country_display()) def get_absolute_url(self): - return reverse('affiliations:institute_details', args=(self.id,)) + return reverse('affiliations:institution_details', args=(self.id,)) class Affiliation(models.Model): """ - An Affiliation is a (time dependent) connection between an Institute and a Contributor. + An Affiliation is a (time dependent) connection between an Institution and a Contributor. This could thus be changed over time and history will be preserved. """ - institute = models.ForeignKey('affiliations.Institution') + institution = models.ForeignKey('affiliations.Institution') contributor = models.ForeignKey('scipost.Contributor') begin_date = models.DateField(null=True, blank=True) end_date = models.DateField(null=True, blank=True) @@ -41,8 +41,8 @@ class Affiliation(models.Model): class Meta: default_related_name = 'affiliations' - ordering = ['begin_date', 'end_date', 'institute'] + ordering = ['begin_date', 'end_date', 'institution'] def __str__(self): - return '{contributor} ({institute})'.format( - contributor=self.contributor, institute=self.institute.name) + return '{contributor} ({institution})'.format( + contributor=self.contributor, institution=self.institution.name) diff --git a/affiliations/signals.py b/affiliations/signals.py index 2d583e8df..8a75e16f0 100644 --- a/affiliations/signals.py +++ b/affiliations/signals.py @@ -13,5 +13,5 @@ def notify_new_affiliation(sender, instance, created, **kwargs): actor, __ = FakeActors.objects.get_or_create(name='A SciPost user') for user in administrators: notify.send(sender=sender, recipient=user, actor=actor, - verb=' created a new Institute instance. You may want to validate it.', + verb=' created a new Institution instance. You may want to validate it.', target=instance) diff --git a/affiliations/templates/affiliations/institute_form.html b/affiliations/templates/affiliations/institute_form.html index 57d68b57f..75463ad95 100644 --- a/affiliations/templates/affiliations/institute_form.html +++ b/affiliations/templates/affiliations/institute_form.html @@ -2,52 +2,52 @@ {% load bootstrap %} -{% block pagetitle %}: Institutes details{% endblock pagetitle %} +{% block pagetitle %}: Institution details{% endblock pagetitle %} {% block breadcrumb_items %} {{ block.super }} - <a href="{% url 'affiliations:institutes' %}" class="breadcrumb-item">Institutes</a> - <span class="breadcrumb-item">Institute detail</span> + <a href="{% url 'affiliations:institutions' %}" class="breadcrumb-item">Institutions</a> + <span class="breadcrumb-item">Institution detail</span> {% endblock %} {% block content %} -<h1>Institute {{ institute }}</h1> +<h1>Institution {{ institution }}</h1> <form method="post"> {% csrf_token %} {{ form|bootstrap }} - <input class="btn btn-primary" type="submit" value="Update Institute"> + <input class="btn btn-primary" type="submit" value="Update Institution"> </form> <br> -<a href="javascript:;" data-toggle="toggle" data-target="#merging">Merge another institute into {{ institute }}?</a> +<a href="javascript:;" data-toggle="toggle" data-target="#merging">Merge another institution into {{ institution }}?</a> <div id="merging" style="display: none;"> - <h3>Merge institutes</h3> + <h3>Merge institutions</h3> <div class="card border-danger"> <div class="card-body d-flex flex-row"> <div class="p-2"> <i class="fa fa-2x fa-exclamation-triangle text-warning" aria-hidden="true"></i> </div> <div class="px-2"> - You better be sure what you are doing, this is a one-way street. This will merge the chosen institute into {{ institute }}. The fields of the chosen institute <strong>will be lost</strong> however. + You better be sure what you are doing, this is a one-way street. This will merge the chosen institution into {{ institution }}. The fields of the chosen institution <strong>will be lost</strong> however. </div> </div> </div> <br> - <form action="{% url 'affiliations:merge_institutes' institute.id %}" method="post"> + <form action="{% url 'affiliations:merge_institutions' institution.id %}" method="post"> {% csrf_token %} {{ merge_form|bootstrap }} - <input class="btn btn-primary" type="submit" value="Merge institutes" onclick="return confirm('Are you sure this is what you want?')"> + <input class="btn btn-primary" type="submit" value="Merge institutions" onclick="return confirm('Are you sure this is what you want?')"> </form> </div> <br> <br> -<h3>Contributors of {{ institute }}</h3> +<h3>Contributors of {{ institution }}</h3> <ul> - {% for contributor in institute.contributors.all %} + {% for contributor in institution.contributors.all %} <li>{{ contributor }}</li> {% endfor %} </ul> diff --git a/affiliations/templates/affiliations/institute_list.html b/affiliations/templates/affiliations/institute_list.html index c40b5a8c9..50d0b8ea3 100644 --- a/affiliations/templates/affiliations/institute_list.html +++ b/affiliations/templates/affiliations/institute_list.html @@ -1,25 +1,25 @@ {% extends 'scipost/_personal_page_base.html' %} -{% block pagetitle %}: Institutes{% endblock pagetitle %} +{% block pagetitle %}: Institutions{% endblock pagetitle %} {% block breadcrumb_items %} {{ block.super }} - <span class="breadcrumb-item">Institutes</span> + <span class="breadcrumb-item">Institutions</span> {% endblock %} {% block content %} -<h1>All Institutes in the database</h1> +<h1>All Institutions in the database</h1> {% if is_paginated %} {% include 'partials/pagination.html' with page_obj=page_obj %} {% endif %} <ul> - {% for institute in object_list %} - <li><a href="{% url 'affiliations:institute_details' institute.id %}">{{ institute }}</a></li> + {% for institution in object_list %} + <li><a href="{% url 'affiliations:institution_details' institution.id %}">{{ institution }}</a></li> {% empty %} - <li><em>There are no Institutes known yet.</em><li> + <li><em>There are no Institutions known yet.</em><li> {% endfor %} </ul> {% if is_paginated %} diff --git a/affiliations/urls.py b/affiliations/urls.py index 6cc8b42ba..ab379c2c1 100644 --- a/affiliations/urls.py +++ b/affiliations/urls.py @@ -3,9 +3,9 @@ from django.conf.urls import url from . import views urlpatterns = [ - url(r'^$', views.InstituteListView.as_view(), name='institutes'), - url(r'^(?P<institute_id>[0-9]+)/$', views.InstituteUpdateView.as_view(), - name='institute_details'), - url(r'^(?P<institute_id>[0-9]+)/merge$', views.merge_institutes, - name='merge_institutes'), + url(r'^$', views.InstitutionListView.as_view(), name='institutions'), + url(r'^(?P<institution_id>[0-9]+)/$', views.InstitutionUpdateView.as_view(), + name='institution_details'), + url(r'^(?P<institution_id>[0-9]+)/merge$', views.merge_institutions, + name='merge_institutions'), ] diff --git a/affiliations/views.py b/affiliations/views.py index 8963d139e..3acbc40fa 100644 --- a/affiliations/views.py +++ b/affiliations/views.py @@ -7,20 +7,20 @@ from django.views.generic.edit import UpdateView from django.views.generic.list import ListView from django.shortcuts import get_object_or_404 -from .forms import InstituteMergeForm +from .forms import InstitutionMergeForm from .models import Institution @method_decorator(permission_required('scipost.can_manage_affiliations'), name='dispatch') -class InstituteListView(ListView): +class InstitutionListView(ListView): model = Institution paginate_by = 100 @method_decorator(permission_required('scipost.can_manage_affiliations'), name='dispatch') -class InstituteUpdateView(UpdateView): +class InstitutionUpdateView(UpdateView): model = Institution - pk_url_kwarg = 'institute_id' + pk_url_kwarg = 'institution_id' fields = [ 'name', 'acronym', @@ -29,24 +29,24 @@ class InstituteUpdateView(UpdateView): def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) - context['merge_form'] = InstituteMergeForm() + context['merge_form'] = InstitutionMergeForm() return context def form_valid(self, *args, **kwargs): - messages.success(self.request, 'Institute saved') + messages.success(self.request, 'Institution saved') return super().form_valid(*args, **kwargs) @permission_required('scipost.can_manage_affiliations') -def merge_institutes(request, institute_id): +def merge_institutions(request, institution_id): """ Merge Affiliation (affiliation_id) into the Affliation chosen in the form. """ - institute = get_object_or_404(Institution, id=institute_id) - form = InstituteMergeForm(request.POST or None, instance=institute) + institution = get_object_or_404(Institution, id=institution_id) + form = InstitutionMergeForm(request.POST or None, instance=institution) if form.is_valid(): form.save() - messages.success(request, 'Institute {a} merged into {b}'.format( - a=form.cleaned_data.get('institute', '?'), b=institute)) + messages.success(request, 'Institution {a} merged into {b}'.format( + a=form.cleaned_data.get('institution', '?'), b=institution)) - return redirect(reverse('affiliations:institute_details', args=(institute.id,))) + return redirect(reverse('affiliations:institution_details', args=(institution.id,))) diff --git a/journals/migrations/0050_publication_institutes.py b/journals/migrations/0050_publication_institutes.py index 71f4c2adf..75fe84102 100644 --- a/journals/migrations/0050_publication_institutes.py +++ b/journals/migrations/0050_publication_institutes.py @@ -16,6 +16,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='publication', name='institutes', - field=models.ManyToManyField(blank=True, related_name='publications', to='affiliations.Institute'), + field=models.ManyToManyField(blank=True, related_name='publications', to='affiliations.Institution'), ), ] diff --git a/journals/migrations/0052_auto_20171107_1354.py b/journals/migrations/0052_auto_20171107_1354.py new file mode 100644 index 000000000..d0dc80f5c --- /dev/null +++ b/journals/migrations/0052_auto_20171107_1354.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-11-07 12:54 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0051_auto_20171102_1307'), + ] + + operations = [ + migrations.RenameField( + model_name='publication', + old_name='institutes', + new_name='institutions', + ), + ] diff --git a/journals/models.py b/journals/models.py index 7cde56d97..d1ea12b9d 100644 --- a/journals/models.py +++ b/journals/models.py @@ -166,8 +166,8 @@ class Publication(models.Model): grants = models.ManyToManyField('funders.Grant', blank=True, related_name="publications") funders_generic = models.ManyToManyField( 'funders.Funder', blank=True, related_name="publications") # not linked to a grant - institutes = models.ManyToManyField('affiliations.Institution', - blank=True, related_name="publications") + institutions = models.ManyToManyField('affiliations.Institution', + blank=True, related_name="publications") # Metadata metadata = JSONField(default={}, blank=True, null=True) diff --git a/journals/templates/journals/publication_detail.html b/journals/templates/journals/publication_detail.html index 64a0039f8..b86f7d429 100644 --- a/journals/templates/journals/publication_detail.html +++ b/journals/templates/journals/publication_detail.html @@ -90,10 +90,10 @@ {% if is_edcol_admin %} {# This function is not available for public yet! #} - <h3>Institutes related to this Publication: <small>(adminstrator only)</small></h3> + <h3>Institutions related to this Publication: <small>(adminstrator only)</small></h3> <ul> - {% for institute in publication.institutes.all %} - <li>{{ institute }}</li> + {% for institution in publication.institutions.all %} + <li>{{ institution }}</li> {% endfor %} </ul> {% endif %} diff --git a/journals/views.py b/journals/views.py index bbd2b074b..8f7b60053 100644 --- a/journals/views.py +++ b/journals/views.py @@ -254,10 +254,10 @@ def validate_publication(request): publication.authors_claims.add(*submission.authors_claims.all()) publication.authors_false_claims.add(*submission.authors_false_claims.all()) - # Add Institutes to the publication + # Add Institutions to the publication for author in publication.authors.all(): - for institute in author.affiliations.active(): - publication.institutes.add(institute) + for institution in author.affiliations.active(): + publication.institutions.add(institution) # Save the beast publication.save() diff --git a/scipost/forms.py b/scipost/forms.py index cf13b6553..27a14be3c 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -116,7 +116,7 @@ class RegistrationForm(forms.Form): 'password': self.cleaned_data['password'], 'is_active': False }) - institute, __ = Institution.objects.get_or_create( + institution, __ = Institution.objects.get_or_create( country=self.cleaned_data['country_of_employment'], name=self.cleaned_data['affiliation'], ) @@ -130,7 +130,7 @@ class RegistrationForm(forms.Form): }) affiliation, __ = Affiliation.objects.get_or_create( contributor=contributor, - institute=institute, + institution=institution, ) if contributor.activation_key == '': diff --git a/scipost/migrations/0066_contributor__affiliation.py b/scipost/migrations/0066_contributor__affiliation.py index 345021dd9..734116ef9 100644 --- a/scipost/migrations/0066_contributor__affiliation.py +++ b/scipost/migrations/0066_contributor__affiliation.py @@ -17,6 +17,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='contributor', name='_affiliation', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='affiliations.Institute'), + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='affiliations.Institution'), ), ] diff --git a/scipost/migrations/0067_auto_20171101_2132.py b/scipost/migrations/0067_auto_20171101_2132.py index 43e5ed004..ef5d86831 100644 --- a/scipost/migrations/0067_auto_20171101_2132.py +++ b/scipost/migrations/0067_auto_20171101_2132.py @@ -26,6 +26,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='contributor', name='_affiliation', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='contributors', to='affiliations.Institute'), + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='contributors', to='affiliations.Institution'), ), ] diff --git a/scipost/models.py b/scipost/models.py index 4cd14cef3..cd56f991d 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -9,8 +9,6 @@ from django.contrib.postgres.fields import ArrayField from django.db import models from django.utils import timezone -from django_countries.fields import CountryField - from .behaviors import TimeStampedModel from .constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS,\ subject_areas_dict, CONTRIBUTOR_STATUS, TITLE_CHOICES,\ diff --git a/scipost/templates/scipost/_private_info_as_table.html b/scipost/templates/scipost/_private_info_as_table.html index 9eb68274e..5e2450b5f 100644 --- a/scipost/templates/scipost/_private_info_as_table.html +++ b/scipost/templates/scipost/_private_info_as_table.html @@ -11,7 +11,7 @@ {% if not forloop.first %} <br> {% endif %} - {{ affiliation.institute }} + {{ affiliation.institution }} {% endfor %} </td> </tr> diff --git a/scipost/templates/scipost/_public_info_as_table.html b/scipost/templates/scipost/_public_info_as_table.html index 6e80fb2c5..1f0f93e93 100644 --- a/scipost/templates/scipost/_public_info_as_table.html +++ b/scipost/templates/scipost/_public_info_as_table.html @@ -10,7 +10,7 @@ {% if not forloop.first %} <br> {% endif %} - {{ affiliation.institute }} + {{ affiliation.institution }} {% endfor %} </td> </tr> diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 90218f977..8339a12e3 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -317,7 +317,7 @@ <h3>SciPost Administation</h3> <ul> - <li><a href="{% url 'affiliations:institutes' %}">Manage Institutes database</a></li> + <li><a href="{% url 'affiliations:institutions' %}">Manage Institutions database</a></li> </ul> {% endif %} diff --git a/scipost/templates/scipost/update_personal_data.html b/scipost/templates/scipost/update_personal_data.html index 42c0a5b38..d4a41b479 100644 --- a/scipost/templates/scipost/update_personal_data.html +++ b/scipost/templates/scipost/update_personal_data.html @@ -55,15 +55,15 @@ {{ cont_form|bootstrap }} {% endif %} </div> - {% if institute_formset %} + {% if institution_formset %} <div class="col-lg-6"> - <div id="institutes" class="formset-group"> - <h1 class="mb-3">Your Institutes</h1> - {{ institute_formset.media }} - {{ institute_formset|bootstrap }} + <div id="institutions" class="formset-group"> + <h1 class="mb-3">Your Institutions</h1> + {{ institution_formset.media }} + {{ institution_formset|bootstrap }} </div> <div class="formset-form form-empty" style="display: none;"> - {{ institute_formset.empty_form|bootstrap }} + {{ institution_formset.empty_form|bootstrap }} </div> </div> {% endif %} @@ -76,9 +76,9 @@ <script type="text/javascript"> $(function() { - $('form #institutes > .formset-form').formset({ - addText: 'add new Institute', - deleteText: 'remove Institute', + $('form #institutions > .formset-form').formset({ + addText: 'add new Institution', + deleteText: 'remove Institution', formTemplate: 'form .form-empty', }) }) diff --git a/scipost/views.py b/scipost/views.py index e122018ec..3269094ef 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -892,12 +892,12 @@ def _update_personal_data_contributor(request): contributor = Contributor.objects.get(user=request.user) user_form = UpdateUserDataForm(request.POST or None, instance=request.user) cont_form = UpdatePersonalDataForm(request.POST or None, instance=contributor) - institute_formset = AffiliationsFormset(request.POST or None, contributor=contributor) - if user_form.is_valid() and cont_form.is_valid() and institute_formset.is_valid(): + institution_formset = AffiliationsFormset(request.POST or None, contributor=contributor) + if user_form.is_valid() and cont_form.is_valid() and institution_formset.is_valid(): user_form.save() cont_form.save() cont_form.sync_lists() - institute_formset.save() + institution_formset.save() if 'orcid_id' in cont_form.changed_data: cont_form.propagate_orcid() messages.success(request, 'Your personal data has been updated.') @@ -909,7 +909,7 @@ def _update_personal_data_contributor(request): context = { 'user_form': user_form, 'cont_form': cont_form, - 'institute_formset': institute_formset, + 'institution_formset': institution_formset, } return render(request, 'scipost/update_personal_data.html', context) -- GitLab