From a245d1064e9e0b16308fafefd738dd3e236f39d9 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Tue, 27 Aug 2019 20:41:11 +0200 Subject: [PATCH] Remove deprecated EditorialCollege and EditorialCollegeFellowship --- scipost/admin.py | 37 +------------- scipost/factories.py | 19 +------- scipost/migrations/0028_auto_20190827_2023.py | 31 ++++++++++++ scipost/models.py | 48 ------------------- scipost/test_views.py | 29 +---------- 5 files changed, 34 insertions(+), 130 deletions(-) create mode 100644 scipost/migrations/0028_auto_20190827_2023.py diff --git a/scipost/admin.py b/scipost/admin.py index 95dcfdec2..08d72dba4 100644 --- a/scipost/admin.py +++ b/scipost/admin.py @@ -10,7 +10,7 @@ from django.contrib.auth.models import User, Permission from scipost.models import TOTPDevice, Contributor, Remark,\ AuthorshipClaim, PrecookedEmail,\ - EditorialCollege, EditorialCollegeFellowship, UnavailabilityPeriod + UnavailabilityPeriod from organizations.admin import ContactInline from production.admin import ProductionUserInline @@ -150,38 +150,3 @@ class PrecookedEmailAdmin(admin.ModelAdmin): admin.site.register(PrecookedEmail, PrecookedEmailAdmin) - - -class EditorialCollegeAdmin(admin.ModelAdmin): - search_fields = ['discipline', 'member'] - - -admin.site.register(EditorialCollege, EditorialCollegeAdmin) - - -def college_fellow_is_active(fellow): - '''Check if fellow is currently active.''' - return fellow.is_active() - - -class EditorialCollegeFellowshipAdminForm(forms.ModelForm): - contributor = forms.ModelChoiceField( - queryset=Contributor.objects.order_by('user__last_name')) - - class Meta: - model = EditorialCollegeFellowship - fields = '__all__' - - -class EditorialCollegeFellowshipAdmin(admin.ModelAdmin): - list_display = ('__str__', 'college', college_fellow_is_active) - list_filter = ('college', 'affiliation') - search_fields = ['college__discipline', - 'contributor__user__first_name', 'contributor__user__last_name'] - fields = ('contributor', 'college', 'start_date', 'until_date', 'affiliation', ) - - college_fellow_is_active.boolean = True - form = EditorialCollegeFellowshipAdminForm - - -admin.site.register(EditorialCollegeFellowship, EditorialCollegeFellowshipAdmin) diff --git a/scipost/factories.py b/scipost/factories.py index 4d86a30ba..6f3128d64 100644 --- a/scipost/factories.py +++ b/scipost/factories.py @@ -11,7 +11,7 @@ from django.contrib.auth.models import Group from common.helpers import generate_orcid from submissions.models import Submission -from .models import Contributor, EditorialCollege, EditorialCollegeFellowship, Remark, TOTPDevice +from .models import Contributor, Remark, TOTPDevice from .constants import TITLE_CHOICES, SCIPOST_SUBJECT_AREAS, NORMAL_CONTRIBUTOR @@ -89,23 +89,6 @@ class TOTPDeviceFactory(factory.django.DjangoModelFactory): model = TOTPDevice -class EditorialCollegeFactory(factory.django.DjangoModelFactory): - discipline = random.choice(['Physics', 'Chemistry', 'Medicine']) - - class Meta: - model = EditorialCollege - django_get_or_create = ('discipline',) - - -class EditorialCollegeFellowshipFactory(factory.django.DjangoModelFactory): - college = factory.Iterator(EditorialCollege.objects.all()) - contributor = factory.Iterator(Contributor.objects.exclude( - user__username='deleted').order_by('?')) - - class Meta: - model = EditorialCollegeFellowship - - class SubmissionRemarkFactory(factory.django.DjangoModelFactory): contributor = factory.Iterator(Contributor.objects.all()) submission = factory.Iterator(Submission.objects.all()) diff --git a/scipost/migrations/0028_auto_20190827_2023.py b/scipost/migrations/0028_auto_20190827_2023.py new file mode 100644 index 000000000..dedaef2ce --- /dev/null +++ b/scipost/migrations/0028_auto_20190827_2023.py @@ -0,0 +1,31 @@ +# Generated by Django 2.1.8 on 2019-08-27 18:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('scipost', '0027_auto_20190826_0924'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='editorialcollegefellowship', + unique_together=set(), + ), + migrations.RemoveField( + model_name='editorialcollegefellowship', + name='college', + ), + migrations.RemoveField( + model_name='editorialcollegefellowship', + name='contributor', + ), + migrations.DeleteModel( + name='EditorialCollege', + ), + migrations.DeleteModel( + name='EditorialCollegeFellowship', + ), + ] diff --git a/scipost/models.py b/scipost/models.py index ee3de6178..57fed958d 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -329,51 +329,3 @@ class PrecookedEmail(models.Model): def __str__(self): return self.email_subject - - -###################### -# Static info models # -###################### - -class EditorialCollege(models.Model): - """A SciPost Editorial College for a specific discipline. - - DEPRECATED. To be removed. - """ - discipline = models.CharField(max_length=255, unique=True) - - def __str__(self): - return self.discipline - - -class EditorialCollegeFellowship(TimeStampedModel): - """ - Editorial College Fellowship connecting Editorial College and Contributors, - maybe with a limiting start/until date. - - DEPRECATED. To be removed. - """ - contributor = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE, - related_name='+') - college = models.ForeignKey('scipost.EditorialCollege', on_delete=models.CASCADE, - related_name='fellowships') - affiliation = models.CharField(max_length=255, blank=True) - start_date = models.DateField(null=True, blank=True) - until_date = models.DateField(null=True, blank=True) - - objects = FellowManager() - - class Meta: - unique_together = ('contributor', 'college', 'start_date', 'until_date') - - def __str__(self): - return self.contributor.__str__() - - def is_active(self): - if not self.start_date: - if not self.until_date: - return True - return today <= self.until_date - elif not self.until_date: - return today >= self.start_date - return today >= self.start_date and today <= self.until_date diff --git a/scipost/test_views.py b/scipost/test_views.py index 15ece1cf0..69fae6f60 100644 --- a/scipost/test_views.py +++ b/scipost/test_views.py @@ -11,9 +11,7 @@ from commentaries.factories import UnvettedCommentaryFactory, CommentaryFactory, from commentaries.forms import CommentarySearchForm from commentaries.models import Commentary -from .factories import ContributorFactory,\ - EditorialCollegeFellowshipFactory, EditorialCollegeFactory -from .models import EditorialCollege, EditorialCollegeFellowship +from .factories import ContributorFactory class RequestCommentaryTest(TestCase): @@ -131,28 +129,3 @@ class CommentaryDetailTest(TestCase): def test_status_code_200(self): response = self.client.get(self.target) self.assertEqual(response.status_code, 200) - - -@tag('static-info', 'full') -class AboutViewTest(TestCase): - def setUp(self): - self.client = Client() - self.target = reverse('scipost:about') - - # Create College with 10 members - self.college = EditorialCollegeFactory() - EditorialCollegeFellowshipFactory.create_batch(10) - - def test_status_code_200_including_members(self): - response = self.client.get(self.target) - self.assertEqual(response.status_code, 200) - - # College exists in context - self.assertTrue('object_list' in response.context) - college = response.context['object_list'][0] - self.assertTrue(isinstance(college, EditorialCollege)) - - # Members exist in college - self.assertTrue(college.member.count() >= 10) - last_member = college.member.last() - self.assertTrue(isinstance(last_member, EditorialCollegeFellowship)) -- GitLab