From e53b7b8f4969a32d7554a8a47772e8a43441206a Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Fri, 19 May 2017 19:28:50 +0200 Subject: [PATCH] Minor PEP improvements --- partners/admin.py | 7 +------ partners/forms.py | 1 + partners/models.py | 2 -- partners/urls.py | 2 +- partners/views.py | 12 ++++++------ production/admin.py | 2 -- production/constants.py | 2 -- production/forms.py | 2 +- production/models.py | 2 +- production/views.py | 4 +--- 10 files changed, 12 insertions(+), 24 deletions(-) diff --git a/partners/admin.py b/partners/admin.py index 6295519fa..2b1ddd057 100644 --- a/partners/admin.py +++ b/partners/admin.py @@ -11,13 +11,8 @@ class PartnerAdmin(admin.ModelAdmin): search_fields = ['institution', 'institution_acronym', 'institution_address', 'contact_person'] -admin.site.register(Partner, PartnerAdmin) - +admin.site.register(Partner, PartnerAdmin) admin.site.register(Consortium) - - admin.site.register(ProspectivePartner) - - admin.site.register(MembershipAgreement) diff --git a/partners/forms.py b/partners/forms.py index f53c3844c..3aa5ed7fe 100644 --- a/partners/forms.py +++ b/partners/forms.py @@ -20,6 +20,7 @@ class PartnerForm(forms.ModelForm): super(PartnerForm, self).__init__(*args, **kwargs) self.fields['institution_address'].widget = forms.Textarea({'rows': 8, }) + class ProspectivePartnerForm(forms.ModelForm): class Meta: model = ProspectivePartner diff --git a/partners/models.py b/partners/models.py index 123b99d4c..82450ab99 100644 --- a/partners/models.py +++ b/partners/models.py @@ -8,7 +8,6 @@ from .constants import PARTNER_TYPES, PARTNER_STATUS, CONSORTIUM_STATUS,\ MEMBERSHIP_AGREEMENT_STATUS, MEMBERSHIP_DURATION from scipost.constants import TITLE_CHOICES -from scipost.models import Contributor class ContactPerson(models.Model): @@ -62,7 +61,6 @@ class Consortium(models.Model): verbose_name_plural = 'consortia' - class ProspectivePartner(models.Model): """ Created from the membership_request page, after submitting a query form. diff --git a/partners/urls.py b/partners/urls.py index 3c3dd7ebb..5558aaaed 100644 --- a/partners/urls.py +++ b/partners/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import include, url +from django.conf.urls import url from . import views diff --git a/partners/views.py b/partners/views.py index dd338e232..7473a5352 100644 --- a/partners/views.py +++ b/partners/views.py @@ -1,12 +1,12 @@ -from django.contrib.auth.decorators import login_required from django.contrib import messages from django.shortcuts import render, reverse, redirect from django.utils import timezone from guardian.decorators import permission_required -from .models import Partner, Consortium, ProspectivePartner, MembershipAgreement -from .forms import PartnerForm, ProspectivePartnerForm, MembershipQueryForm +from .models import Partner, ProspectivePartner, MembershipAgreement +from .forms import ProspectivePartnerForm, MembershipQueryForm + def supporting_partners(request): prospective_agreements = MembershipAgreement.objects.filter( @@ -34,7 +34,7 @@ def membership_request(request): 'with further details.') context = {'ack_message': ack_message, } return render(request, 'scipost/acknowledgement.html', context) - context = {'query_form': query_form,} + context = {'query_form': query_form} return render(request, 'partners/membership_request.html', context) @@ -57,8 +57,8 @@ def manage(request): def add_prospective_partner(request): form = ProspectivePartnerForm(request.POST or None) if form.is_valid(): - pros_partner = form.save() + form.save() messages.success(request, 'Prospective Partners successfully added') return redirect(reverse('partners:manage')) - context = {'form': form,} + context = {'form': form} return render(request, 'partners/add_prospective_partner.html', context) diff --git a/production/admin.py b/production/admin.py index b20b4a415..41ae12e06 100644 --- a/production/admin.py +++ b/production/admin.py @@ -4,6 +4,4 @@ from .models import ProductionStream, ProductionEvent admin.site.register(ProductionStream) - - admin.site.register(ProductionEvent) diff --git a/production/constants.py b/production/constants.py index 8a1ba8ea8..63d9f65fe 100644 --- a/production/constants.py +++ b/production/constants.py @@ -1,5 +1,3 @@ - - PRODUCTION_STREAM_STATUS = ( ('ongoing', 'Ongoing'), ('completed', 'Completed'), diff --git a/production/forms.py b/production/forms.py index d783973ec..9f47ebe67 100644 --- a/production/forms.py +++ b/production/forms.py @@ -8,6 +8,6 @@ class ProductionEventForm(forms.ModelForm): model = ProductionEvent exclude = ['stream', 'noted_on', 'noted_by'] widgets = { - 'comments': forms.Textarea(attrs={'rows': 4,}), + 'comments': forms.Textarea(attrs={'rows': 4}), 'duration': forms.TextInput(attrs={'placeholder': 'HH:MM:SS'}) } diff --git a/production/models.py b/production/models.py index 8badf3eea..c2cb30209 100644 --- a/production/models.py +++ b/production/models.py @@ -1,7 +1,7 @@ from django.db import models from django.utils import timezone -from .constants import PRODUCTION_STREAM_STATUS, PRODUCTION_EVENTS +from .constants import PRODUCTION_EVENTS from scipost.models import Contributor diff --git a/production/views.py b/production/views.py index 8103f5fdb..4093d7751 100644 --- a/production/views.py +++ b/production/views.py @@ -9,7 +9,6 @@ from .models import ProductionStream, ProductionEvent from .forms import ProductionEventForm from submissions.models import Submission -from scipost.models import Contributor ###################### @@ -33,6 +32,7 @@ def production(request): } return render(request, 'production/production.html', context) + @permission_required('scipost.can_view_production', return_403=True) @transaction.atomic def add_event(request, stream_id): @@ -57,8 +57,6 @@ def add_event(request, stream_id): return render(request, 'scipost/error.html', {'errormessage': errormessage}) - - def upload_proofs(request): """ TODO -- GitLab