SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 96b1e20a authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Invitation token useable once only; beautify invitation form with crispy

parent 1a43a7aa
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,9 @@ from django_countries.widgets import CountrySelectWidget ...@@ -5,6 +5,9 @@ from django_countries.widgets import CountrySelectWidget
from django_countries.fields import LazyTypedChoiceField from django_countries.fields import LazyTypedChoiceField
from captcha.fields import CaptchaField from captcha.fields import CaptchaField
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Field, Fieldset, HTML, Submit
from .models import * from .models import *
...@@ -43,7 +46,19 @@ class RegistrationInvitationForm(forms.ModelForm): ...@@ -43,7 +46,19 @@ class RegistrationInvitationForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(RegistrationInvitationForm, self).__init__(*args, **kwargs) super(RegistrationInvitationForm, self).__init__(*args, **kwargs)
self.fields['personal_message'].widget.attrs.update({'placeholder': 'NOTE: a personal phrase or two. The bulk of the text will be auto-generated.'}) self.fields['personal_message'].widget.attrs.update({'placeholder': 'NOTE: a personal phrase or two. The bulk of the text will be auto-generated.'})
self.helper = FormHelper()
self.helper.layout = Layout(
Div(
Div(
Field('title'), Field('first_name'), Field('last_name'), Field('email_address'), Field('invitation_type'),
css_class="col-6"),
Div(
Field('message_style'),
Field('personal_message'),
Submit('submit', 'Send invitation'),
css_class="col-6"),
css_class="row"),
)
class UpdateUserDataForm(forms.ModelForm): class UpdateUserDataForm(forms.ModelForm):
class Meta: class Meta:
......
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
</div> </div>
<form action="{% url 'scipost:registration_invitations' %}" method="post"> <form action="{% url 'scipost:registration_invitations' %}" method="post">
{% csrf_token %} {% csrf_token %}
<table> {% load crispy_forms_tags %}
{{ reg_inv_form.as_table }} {% crispy reg_inv_form %}
</table>
<input type="submit" value="Submit" />
</form> </form>
</section> </section>
<hr class="hr12"/> <hr class="hr12"/>
......
...@@ -117,10 +117,10 @@ class Utils(object): ...@@ -117,10 +117,10 @@ class Utils(object):
cls.invitation.save() cls.invitation.save()
email_text = 'Dear ' email_text = 'Dear '
if cls.invitation.message_style == 'F': if cls.invitation.message_style == 'F':
email_text += title_dict[cls.invitation.title] + ' ' + cls.invitation.last_name + ',\n\n' email_text += title_dict[cls.invitation.title] + ' ' + cls.invitation.last_name
else: else:
email_text += cls.invitation.first_name + ',\n\n' + cls.invitation.personal_message + '\n\n' email_text += cls.invitation.first_name
email_text += ',\n\n' + 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 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' +
'- a means to comment on all existing literature\n\n' + '- a means to comment on all existing literature\n\n' +
'- a repository of links to theses (Habilitation, PhD, Master’s)\n\n' + '- a repository of links to theses (Habilitation, PhD, Master’s)\n\n' +
......
...@@ -207,6 +207,8 @@ def accept_invitation(request, key): ...@@ -207,6 +207,8 @@ def accept_invitation(request, key):
elif invitation.responded: elif invitation.responded:
errormessage = 'This invitation token has already been used.' errormessage = 'This invitation token has already been used.'
else: else:
invitation.reponded = True
invitation.save()
form = RegistrationForm() form = RegistrationForm()
form.fields['last_name'].initial = invitation.last_name form.fields['last_name'].initial = invitation.last_name
form.fields['first_name'].initial = invitation.first_name form.fields['first_name'].initial = invitation.first_name
......
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