diff --git a/mails/forms.py b/mails/forms.py index a7a8b241a3b22343728d21d1e28536af52da02b4..a3afda4b877659ca0dff58f3e35e962a3833adff 100644 --- a/mails/forms.py +++ b/mails/forms.py @@ -18,11 +18,20 @@ class EmailTemplateForm(forms.Form): subject = forms.CharField(max_length=250, label="Subject*") text = forms.CharField(widget=SummernoteEditor, label="Text*") extra_recipient = forms.EmailField(label="Optional: bcc this email to", required=False) + prefix = 'mail_form' def __init__(self, *args, **kwargs): self.mail_code = kwargs.pop('mail_code') self.mail_fields = None - super().__init__(*args) + + data = {} + if args[0].get('subject'): + data['subject'] = args[0]['subject'] + if args[0].get('text'): + data['text'] = args[0]['text'] + if args[0].get('extra_recipient'): + data['extra_recipient'] = args[0]['extra_recipient'] + super().__init__(data or None) # Gather data mail_template = loader.get_template('mail_templates/%s.html' % self.mail_code) @@ -131,3 +140,18 @@ class EmailTemplateForm(forms.Form): reply_to=[self.mail_data.get('from_address', 'no-reply@scipost.org')]) email.attach_alternative(self.mail_fields['html_message'], 'text/html') email.send(fail_silently=False) + + +class HiddenDataForm(forms.Form): + def __init__(self, form, *args, **kwargs): + super().__init__(form.data, *args, **kwargs) + for name, field in form.fields.items(): + self.fields[name] = field + self.fields[name].widget = forms.HiddenInput() + + # for name, field in form.fields.items(): + # self.fields[name] = field + # d = form.data + # raise + # for field, value in form.data.items(): + # self.fields[name].initial = value diff --git a/mails/templates/mail_templates/registration_invitation.html b/mails/templates/mail_templates/registration_invitation.html new file mode 100644 index 0000000000000000000000000000000000000000..0202042a577c7c213ca9280752a95e17febd011b --- /dev/null +++ b/mails/templates/mail_templates/registration_invitation.html @@ -0,0 +1,289 @@ +{% if renew %} + Reminder: Invitation to SciPost + ------------------------------- + + <strong>Reminder: Invitation to SciPost</strong> + <br/> +{% endif %} + +{% if invitation.invitation_type == 'F' %} + <strong>RE: Invitation to join the Editorial College of SciPost</strong> + <br> +{% endif %} + +Dear {% if invitation.message_style == 'F' %}{{ invitation.get_title_display }} {{ invitation.last_name }}{% else %}{{ invitation.first_name }}{% endif %}, + +<br><br> + +{% if invitation.personal_message %} + {{ personal_message|linebreaks }} + <br> +{% endif %} + + +{% if invitation.invitation_type == 'R' %} + <p> + We would hereby like to cordially invite you + to become a Contributor on SciPost + (this is required in order to deliver reports; + our records show that you are not yet registered); + for your convenience, we have prepared a pre-filled + <a href="https://scipost.org/invitation/{{ invitation_key }}">registration form</a> + for you. After activation of your registration, you will be allowed to contribute, + in particular by providing referee reports. + </p> + <p> + To ensure timely processing of the submission (out of respect for the authors), + we would appreciate a quick accept/decline + response from you, ideally within the next 2 days. + </p> + <p> + If you are <strong>not</strong> able to provide a Report, + you can let us know by simply + <a href="https://scipost.org/submissions/decline_ref_invitation/{{ invitation_key }}"> + clicking here</a>. + </p> + <p> + If you are able to provide a Report, you can confirm this after registering + and logging in (you will automatically be prompted for a confirmation). + </p> + <p> + We very much hope that we can count on your expertise, + <br> + Many thanks in advance, + <br> + The SciPost Team + </p> +{% elif invitation.invitation_type == 'ci' %} + <p> + Your work has been cited in a manuscript submitted to SciPost, + </p> + <p>{{ invitation.cited_in_submission.title }} <br>by {{ invitation.cited_in_submission.author_list }}, + </p> + <p> + which you can find online at the <a href="https://scipost.org/{{ invitation.cited_in_submission.get_absolute_url }}"> submission's page</a>. + </p> + <p> + I would hereby like to use this opportunity to quickly introduce + you to the SciPost initiative, and to invite you to become an active + Contributor to the site. You might for example consider reporting or + commenting on the above submission before the refereeing deadline. + </p> + + <p> + In summary, SciPost.org is a publication portal managed by + professional scientists, offering (among others) high-quality + Open Access journals with innovative forms of refereeing, and a + means of commenting on all existing literature. SciPost is established as + a not-for-profit foundation devoted to serving the interests of the + international scientific community. + </p> + <p> + The site is anchored at <a href="https://scipost.org">scipost.org</a>. + Many further details about SciPost, its principles, ideals and implementation can be found at + the <a href="https://scipost.org/about">about</a> + and <a href="https://scipost.org/FAQ">FAQ</a> pages.</p> + <p>As a professional academic, you can register at the + <a href="https://scipost.org/register">registration page</a>, + enabling you to contribute to the site's contents, for example by offering submissions, reports and comments. + </p> + <p> + For your convenience, a partly pre-filled <a href="https://scipost.org/invitation/{{ invitation_key }}">registration form</a> + has been prepared for you (you can in any case still register at the + <a href="https://scipost.org/register">registration page</a>). + </p> + <p> + If you do develop sympathy for the initiative, besides participating in the + online platform, we would 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. We'll also be looking forward to your reaction, + comments and suggestions about the initiative, which we hope you will find + useful to your work as a professional scientist. + </p> + <p> + Many thanks in advance for taking a few minutes to look into it, + <br> + On behalf of the SciPost Foundation,<br> + <br> + {{ invitation.invited_by.get_title_display }} {{ invitation.invited_by.user.first_name }} {{ invitation.invited_by.user.last_name }} + </p> + +{% elif invitation.invitation_type == 'cp' %} + <p> + Your work has been cited in a paper published by SciPost, + </p> + <p> + {{ invitation.cited_in_publication.title }} + <br> + <i>by {{ invitation.cited_in_publication.author_list }}</i> + <br> + (published as <a href="https://scipost.org/{{ invitation.cited_in_publication.doi_label }}">{{ invitation.cited_in_publication.citation }}</a>). + </p> + <p> + I would hereby like to use this opportunity to quickly introduce + you to the SciPost initiative, and to invite you to become an active + Contributor to the site. + </p> + + <p> + In summary, SciPost.org is a publication portal managed by + professional scientists, offering (among others) high-quality + Open Access journals with innovative forms of refereeing, and a + means of commenting on all existing literature. SciPost is established as + a not-for-profit foundation devoted to serving the interests of the + international scientific community. + </p> + <p> + The site is anchored at <a href="https://scipost.org">scipost.org</a>. + Many further details about SciPost, its principles, ideals and implementation can be found at + the <a href="https://scipost.org/about">about</a> + and <a href="https://scipost.org/FAQ">FAQ</a> pages.</p> + <p>As a professional academic, you can register at the + <a href="https://scipost.org/register">registration page</a>, + enabling you to contribute to the site's contents, for example by offering submissions, reports and comments. + </p> + <p> + For your convenience, a partly pre-filled <a href="https://scipost.org/invitation/{{ invitation_key }}">registration form</a> + has been prepared for you (you can in any case still register at the + <a href="https://scipost.org/register">registration page</a>). + </p> + <p> + If you do develop sympathy for the initiative, besides participating in the + online platform, we would 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. We'll also be looking forward to your reaction, + comments and suggestions about the initiative, which we hope you will find + useful to your work as a professional scientist. + </p> + <p> + Many thanks in advance for taking a few minutes to look into it, + <br> + On behalf of the SciPost Foundation,<br> + <br> + {{ invitation.invited_by.get_title_display }} {{ invitation.invited_by.user.first_name }} {{ invitation.invited_by.user.last_name }} + </p> +{% elif invitation.invitation_type == 'C' %} + <p> + I would hereby like to quickly introduce + you to a scientific publishing initiative + called SciPost, and to invite you to become an active Contributor. + </p> + + <p> + In summary, SciPost.org is a publication portal managed by + professional scientists, offering (among others) high-quality + Open Access journals with innovative forms of refereeing, and a + means of commenting on all existing literature. SciPost is established as + a not-for-profit foundation devoted to serving the interests of the + international scientific community. + </p> + <p> + The site is anchored at <a href="https://scipost.org">scipost.org</a>. + Many further details about SciPost, its principles, ideals and implementation can be found at + the <a href="https://scipost.org/about">about</a> + and <a href="https://scipost.org/FAQ">FAQ</a> pages.</p> + <p>As a professional academic, you can register at the + <a href="https://scipost.org/register">registration page</a>, + enabling you to contribute to the site's contents, for example by offering submissions, reports and comments. + </p> + <p> + For your convenience, a partly pre-filled <a href="https://scipost.org/invitation/{{ invitation_key }}">registration form</a> + has been prepared for you (you can in any case still register at the + <a href="https://scipost.org/register">registration page</a>). + </p> + <p> + If you do develop sympathy for the initiative, besides participating in the + online platform, we would 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. We'll also be looking forward to your reaction, + comments and suggestions about the initiative, which we hope you will find + useful to your work as a professional scientist. + </p> + <p> + Many thanks in advance for taking a few minutes to look into it, + <br> + On behalf of the SciPost Foundation,<br> + <br> + {{ invitation.invited_by.get_title_display }} {{ invitation.invited_by.user.first_name }} {{ invitation.invited_by.user.last_name }} + </p> +{% elif invitation.invitation_type == 'F' %} + <p> + You will perhaps have already heard about SciPost, a publication + portal established by and for professional scientists. + </p> + <p> + SciPost.org is legally based on a not-for-profit foundation and will + operate in perpetuity as a non-commercial entity at the exclusive service + of the academic sector, bringing a cost-slashing alternative to existing practices. + </p> + <p> + SciPost offers a collection of two-way open + access (no subscription fees, no author fees) journals with extremely + stringent (peer-witnessed) refereeing, overseen by + our Editorial College (exclusively composed + of established, professionally practising scientists). The whole process is + designed to ensure the highest achievable scientific quality while making the + editorial workflow as light and efficient as possible. + </p> + <p> + To go straight to the point, on behalf of the SciPost Foundation + and in view of your professional expertise, I hereby would + like to invite you to become an Editorial Fellow and thus join the + Editorial College of SciPost Physics. + </p> + <p> + Please note that only well-known and respected senior academics are + being contacted for this purpose. Academic reputation and involvement + in the community are the most important criteria guiding our + considerations of who should belong to the Editorial College. + </p> + <p> + To help you in considering this, it would be best if you were to take + the time to look at the website itself, which is anchored at scipost.org. + Besides looking around the site, you can also personally register + (to become a Contributor, without necessarily committing to membership + of the Editorial College, this to be discussed separately) by visiting + the following <a href="https://scipost.org/invitation/{{ invitation.cited_in_publication.citation }}"> + single-use link</a>, containing a partly pre-filled form for your convenience. + </p> + <p> + Many details about the initiative + can then be found at scipost.org/about and at scipost.org/FAQ. + Functioning of the College will proceed according to the by-laws set + out in scipost.org/EdCol_by-laws. + </p> + <p> + Since the success of this initiative is dependent on the involvement of + the very people it is meant to serve, we'd be very grateful if you were + to give due consideration to this proposal. We would expect you to + commit just 2-4 hours per month to help perform Editorial duties; we will + constantly adjust the number of Editorial Fellows to ensure this is the case. You + could try it out for 6 months or a year, and of course you could quit + any time you wished. + </p> + <p> + I'd be happy to provide you with more information, should you require + it. In view of our development plans, I would be grateful if you could + react (by replying to this email) within the next two or three weeks, + if possible. I'll be looking forward to your reaction, your comments + and suggestions, be they positive or negative. If you need more time + to consider, that's also fine; just let me know. + </p> + <p> + On behalf of the SciPost Foundation,<br> + <br> + <br> + <br>Prof. dr Jean-Sébastien Caux + <br>--------------------------------------------- + <br>Institute for Theoretial Physics + <br>University of Amsterdam + <br>Science Park 904 + <br>1098 XH Amsterdam + <br>The Netherlands + <br>--------------------------------------------- + <br>tel.: +31 (0)20 5255775\nfax: +31 (0)20 5255778 + <br>--------------------------------------------- + </p> +{% endif %} + +{% include 'email/_footer.html' %} diff --git a/mails/templates/mail_templates/registration_invitation.json b/mails/templates/mail_templates/registration_invitation.json new file mode 100644 index 0000000000000000000000000000000000000000..9941b614623cf8f70ca83bcfbf4f934307d93b3f --- /dev/null +++ b/mails/templates/mail_templates/registration_invitation.json @@ -0,0 +1,8 @@ +{ + "subject": "SciPost: invitation", + "to_address": "email", + "bcc_to": "invited_by.user.email", + "from_address_name": "J-S Caux", + "from_address": "jscaux@scipost.org", + "context_object": "invitation" +} diff --git a/mails/templates/mails/mail_form.html b/mails/templates/mails/mail_form.html index fbb170d4dcffc6286e03a3737fdc24d8eef863dc..651e840fe09cc5808caf604e33a0788b35faa701 100644 --- a/mails/templates/mails/mail_form.html +++ b/mails/templates/mails/mail_form.html @@ -9,8 +9,11 @@ <h1>Complete and send mail</h1> <h3 class="mb-4">You may edit the mail before sending it.</h3> + {{ transfer_data }} + <form enctype="multipart/form-data" method="post"> {% csrf_token %} + {% if transfer_data_form %}{{ transfer_data_form }}{% endif %} {{ form|bootstrap }} <div class="form-group row"> <div class="offset-md-2 col-md-10"> diff --git a/mails/views.py b/mails/views.py index f7fedc01ded99d81c6f90b0d33f17e8489024ca9..61e4e3ccc9b79ca7e5221092335e3df649aa853c 100644 --- a/mails/views.py +++ b/mails/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render -from .forms import EmailTemplateForm +from .forms import EmailTemplateForm, HiddenDataForm class MailEditingSubView(object): @@ -14,6 +14,9 @@ class MailEditingSubView(object): def recipients_string(self): return ', '.join(getattr(self.mail_form, 'mail_fields', {}).get('recipients', [''])) + def add_form(self, form): + self.context['transfer_data_form'] = HiddenDataForm(form) + def is_valid(self): return self.mail_form.is_valid() diff --git a/scipost/forms.py b/scipost/forms.py index 60c748382e617c1bc3a971b3caefdddb3ebb3f63..82b0e187994230fd1201474a6137e02577e8963f 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -145,8 +145,7 @@ class DraftInvitationForm(forms.ModelForm): model = DraftInvitation fields = ['title', 'first_name', 'last_name', 'email', 'invitation_type', - 'cited_in_submission', 'cited_in_publication' - ] + 'cited_in_submission', 'cited_in_publication'] def __init__(self, *args, **kwargs): ''' @@ -161,12 +160,7 @@ class DraftInvitationForm(forms.ModelForm): if self.instance.id: return email - if RegistrationInvitation.objects.filter(email=email).exists(): - self.add_error('email', 'This email address has already been used for an invitation') - elif DraftInvitation.objects.filter(email=email).exists(): - self.add_error('email', ('This email address has already been' - ' used for a draft invitation')) - elif User.objects.filter(email=email).exists(): + if User.objects.filter(email=email).exists(): self.add_error('email', 'This email address is already associated to a Contributor') return email @@ -253,9 +247,9 @@ class RegistrationInvitationForm(forms.ModelForm): def clean_email(self): email = self.cleaned_data['email'] - if RegistrationInvitation.objects.filter(email=email).exists(): - self.add_error('email', 'This email address has already been used for an invitation') - elif User.objects.filter(email=email).exists(): + # if RegistrationInvitation.objects.filter(email=email).exists(): + # self.add_error('email', 'This email address has already been used for an invitation') + if User.objects.filter(email=email).exists(): self.add_error('email', 'This email address is already associated to a Contributor') return email diff --git a/scipost/templates/scipost/registration_invitation_form.html b/scipost/templates/scipost/registration_invitation_form.html new file mode 100644 index 0000000000000000000000000000000000000000..2de39239065b03276ce255127c6caaf4f10f7e9c --- /dev/null +++ b/scipost/templates/scipost/registration_invitation_form.html @@ -0,0 +1,29 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block pagetitle %}: registration invitations{% endblock pagetitle %} + +{% load scipost_extras %} +{% load bootstrap %} + +{% block breadcrumb_items %} + {{block.super}} + <a href="{% url 'scipost:registration_invitations' %}" class="breadcrumb-item">Registration invitations</a> + <span class="breadcrumb-item">Process</span> +{% endblock %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Send Registration Invitation</h1> + <br> + <form method="post"> + {% csrf_token %} + {{ form.media }} + {{ form|bootstrap }} + <input type="submit" class="btn btn-primary" value="Submit"> + </form> + </div> +</div> + +{% endblock %} diff --git a/scipost/templates/scipost/registration_invitations.html b/scipost/templates/scipost/registration_invitations.html index bcd610d61a0b261225a22c21b222e0e5f2f8f528..7e3397834667e1efe4e837c0288f281f314804ec 100644 --- a/scipost/templates/scipost/registration_invitations.html +++ b/scipost/templates/scipost/registration_invitations.html @@ -35,33 +35,17 @@ $(document).ready(function(){ <div class="row"> <div class="col-12"> - <div class="card card-grey"> - <div class="card-body"> - <h1 class="card-title">Registration Invitations</h1> - {% if request.user|is_in_group:'SciPost Administrators' %} - <h3>Perform a <a href="{% url 'scipost:registration_invitations_cleanup' %}">cleanup</a> of existing invitations.</h3> - {% endif %} - </div> - </div> + <h1 class="highlight">Registration Invitations</h1> + <h3>Actions</h3> + <ul> + {% if perms.scipost.can_manage_registration_invitations %} + <li><a href="{% url 'scipost:registration_invitations_cleanup' %}">Perform a cleanup</a> of existing invitations</li> + {% endif %} + <li><a href="#">Send new invitation</a></li> + </ul> </div> </div> -<div class="row"> - <div class="col-12"> - <h2 class="highlight">Send a new invitation</h2> - {% if errormessage %} - <h3 class="text-danger">{{ errormessage }}</h3> - {% endif %} - <form action="{% url 'scipost:registration_invitations' %}" method="post"> - {% csrf_token %} - {{reg_inv_form.media}} - {{reg_inv_form|bootstrap}} - <input type="submit" class="btn btn-primary" value="Submit"> - </form> - </div> -</div> - - <div class="row"> <div class="col-12"> <h2 class="highlight">Existing drafts (to be processed by Admin)</h2> diff --git a/scipost/urls.py b/scipost/urls.py index 9ab0cf02bef3b221475c65d090119be5b56fd827..d363be48829f4269adeaab9d65e2afc13e48bfd5 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -84,7 +84,7 @@ urlpatterns = [ url(r'^registration_requests/(?P<contributor_id>[0-9]+)/reset$', views.registration_requests_reset, name="registration_requests_reset"), url(r'^registration_invitations/(?P<draft_id>[0-9]+)$', - views.registration_invitations, name="registration_invitations_from_draft"), + views.registration_invitations_form, name="registration_invitations_from_draft"), url(r'^registration_invitations$', views.registration_invitations, name="registration_invitations"), url(r'^draft_registration_invitation$', diff --git a/scipost/utils.py b/scipost/utils.py index 8c95c5ddc109f882dba1f4052172eaedfce83fe2..dfadfebcea7d96f23894c744f7329f28714d0c0a 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -280,16 +280,6 @@ class Utils(BaseMailUtil): 'useful to your work as a professional scientist.</p>' '\n<p>Many thanks in advance for taking a few minutes to look into it,</p>' '<p>On behalf of the SciPost Foundation,</p>' - # '<br/>Prof. dr Jean-Sébastien Caux' - # '<br/>---------------------------------------------' - # '<br/>Institute for Theoretical Physics' - # '<br/>University of Amsterdam' - # '<br/>Science Park 904' - # '<br/>1098 XH Amsterdam<br/>The Netherlands' - # '<br/>---------------------------------------------' - # '<br/>tel.: +31 (0)20 5255775' - # '<br/>fax: +31 (0)20 5255778' - # '<br/>---------------------------------------------' '<p>' + signature + '</p>' ) email_context['invitation_key'] = cls.invitation.invitation_key diff --git a/scipost/views.py b/scipost/views.py index b9d8656f910498ac50b5d7993d097c7f8b7eb00b..a99666af6ea14f179212c850972a2bb491d75df8 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -442,42 +442,96 @@ def map_draft_reg_inv_to_contributor(request, draft_id, contributor_id): @permission_required('scipost.can_invite_Fellows', return_403=True) -def registration_invitations(request, draft_id=None): - """ Overview and tools for administrators """ - # List invitations sent; send new ones - associated_contributors = None - initial = {} - if draft_id: - # Fill draft data if draft_id given - draft = get_object_or_404(DraftInvitation, id=draft_id) - associated_contributors = Contributor.objects.filter( - user__last_name__icontains=draft.last_name) - initial = { - 'title': draft.title, - 'first_name': draft.first_name, - 'last_name': draft.last_name, - 'email': draft.email, - 'invitation_type': draft.invitation_type, - 'cited_in_submission': draft.cited_in_submission, - 'cited_in_publication': draft.cited_in_publication, - } +def registration_invitations_form(request, draft_id): + draft = get_object_or_404(DraftInvitation, id=draft_id) + initial = { + 'title': draft.title, + 'first_name': draft.first_name, + 'last_name': draft.last_name, + 'email': draft.email, + 'invitation_type': draft.invitation_type, + 'cited_in_submission': draft.cited_in_submission, + 'cited_in_publication': draft.cited_in_publication, + } + form = RegistrationInvitationForm(request.POST or None, initial=initial, + current_user=request.user) + mail_request = MailEditingSubView(request, mail_code='registration_invitation', + invitation=draft) + if form.is_valid(): + if mail_request.is_valid(): + # invitation.nr_reminders += 1 + # invitation.date_last_reminded = timezone.now() + # invitation.save() + # invitation.refresh_keys() + # messages.success(request, 'Registration invitation has been sent.') + # mail_request.send() + invitation = form.save(commit=False) + invitation.invited_by = request.user.contributor + invitation.save() + invitation.refresh_keys() - # Send invitation from form information - reg_inv_form = RegistrationInvitationForm(request.POST or None, initial=initial, - current_user=request.user) - if reg_inv_form.is_valid(): - invitation = reg_inv_form.save(commit=False) - invitation.invited_by = request.user.contributor - invitation.save() - invitation.refresh_keys() + Utils.load({'invitation': invitation}) + Utils.send_registration_invitation_email() + DraftInvitation.objects.filter(email=form.cleaned_data['email']).update(processed=True) + + messages.success(request, 'Registration Invitation sent') + return redirect(reverse('scipost:registration_invitations')) + else: + mail_request.add_form(form) + return mail_request.return_render() + context = { + 'form': form, + } + return render(request, 'scipost/registration_invitation_form.html', context) - Utils.load({'invitation': invitation}) - Utils.send_registration_invitation_email() - (DraftInvitation.objects.filter(email=reg_inv_form.cleaned_data['email']) - .update(processed=True)) - messages.success(request, 'Registration Invitation sent') - return redirect(reverse('scipost:registration_invitations')) +@permission_required('scipost.can_invite_Fellows', return_403=True) +def registration_invitations(request): + """ Overview and tools for administrators """ + # List invitations sent; send new ones + # associated_contributors = None + # initial = {} + # draft = None + # if draft_id: + # # Fill draft data if draft_id given + # draft = get_object_or_404(DraftInvitation, id=draft_id) + # associated_contributors = Contributor.objects.filter( + # user__last_name__icontains=draft.last_name) + # initial = { + # 'title': draft.title, + # 'first_name': draft.first_name, + # 'last_name': draft.last_name, + # 'email': draft.email, + # 'invitation_type': draft.invitation_type, + # 'cited_in_submission': draft.cited_in_submission, + # 'cited_in_publication': draft.cited_in_publication, + # } + + # # Send invitation from form information + # reg_inv_form = RegistrationInvitationForm(request.POST or None, initial=initial, + # current_user=request.user) + # if reg_inv_form.is_valid(): + # if mail_request.is_valid(): + # # invitation.nr_reminders += 1 + # # invitation.date_last_reminded = timezone.now() + # # invitation.save() + # # invitation.refresh_keys() + # # messages.success(request, 'Registration invitation has been sent.') + # # mail_request.send() + # invitation = reg_inv_form.save(commit=False) + # invitation.invited_by = request.user.contributor + # invitation.save() + # invitation.refresh_keys() + # + # Utils.load({'invitation': invitation}) + # Utils.send_registration_invitation_email() + # (DraftInvitation.objects.filter(email=reg_inv_form.cleaned_data['email']) + # .update(processed=True)) + # + # messages.success(request, 'Registration Invitation sent') + # return redirect(reverse('scipost:registration_invitations')) + # else: + # return mail_request.return_render() sent_reg_inv = RegistrationInvitation.objects.filter(responded=False, declined=False) sent_reg_inv_fellows = sent_reg_inv.filter(invitation_type='F').order_by('last_name') @@ -498,10 +552,10 @@ def registration_invitations(request, draft_id=None): names_reg_contributors = Contributor.objects.filter( status=1).order_by('user__last_name').values_list( 'user__first_name', 'user__last_name') - existing_drafts = DraftInvitation.objects.filter(processed=False).order_by('last_name') + existing_drafts = DraftInvitation.objects.filter(processed=False).order_by('last_name', 'email') context = { - 'reg_inv_form': reg_inv_form, + # 'reg_inv_form': reg_inv_form, 'sent_reg_inv_fellows': sent_reg_inv_fellows, 'sent_reg_inv_contrib': sent_reg_inv_contrib, 'sent_reg_inv_ref': sent_reg_inv_ref, @@ -515,7 +569,7 @@ def registration_invitations(request, draft_id=None): 'decl_reg_inv': decl_reg_inv, 'names_reg_contributors': names_reg_contributors, 'existing_drafts': existing_drafts, - 'associated_contributors': associated_contributors, + # 'associated_contributors': associated_contributors, } return render(request, 'scipost/registration_invitations.html', context)