From ae285899a16403079c1a6de5bc1a671edcb44ce1 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 30 Mar 2016 11:25:08 +0200 Subject: [PATCH] Debug invitation if form incorrectly filled --- scipost/models.py | 3 +++ scipost/utils.py | 2 +- scipost/views.py | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scipost/models.py b/scipost/models.py index 54a8a3d18..80d215ad2 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -121,6 +121,9 @@ class RegistrationInvitation(models.Model): invited_by = models.ForeignKey(Contributor, blank=True, null=True) responded = models.BooleanField(default=False) + def __str__ (self): + return self.invitation_type + ' ' + self.first_name + ' ' + self.last_name + ' on ' + self.date_sent.strftime("%Y-%m-%d") + AUTHORSHIP_CLAIM_STATUS = ( diff --git a/scipost/utils.py b/scipost/utils.py index 342c61cb9..5c14f5896 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -145,7 +145,7 @@ class Utils(object): "If you do develop sympathy for the initiative, besides participating in the online platform, we'd be very grateful if you considered submitting a publication to one of the journals within the near future, in order to help establish their reputation. I'll also be looking forward to your reaction, your comments and suggestions, be they positive or negative.\n\n") email_text += ("On behalf of the SciPost Foundation,\n\n" + - "Prof. dr Jean-Sébastien Caux\n---------------------------------------------\nInstitute for Theoretial Physics\nUniversity of Amsterdam\nScience Park 904\n1098 XH Amsterdam\nThe Netherlands\n---------------------------------------------\ntel.: +31(0)20 5255775\nfax: +31 (0)20 5255778\n---------------------------------------------") + "Prof. dr Jean-Sébastien Caux\n---------------------------------------------\nInstitute for Theoretial Physics\nUniversity of Amsterdam\nScience Park 904\n1098 XH Amsterdam\nThe Netherlands\n---------------------------------------------\ntel.: +31 (0)20 5255775\nfax: +31 (0)20 5255778\n---------------------------------------------") emailmessage = EmailMessage( 'SciPost registration invitation', email_text, 'jscaux@scipost.org', diff --git a/scipost/views.py b/scipost/views.py index c0b6ee486..7d65f45a2 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -116,18 +116,18 @@ def accept_invitation(request, key): Utils.load({'form': form}) if form.is_valid(): if Utils.password_mismatch(): - return render(request, 'scipost/register.html', + return render(request, reverse('accept_invitation', kwargs={'key': key}), {'form': form, 'invited': True, 'errormessage': 'Your passwords must match'}) if Utils.username_already_taken(): - return render(request, 'scipost/register.html', + return render(request, reverse('accept_invitation', kwargs={'key': key}), {'form': form, 'invited': True, 'errormessage': 'This username is already in use'}) if Utils.email_already_taken(): - return render(request, 'scipost/register.html', + return render(request, reverse('accept_invitation', kwargs={'key': key}), {'form': form, 'invited': True, 'errormessage': 'This email address is already in use'}) Utils.create_and_save_contributor() Utils.send_registration_email() return HttpResponseRedirect('thanks_for_registering') - if timezone.now() > invitation.key_expires: + elif timezone.now() > invitation.key_expires: invitation_expired = True errormessage = 'The invitation key has expired.' elif invitation.responded: -- GitLab