From e2871f53550dc4c0c5c17b750bf3129dde687d5d Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 30 Mar 2016 11:03:51 +0200 Subject: [PATCH] ONLINE LAUNCH VERSION --- scipost/models.py | 2 +- scipost/templates/scipost/register.html | 2 +- scipost/utils.py | 2 +- scipost/views.py | 69 ++++++++++++++++--------- 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/scipost/models.py b/scipost/models.py index 144c6032d..54a8a3d18 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -54,7 +54,7 @@ class Contributor(models.Model): affiliation = models.CharField(max_length=300, verbose_name='affiliation') address = models.CharField(max_length=1000, verbose_name="address", default='', blank=True) personalwebpage = models.URLField(verbose_name='personal web page', blank=True) - vetted_by = models.OneToOneField('self', blank=True, null=True) + vetted_by = models.ForeignKey('self', related_name="contrib_vetted_by", blank=True, null=True) def __str__ (self): diff --git a/scipost/templates/scipost/register.html b/scipost/templates/scipost/register.html index 9981e3505..cd22914b9 100644 --- a/scipost/templates/scipost/register.html +++ b/scipost/templates/scipost/register.html @@ -7,7 +7,7 @@ <section> <h1>Register to SciPost</h1> - {% if request.session.invited == True %}<!-- Temporary: only see form if invited --> + {% if invited %}<!-- Temporary: only see form if invited --> <div class="flex-greybox"> <h2>{{ welcome_message }}</h2> diff --git a/scipost/utils.py b/scipost/utils.py index 26f7d492a..342c61cb9 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -124,7 +124,7 @@ class Utils(object): email_text += ',\n\n' if cls.invitation.personal_message is not None: email_text += cls.invitation.personal_message + '\n\n' - email_text += ('You will have noticed that the world of scientific publishing is currently undergoing many changes, but you will ll perhaps agree that it is not completely clear that the best interests of science and scientists are being served. In recent times, and after much thinking of how best to address this issue, I have decided to forge ahead and implement a new online publication portal by and for scientists.\n\nThe initiative, called SciPost, can in a sense be viewed as an extra layer on arXiv.org. To summarize, SciPost will be a complete scientific publication platform, run by and for professional scientists, providing:\n\n' + + email_text += ('You will have noticed that the world of scientific publishing is currently undergoing many changes, but you will perhaps agree that it is not completely clear that the best interests of science and scientists are being served. In recent times, and after much thinking of how best to address this issue, I have decided to forge ahead and implement a new online publication portal by and for scientists.\n\nThe initiative, called SciPost, can in a sense be viewed as an extra layer on arXiv.org. To summarize, SciPost will be a complete scientific publication platform, run by and for professional scientists, providing:\n\n' + '- a means to comment on all existing literature\n\n' + "- a repository of links to theses (Habilitation, PhD, Master's)\n\n" + '- most importantly, a collection of community-run two-way open access (no subscription fees, no author fees) journals with extremely stringent (peer-witnessed) refereeing. The main innovations are thus a redesigned, more accountable refereeing process (addressing some of the weaknesses identified in current habits), together with a new concept for the editorial process, based on our Editorial College, designed to minimize the burden of the editorial workflow while ensuring the highest achievable quality.\n\n') diff --git a/scipost/views.py b/scipost/views.py index 890f34765..c0b6ee486 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -102,10 +102,52 @@ def register(request): return HttpResponseRedirect('thanks_for_registering') else: form = RegistrationForm() - context = {'form': form} + # Remove invited from next two lines to open registrations without invitation + invited = False + context = {'form': form, 'invited': invited} return render(request, 'scipost/register.html', context) +def accept_invitation(request, key): + """ Register, by invitation """ + invitation = get_object_or_404(RegistrationInvitation, invitation_key=key) + if request.method == 'POST': + form = RegistrationForm(request.POST) + Utils.load({'form': form}) + if form.is_valid(): + if Utils.password_mismatch(): + return render(request, 'scipost/register.html', + {'form': form, 'invited': True, 'errormessage': 'Your passwords must match'}) + if Utils.username_already_taken(): + return render(request, 'scipost/register.html', + {'form': form, 'invited': True, 'errormessage': 'This username is already in use'}) + if Utils.email_already_taken(): + return render(request, 'scipost/register.html', + {'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: + invitation_expired = True + errormessage = 'The invitation key has expired.' + elif invitation.responded: + errormessage = 'This invitation token has already been used.' + else: + invitation.responded = True + invitation.save() + form = RegistrationForm() + form.fields['title'].initial = invitation.title + form.fields['last_name'].initial = invitation.last_name + form.fields['first_name'].initial = invitation.first_name + form.fields['email'].initial = invitation.email_address + errormessage = '' + welcome_message = 'Welcome, ' + title_dict[invitation.title] + ' ' + invitation.last_name + ', and thanks in advance for registering (by completing this form)' + return render(request, 'scipost/register.html', {'form': form, 'invited': True, 'errormessage': errormessage, 'welcome_message': welcome_message}) + + context = {'errormessage': errormessage} + return render(request, 'scipost/accept_invitation_error.html', context) + + def activation(request, key): activation_expired = False @@ -210,7 +252,7 @@ def registration_invitations(request): if reg_inv_form.is_valid(): Utils.create_and_save_invitation() Utils.send_registration_invitation_email() - return HttpResponseRedirect('registration_invitation_sent') + return HttpResponseRedirect('registration_invitation_sent') else: reg_inv_form = RegistrationInvitationForm() sent_reg_inv_fellows = RegistrationInvitation.objects.filter(invitation_type='F', responded=False).order_by('last_name') @@ -229,29 +271,6 @@ def registration_invitations(request): return render(request, 'scipost/registration_invitations.html', context) -def accept_invitation(request, key): - """ Register, by invitation """ - invitation = get_object_or_404(RegistrationInvitation, invitation_key=key) - if timezone.now() > invitation.key_expires: - invitation_expired = True - errormessage = 'The invitation key has expired.' - elif invitation.responded: - errormessage = 'This invitation token has already been used.' - else: - invitation.responded = True - invitation.save() - form = RegistrationForm() - form.fields['title'].initial = invitation.title - form.fields['last_name'].initial = invitation.last_name - form.fields['first_name'].initial = invitation.first_name - form.fields['email'].initial = invitation.email_address - errormessage = '' - welcome_message = 'Welcome, ' + title_dict[invitation.title] + ' ' + invitation.last_name + ', and thanks in advance for registering (by completing this form)' - return render(request, 'scipost/register.html', {'form': form, 'errormessage': errormessage, 'welcome_message': welcome_message}) - - context = {'errormessage': errormessage} - return render(request, 'scipost/accept_invitation_error.html', context) - def login_view(request): if request.method == 'POST': -- GitLab