From c8f6f2ac20c152df1cc82817b74188d2c3a35399 Mon Sep 17 00:00:00 2001 From: Geert Kapteijns <ghkapteijns@gmail.com> Date: Tue, 13 Dec 2016 21:28:39 +0100 Subject: [PATCH] Make parts of forms.py, urls.py, views.py PEP compliant --- theses/forms.py | 2 ++ theses/urls.py | 7 ++++--- theses/views.py | 38 ++++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/theses/forms.py b/theses/forms.py index 95849d3b3..9186071a2 100644 --- a/theses/forms.py +++ b/theses/forms.py @@ -14,6 +14,7 @@ THESIS_REFUSAL_CHOICES = ( (-2, 'the external link to this thesis does not work'), ) + class RequestThesisLinkForm(forms.ModelForm): class Meta: model = ThesisLink @@ -35,6 +36,7 @@ class VetThesisLinkForm(forms.Form): email_response_field = forms.CharField(widget=forms.Textarea( attrs={'rows': 5, 'cols': 40}), label='Justification (optional)', required=False) + class ThesisLinkSearchForm(forms.Form): author = forms.CharField(max_length=100, required=False, label="Author") title_keyword = forms.CharField(max_length=100, label="Title", required=False) diff --git a/theses/urls.py b/theses/urls.py index 59758c05e..88bd43454 100644 --- a/theses/urls.py +++ b/theses/urls.py @@ -7,9 +7,10 @@ urlpatterns = [ # Thesis Links url(r'^$', views.theses, name='theses'), url(r'^browse/(?P<discipline>[a-z]+)/(?P<nrweeksback>[0-9]+)/$', views.browse, name='browse'), - #url(r'^thesis/(?P<thesislink_id>[0-9]+)/$', views.thesis_detail, name='thesis'), url(r'^(?P<thesislink_id>[0-9]+)/$', views.thesis_detail, name='thesis'), url(r'^request_thesislink$', views.request_thesislink, name='request_thesislink'), - url(r'^vet_thesislink_requests$', views.vet_thesislink_requests, name='vet_thesislink_requests'), - url(r'^vet_thesislink_request_ack/(?P<thesislink_id>[0-9]+)$', views.vet_thesislink_request_ack, name='vet_thesislink_request_ack'), + url(r'^vet_thesislink_requests$', views.vet_thesislink_requests, + name='vet_thesislink_requests'), + url(r'^vet_thesislink_request_ack/(?P<thesislink_id>[0-9]+)$', + views.vet_thesislink_request_ack, name='vet_thesislink_request_ack'), ] diff --git a/theses/views.py b/theses/views.py index 882c2f192..1c634d90b 100644 --- a/theses/views.py +++ b/theses/views.py @@ -17,7 +17,8 @@ from comments.models import Comment from comments.forms import CommentForm from scipost.forms import TITLE_CHOICES, AuthenticationForm -title_dict = dict(TITLE_CHOICES) # Convert titles for use in emails + +title_dict = dict(TITLE_CHOICES) # Convert titles for use in emails ################ # Theses @@ -30,23 +31,23 @@ def request_thesislink(request): form = RequestThesisLinkForm(request.POST) if form.is_valid(): contributor = Contributor.objects.get(user=request.user) - thesislink = ThesisLink ( - requested_by = contributor, - type = form.cleaned_data['type'], - discipline = form.cleaned_data['discipline'], - domain = form.cleaned_data['domain'], - subject_area = form.cleaned_data['subject_area'], - title = form.cleaned_data['title'], - author = form.cleaned_data['author'], - supervisor = form.cleaned_data['supervisor'], - institution = form.cleaned_data['institution'], - defense_date = form.cleaned_data['defense_date'], - pub_link = form.cleaned_data['pub_link'], - abstract = form.cleaned_data['abstract'], - latest_activity = timezone.now(), + thesislink = ThesisLink( + requested_by=contributor, + type=form.cleaned_data['type'], + discipline=form.cleaned_data['discipline'], + domain=form.cleaned_data['domain'], + subject_area=form.cleaned_data['subject_area'], + title=form.cleaned_data['title'], + author=form.cleaned_data['author'], + supervisor=form.cleaned_data['supervisor'], + institution=form.cleaned_data['institution'], + defense_date=form.cleaned_data['defense_date'], + pub_link=form.cleaned_data['pub_link'], + abstract=form.cleaned_data['abstract'], + latest_activity=timezone.now(), ) thesislink.save() - #return HttpResponseRedirect('request_thesislink_ack') + # return HttpResponseRedirect('request_thesislink_ack') context = {'ack_header': 'Thank you for your request for a Thesis Link', 'ack_message': 'Your request will soon be handled by an Editor. ', 'followup_message': 'Return to your ', @@ -61,11 +62,12 @@ def request_thesislink(request): @permission_required('scipost.can_vet_thesislink_requests', raise_exception=True) def vet_thesislink_requests(request): contributor = Contributor.objects.get(user=request.user) - thesislink_to_vet = ThesisLink.objects.filter(vetted=False).first() # only handle one at a time + thesislink_to_vet = ThesisLink.objects.filter(vetted=False).first() # only handle one at a time form = VetThesisLinkForm() - context = {'contributor': contributor, 'thesislink_to_vet': thesislink_to_vet, 'form': form } + context = {'contributor': contributor, 'thesislink_to_vet': thesislink_to_vet, 'form': form} return render(request, 'theses/vet_thesislink_requests.html', context) + @permission_required('scipost.can_vet_thesislink_requests', raise_exception=True) def vet_thesislink_request_ack(request, thesislink_id): if request.method == 'POST': -- GitLab