diff --git a/journals/models.py b/journals/models.py index 8581d9d7915b7f7f4ad6acc16d0d5b2097ad3ed7..7afb01756af51cc4ac083b00d0fbff342e9d2b27 100644 --- a/journals/models.py +++ b/journals/models.py @@ -22,9 +22,11 @@ SCIPOST_JOURNALS = ( ) journals_dict = dict(SCIPOST_JOURNALS) + class JournalNameError(Exception): def __init__(self, name): self.name = name + def __str__(self): return self.name diff --git a/scipost/management/commands/populate_db.py b/scipost/management/commands/populate_db.py index 26e2d1a3ac72011e41781b943cedfd7e015b137d..1b4508a504f52ae21dc017178f2aba9ab78f2d62 100644 --- a/scipost/management/commands/populate_db.py +++ b/scipost/management/commands/populate_db.py @@ -16,5 +16,7 @@ class Command(BaseCommand): contributor.vetted_by = contributor contributor.save() + def create_theses(self): + def handle(self, *args, **options): self.create_contributor(options['username']) diff --git a/scipost/models.py b/scipost/models.py index 2962da77cc4716fcf50d66db6668033d42deb937..31e27a84a3986d012b3c6836443ac290619f855b 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -212,7 +212,6 @@ class Contributor(models.Model): default=True, verbose_name="I accept to receive SciPost emails") - def __str__(self): return '%s, %s' % (self.user.last_name, self.user.first_name) diff --git a/theses/models.py b/theses/models.py index 37fcb52f07fd7f09fc90c3a53982bd18c9d162e8..21d717e98592cfe06eacdac7b2979f3941dcd27f 100644 --- a/theses/models.py +++ b/theses/models.py @@ -110,6 +110,8 @@ 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 }}" ' diff --git a/theses/views.py b/theses/views.py index 1c634d90b01759200296b8e7651bf56db8050c68..2f1be437a6d9c26303218b168b85b75b7d46dbf7 100644 --- a/theses/views.py +++ b/theses/views.py @@ -45,7 +45,7 @@ def request_thesislink(request): pub_link=form.cleaned_data['pub_link'], abstract=form.cleaned_data['abstract'], latest_activity=timezone.now(), - ) + ) thesislink.save() # return HttpResponseRedirect('request_thesislink_ack') context = {'ack_header': 'Thank you for your request for a Thesis Link', @@ -62,7 +62,8 @@ 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} return render(request, 'theses/vet_thesislink_requests.html', context) @@ -114,8 +115,8 @@ def vet_thesislink_request_ack(request, thesislink_id): ['theses@scipost.org'], reply_to=['theses@scipost.org']) # Don't send email yet... only when option 1 has succeeded! - #emailmessage.send(fail_silently=False) - context = {'form': form2 } + # emailmessage.send(fail_silently=False) + context = {'form': form2} return render(request, 'theses/request_thesislink.html', context) elif form.cleaned_data['action_option'] == '2': email_text = ('Dear ' + title_dict[thesislink.requested_by.title] + ' ' @@ -126,7 +127,8 @@ def vet_thesislink_request_ack(request, thesislink_id): + form.cleaned_data['refusal_reason'] + '.\n\nThank you for your interest, \nThe SciPost Team.') if form.cleaned_data['email_response_field']: - email_text += '\n\nFurther explanations: ' + form.cleaned_data['email_response_field'] + email_text += '\n\nFurther explanations: ' + \ + form.cleaned_data['email_response_field'] emailmessage = EmailMessage('SciPost Thesis Link', email_text, 'SciPost Theses <theses@scipost.org>', [thesislink.requested_by.user.email], @@ -136,7 +138,7 @@ def vet_thesislink_request_ack(request, thesislink_id): thesislink.delete() #context = {'thesislink_id': thesislink_id } - #return render(request, 'theses/vet_thesislink_request_ack.html', context) + # return render(request, 'theses/vet_thesislink_request_ack.html', context) context = {'ack_header': 'Thesis Link request vetted.', 'followup_message': 'Return to the ', 'followup_link': reverse('theses:vet_thesislink_requests'), @@ -154,7 +156,7 @@ def theses(request): abstract__icontains=form.cleaned_data['abstract_keyword'], supervisor__icontains=form.cleaned_data['supervisor'], vetted=True, - ) + ) thesislink_search_list.order_by('-pub_date') else: thesislink_search_list = [] @@ -167,7 +169,7 @@ def theses(request): .filter(vetted=True, latest_activity__gte=timezone.now() + datetime.timedelta(days=-7))) context = {'form': form, 'thesislink_search_list': thesislink_search_list, - 'thesislink_recent_list': thesislink_recent_list } + 'thesislink_recent_list': thesislink_recent_list} return render(request, 'theses/theses.html', context) @@ -181,11 +183,11 @@ def browse(request, discipline, nrweeksback): abstract__icontains=form.cleaned_data['abstract_keyword'], supervisor__icontains=form.cleaned_data['supervisor'], vetted=True, - ) + ) thesislink_search_list.order_by('-pub_date') else: thesislink_search_list = [] - context = {'form': form, 'thesislink_search_list': thesislink_search_list } + context = {'form': form, 'thesislink_search_list': thesislink_search_list} return HttpResponseRedirect(request, 'theses/theses.html', context) else: form = ThesisLinkSearchForm() @@ -194,7 +196,7 @@ def browse(request, discipline, nrweeksback): latest_activity__gte=timezone.now() + datetime.timedelta(weeks=-int(nrweeksback)))) context = {'form': form, 'discipline': discipline, 'nrweeksback': nrweeksback, - 'thesislink_browse_list': thesislink_browse_list } + 'thesislink_browse_list': thesislink_browse_list} return render(request, 'theses/theses.html', context) @@ -205,21 +207,21 @@ def thesis_detail(request, thesislink_id): form = CommentForm(request.POST) if form.is_valid(): author = Contributor.objects.get(user=request.user) - newcomment = Comment ( - thesislink = thesislink, - author = author, - is_rem = form.cleaned_data['is_rem'], - is_que = form.cleaned_data['is_que'], - is_ans = form.cleaned_data['is_ans'], - is_obj = form.cleaned_data['is_obj'], - is_rep = form.cleaned_data['is_rep'], - is_val = form.cleaned_data['is_val'], - is_lit = form.cleaned_data['is_lit'], - is_sug = form.cleaned_data['is_sug'], - comment_text = form.cleaned_data['comment_text'], - remarks_for_editors = form.cleaned_data['remarks_for_editors'], - date_submitted = timezone.now(), - ) + newcomment = Comment( + thesislink=thesislink, + author=author, + is_rem=form.cleaned_data['is_rem'], + is_que=form.cleaned_data['is_que'], + is_ans=form.cleaned_data['is_ans'], + is_obj=form.cleaned_data['is_obj'], + is_rep=form.cleaned_data['is_rep'], + is_val=form.cleaned_data['is_val'], + is_lit=form.cleaned_data['is_lit'], + is_sug=form.cleaned_data['is_sug'], + comment_text=form.cleaned_data['comment_text'], + remarks_for_editors=form.cleaned_data['remarks_for_editors'], + date_submitted=timezone.now(), + ) newcomment.save() author.nr_comments = Comment.objects.filter(author=author).count() author.save()