SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit e06a8e8e authored by Geert Kapteijns's avatar Geert Kapteijns
Browse files

Fix redirect error in thesis detailview after posting comment

parent 24cc32a6
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,6 @@ class CommentForm(forms.ModelForm): ...@@ -62,7 +62,6 @@ class CommentForm(forms.ModelForm):
) )
class VetCommentForm(forms.Form): class VetCommentForm(forms.Form):
action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=COMMENT_ACTION_CHOICES, action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=COMMENT_ACTION_CHOICES,
required=True, label='Action') required=True, label='Action')
......
...@@ -33,15 +33,11 @@ COMMENT_STATUS = ( ...@@ -33,15 +33,11 @@ COMMENT_STATUS = (
) )
comment_status_dict = dict(COMMENT_STATUS) comment_status_dict = dict(COMMENT_STATUS)
class Comment(models.Model): class Comment(models.Model):
""" A Comment is an unsollicited note, submitted by a Contributor, """ A Comment is an unsollicited note, submitted by a Contributor,
on a particular publication or in reply to an earlier Comment. """ on a particular publication or in reply to an earlier Comment. """
# status:
# 1: vetted
# 0: unvetted
# -1: rejected (unclear)
# -2: rejected (incorrect)
# -3: rejected (not useful)
status = models.SmallIntegerField(default=0) status = models.SmallIntegerField(default=0)
vetted_by = models.ForeignKey(Contributor, blank=True, null=True, vetted_by = models.ForeignKey(Contributor, blank=True, null=True,
on_delete=models.CASCADE, on_delete=models.CASCADE,
......
import factory import factory
from .models import ThesisLink from .models import ThesisLink
from scipost.factories import UserFactory, ContributorFactory from scipost.factories import ContributorFactory
class ThesisLinkFactory(factory.django.DjangoModelFactory): class ThesisLinkFactory(factory.django.DjangoModelFactory):
......
...@@ -28,6 +28,7 @@ class RequestThesisLinkForm(forms.ModelForm): ...@@ -28,6 +28,7 @@ class RequestThesisLinkForm(forms.ModelForm):
self.fields['pub_link'].widget.attrs.update({'placeholder': 'Full URL'}) self.fields['pub_link'].widget.attrs.update({'placeholder': 'Full URL'})
self.fields['abstract'].widget.attrs.update({'cols': 100}) self.fields['abstract'].widget.attrs.update({'cols': 100})
class VetThesisLinkForm(forms.Form): class VetThesisLinkForm(forms.Form):
action_option = forms.ChoiceField(widget=forms.RadioSelect, action_option = forms.ChoiceField(widget=forms.RadioSelect,
choices=THESIS_ACTION_CHOICES, choices=THESIS_ACTION_CHOICES,
......
from django.test import TestCase from django.test import TestCase
from django.test.client import Client
class TestThesisDetail(TestCase):
def test_acknowledges_after_submitting_comment(self):
client = Client()
response = client.post('/theses/1')
self.assertEqual(response.get('location'), 'bladiebla')
...@@ -137,8 +137,6 @@ def vet_thesislink_request_ack(request, thesislink_id): ...@@ -137,8 +137,6 @@ def vet_thesislink_request_ack(request, thesislink_id):
emailmessage.send(fail_silently=False) emailmessage.send(fail_silently=False)
thesislink.delete() thesislink.delete()
#context = {'thesislink_id': thesislink_id }
# return render(request, 'theses/vet_thesislink_request_ack.html', context)
context = {'ack_header': 'Thesis Link request vetted.', context = {'ack_header': 'Thesis Link request vetted.',
'followup_message': 'Return to the ', 'followup_message': 'Return to the ',
'followup_link': reverse('theses:vet_thesislink_requests'), 'followup_link': reverse('theses:vet_thesislink_requests'),
...@@ -207,7 +205,7 @@ def thesis_detail(request, thesislink_id): ...@@ -207,7 +205,7 @@ def thesis_detail(request, thesislink_id):
form = CommentForm(request.POST) form = CommentForm(request.POST)
if form.is_valid(): if form.is_valid():
author = Contributor.objects.get(user=request.user) author = Contributor.objects.get(user=request.user)
newcomment = Comment( new_comment = Comment(
thesislink=thesislink, thesislink=thesislink,
author=author, author=author,
is_rem=form.cleaned_data['is_rem'], is_rem=form.cleaned_data['is_rem'],
...@@ -222,11 +220,12 @@ def thesis_detail(request, thesislink_id): ...@@ -222,11 +220,12 @@ def thesis_detail(request, thesislink_id):
remarks_for_editors=form.cleaned_data['remarks_for_editors'], remarks_for_editors=form.cleaned_data['remarks_for_editors'],
date_submitted=timezone.now(), date_submitted=timezone.now(),
) )
newcomment.save() new_comment.save()
author.nr_comments = Comment.objects.filter(author=author).count() author.nr_comments = Comment.objects.filter(author=author).count()
author.save() author.save()
request.session['thesislink_id'] = thesislink_id request.session['thesislink_id'] = thesislink_id
return HttpResponseRedirect(reverse('comments:comment_submission_ack')) context = {}
return render(request, 'scipost/acknowledgement.html', context)
else: else:
form = CommentForm() form = CommentForm()
......
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