SciPost Code Repository

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

Replace wildcard imports for explicit ones

parent 0c40602a
No related branches found
No related tags found
No related merge requests found
from django import forms
from django.core.mail import EmailMessage
from .models import *
# from .models import *
from .models import ThesisLink
from .helpers import past_years
from scipost.models import Contributor, title_dict
class RequestThesisLinkForm(forms.ModelForm):
class Meta:
......@@ -54,8 +57,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
email_text = ('Dear ' + title_dict[thesislink.requested_by.title] + ' '
+ thesislink.requested_by.user.last_name
+ ', \n\nThe Thesis Link you have requested, concerning thesis with title '
+ thesislink.title + ' by ' + thesislink.author
+ ', \n\nThe Thesis Link you have requested, concerning thesis with'
+ ' title ' + thesislink.title + ' by ' + thesislink.author
+ ', has been activated at https://scipost.org/thesis/'
+ str(thesislink.id) + '.'
+ '\n\nThank you for your contribution, \nThe SciPost Team.')
......@@ -68,8 +71,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
elif int(self.cleaned_data['action_option']) == VetThesisLinkForm.REFUSE:
email_text = ('Dear ' + title_dict[thesislink.requested_by.title] + ' '
+ thesislink.requested_by.user.last_name
+ ', \n\nThe Thesis Link you have requested, concerning thesis with title '
+ thesislink.title + ' by ' + thesislink.author
+ ', \n\nThe Thesis Link you have requested, concerning thesis with'
+ ' title ' + thesislink.title + ' by ' + thesislink.author
+ ', has not been activated for the following reason: '
+ self.cleaned_data['refusal_reason']
+ '.\n\nThank you for your interest, \nThe SciPost Team.')
......@@ -90,8 +93,8 @@ class VetThesisLinkForm(RequestThesisLinkForm):
thesislink.save()
email_text = ('Dear ' + title_dict[thesislink.requested_by.title] + ' '
+ thesislink.requested_by.user.last_name
+ ', \n\nThe Thesis Link you have requested, concerning thesis with title '
+ thesislink.title + ' by ' + thesislink.author_list
+ ', \n\nThe Thesis Link you have requested, concerning thesis with'
+ ' title ' + thesislink.title + ' by ' + thesislink.author_list
+ ', has been activated '
'(with slight modifications to your submitted details) at '
'https://scipost.org/thesis/' + str(thesislink.id) + '.'
......
from django.utils import timezone
from django.db import models
from django.contrib.auth.models import User
from django.template import Template, Context
from .models import *
from journals.models import *
from scipost.constants import SCIPOST_DISCIPLINES, subject_areas_dict, disciplines_dict
from scipost.models import *
from journals.models import SCIPOST_JOURNALS_DOMAINS, journals_domains_dict
from scipost.constants import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS,\
subject_areas_dict, disciplines_dict
from scipost.models import Contributor
class ThesisLink(models.Model):
......@@ -75,8 +73,7 @@ class ThesisLink(models.Model):
'pub_link': self.pub_link, 'institution': self.institution,
'supervisor': self.supervisor, 'defense_date': self.defense_date,
'latest_activity': self.latest_activity.strftime('%Y-%m-%d %H:%M')})
print(subject_areas_dict)
print(self.subject_area in subject_areas_dict)
header = (
'<li><div class="flex-container">'
'<div class="flex-whitebox0"><p><a href="/thesis/{{ id }}" '
......
......@@ -2,25 +2,21 @@ import datetime
from django.utils import timezone
from django.shortcuts import get_object_or_404, render
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
from django.contrib.auth.decorators import permission_required
from django.contrib import messages
from django.core.mail import EmailMessage
from django.core.urlresolvers import reverse, reverse_lazy
from django.http import HttpResponse, HttpResponseRedirect
from django.views.decorators.csrf import csrf_protect
from django.db.models import Avg
from django.views.generic.edit import CreateView, FormView, UpdateView
from django.http import HttpResponseRedirect
from django.views.generic.edit import CreateView, UpdateView
from django.views.generic.list import ListView
from django.utils.decorators import method_decorator
from .models import *
from .forms import *
from .models import ThesisLink
from .forms import RequestThesisLinkForm, ThesisLinkSearchForm, VetThesisLinkForm
from comments.models import Comment
from comments.forms import CommentForm
from scipost.forms import TITLE_CHOICES, AuthenticationForm
from scipost.forms import TITLE_CHOICES
from scipost.models import Contributor
import strings
title_dict = dict(TITLE_CHOICES) # Convert titles for use in emails
......@@ -64,9 +60,9 @@ class VetThesisLink(UpdateView):
def form_valid(self, form):
# I totally override the form_valid method. I do not call super.
# This is because, by default, an UpdateView saves the object as instance,
# which it builds from the form data. So, the changes (by whom the thesis link was vetted, etc.)
# would be lost. Instead, we need the form to save with commit=False, then modify
# the vetting fields, and then save.
# which it builds from the form data. So, the changes (by whom the thesis link was
# vetted, etc.) would be lost. Instead, we need the form to save with commit=False,
# then modify the vetting fields, and then save.
# Builds model that reflects changes made during update. Does not yet save.
self.object = form.save(commit=False)
......@@ -102,7 +98,8 @@ def theses(request):
thesislink_recent_list = (ThesisLink.objects
.filter(vetted=True,
latest_activity__gte=timezone.now() + datetime.timedelta(days=-7)))
latest_activity__gte=timezone.now() + datetime.timedelta(
days=-7)))
context = {'form': form, 'thesislink_search_list': thesislink_search_list,
'thesislink_recent_list': thesislink_recent_list}
return render(request, 'theses/theses.html', context)
......
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