From 1a43a7aa1c24dc62752495a5d452c7161693c7a3 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sat, 26 Mar 2016 22:22:53 +0100
Subject: [PATCH] Invitation messages written, forms updated

---
 scipost/forms.py                              |  8 ++-
 scipost/models.py                             |  7 ++
 scipost/templates/scipost/personal_page.html  |  2 +-
 .../scipost/registration_invitations.html     | 67 ++++++++++---------
 scipost/utils.py                              | 38 +++++++++--
 5 files changed, 81 insertions(+), 41 deletions(-)

diff --git a/scipost/forms.py b/scipost/forms.py
index d97a7ae13..99d66613e 100644
--- a/scipost/forms.py
+++ b/scipost/forms.py
@@ -34,10 +34,16 @@ class RegistrationForm(forms.Form):
     captcha = CaptchaField(label='* I am not a robot')
 
 
+
 class RegistrationInvitationForm(forms.ModelForm):
     class Meta:
         model = RegistrationInvitation
-        fields = ['title', 'first_name', 'last_name', 'email_address', 'invitation_type']
+        fields = ['title', 'first_name', 'last_name', 'email_address', 'invitation_type', 'message_style', 'personal_message']
+
+    def __init__(self, *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.'})
+ 
 
 class UpdateUserDataForm(forms.ModelForm):
     class Meta:
diff --git a/scipost/models.py b/scipost/models.py
index 2343c113e..a13fea4b8 100644
--- a/scipost/models.py
+++ b/scipost/models.py
@@ -100,6 +100,11 @@ INVITATION_TYPE = (
     ('C', 'Contributor'),
     )
 
+INVITATION_STYLE = (
+    ('F', 'formal'),
+    ('P', 'personal'),
+    )
+
 class RegistrationInvitation(models.Model):
     """ 
     Invitation to particular persons for registration
@@ -109,6 +114,8 @@ class RegistrationInvitation(models.Model):
     last_name = models.CharField(max_length=30, default='')
     email_address = models.EmailField()
     invitation_type = models.CharField(max_length=2, choices=INVITATION_TYPE, default='C')
+    message_style = models.CharField(max_length=1, choices=INVITATION_STYLE, default='F')
+    personal_message = models.TextField(blank=True, null=True)
     invitation_key = models.CharField(max_length=40, default='')
     key_expires = models.DateTimeField(default=timezone.now)
     date_sent = models.DateTimeField(default=timezone.now)
diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html
index a2ff2f57c..ad938b91c 100644
--- a/scipost/templates/scipost/personal_page.html
+++ b/scipost/templates/scipost/personal_page.html
@@ -66,7 +66,7 @@
     <ul>
       <li><a href="{% url 'scipost:vet_registration_requests' %}">Vet Registration requests</a> ({{ nr_reg_to_vet }})</li>
       <li>Awaiting validation ({{ nr_reg_awaiting_validation }}) (no action necessary)</li>
-      <li><a href="{% url 'scipost:registration_invitations' %}">Manage Registration invitations</a></li>
+      <li><a href="{% url 'scipost:registration_invitations' %}">Manage Registration Invitations</a></li>
     </ul>
   </div>
   {% endif %}
diff --git a/scipost/templates/scipost/registration_invitations.html b/scipost/templates/scipost/registration_invitations.html
index 196e75e65..c4445ff75 100644
--- a/scipost/templates/scipost/registration_invitations.html
+++ b/scipost/templates/scipost/registration_invitations.html
@@ -8,9 +8,12 @@
   <div class="flex-greybox">
     <h1>Registration Invitations</h1>
   </div>
-
+</section>
+<hr class="hr12"/>
+<section>
   <div class="flex-greybox">
     <h2>Send a new invitation:</h2>
+  </div>
     <form action="{% url 'scipost:registration_invitations' %}" method="post">
       {% csrf_token %}
       <table>
@@ -18,40 +21,40 @@
       </table>
       <input type="submit" value="Submit" />
     </form>
-  </div>
-
+</section>
+<hr class="hr12"/>
+<section>
   <div class="flex-greybox">
     <h2>Invitations sent:</h2>
-
-    <h3>Editorial Fellows</h3>
-    <table>
-      <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type (Fellow, Contrib)</td><td>Responded</td></tr>
-      {% for fellow in sent_reg_inv_fellows %}
-      <tr>
-	<td>{{ fellow.last_name }}</td>
-	<td>{{ fellow.first_name }}</td>
-	<td>{{ fellow.email_address }}</td>
-	<td>{{ fellow.date_sent }} </td>
-	<td>{{ fellow.invitation_type }}</td>
-	<td>{{ fellow.responded }}</td></tr>
-      {% endfor %}
-    </table>
-
-    <h3>Normal Contributors</h3>
-    <table>
-      <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type (Fellow, Contrib)</td><td>Responded</td></tr>
-      {% for fellow in sent_reg_inv_contrib %}
-      <tr>
-	<td>{{ fellow.last_name }}</td>
-	<td>{{ fellow.first_name }}</td>
-	<td>{{ fellow.email_address }}</td>
-	<td>{{ fellow.date_sent }} </td>
-	<td>{{ fellow.invitation_type }}</td>
-	<td>{{ fellow.responded }}</td></tr>
-      {% endfor %}
-    </table>
-
   </div>
+  <h3>Editorial Fellows</h3>
+  <table class="tableofInvitees">
+    <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type (Fellow, Contrib)</td><td>Responded</td></tr>
+    {% for fellow in sent_reg_inv_fellows %}
+    <tr>
+      <td>{{ fellow.last_name }}</td>
+      <td>{{ fellow.first_name }}</td>
+      <td>{{ fellow.email_address }}</td>
+      <td>{{ fellow.date_sent }} </td>
+      <td>{{ fellow.invitation_type }}</td>
+      <td>{{ fellow.responded }}</td></tr>
+    {% endfor %}
+  </table>
+  
+  <h3>Normal Contributors</h3>
+  <table class="tableofInvitees">
+    <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type (Fellow, Contrib)</td><td>Responded</td></tr>
+    {% for fellow in sent_reg_inv_contrib %}
+    <tr>
+      <td>{{ fellow.last_name }}</td>
+      <td>{{ fellow.first_name }}</td>
+      <td>{{ fellow.email_address }}</td>
+      <td>{{ fellow.date_sent }} </td>
+      <td>{{ fellow.invitation_type }}</td>
+      <td>{{ fellow.responded }}</td></tr>
+    {% endfor %}
+  </table>
+
 </section>
 
 {% endblock bodysup %}
diff --git a/scipost/utils.py b/scipost/utils.py
index 40eeaaa38..016f43f8c 100644
--- a/scipost/utils.py
+++ b/scipost/utils.py
@@ -97,6 +97,8 @@ class Utils(object):
             last_name = cls.reg_inv_form.cleaned_data['last_name'],
             email_address = cls.reg_inv_form.cleaned_data['email_address'],
             invitation_type = cls.reg_inv_form.cleaned_data['invitation_type'],
+            message_style = cls.reg_inv_form.cleaned_data['message_style'],
+            personal_message = cls.reg_inv_form.cleaned_data['personal_message'],
             )
         Utils.load({'invitation': invitation})
 
@@ -113,13 +115,35 @@ class Utils(object):
         cls.invitation.key_expires = datetime.datetime.strftime(
             datetime.datetime.now() + datetime.timedelta(days=14), "%Y-%m-%d %H:%M:%S")
         cls.invitation.save()
-        email_text = ('Dear ' + title_dict[cls.invitation.title] + ' ' +
-                      cls.invitation.last_name +
-                      ', \n\nYou are invited to register to the SciPost publication portal.' +
-                      ' You can do this by visiting ' +
-                      'this link within the next 2 weeks: \n\n' + 'https://scipost.org/invitation/' +
-                      cls.invitation.invitation_key +
-                      '\n\nYour registration will thereafter be vetted. Many thanks for your interest.  \n\nThe SciPost Team.')
+        email_text = 'Dear '
+        if cls.invitation.message_style == 'F':
+            email_text += title_dict[cls.invitation.title] + ' ' + cls.invitation.last_name + ',\n\n'
+        else:
+            email_text += cls.invitation.first_name + ',\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' +
+                       '- 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')
+        if cls.invitation.invitation_type == 'F':
+            email_text += ('The portal has been intensively developed over the last few months. It is legally based on a not-for-profit Foundation and will perpetually operate as a non-commercial entity at the service of the academic sector. We are now entering the next phase in the implementation, which is to build up the community of professional academics who will help operate it.\n\n' +
+                           'To go straight to the point, on behalf of the Foundation, I hereby have the honour to invite you to become an Editorial Fellow and thus join the Editorial College of SciPost Physics.\n\n' +
+                           'Please note that only well-known and respected senior academics are being contacted. Academic reputation is the most important criterion guiding our considerations of who should belong to the Editorial College.\n\n' +
+                           'To help you in considering this, it’s perhaps best if you take the time to take a look at the website itself. At the moment, registration is by invitation only, and the site is temporarily stripped of content for non-registered users. You can personally register by visiting the following link within the next 2 weeks: \n\n' + 
+                           'https://scipost.org/invitation/' + cls.invitation.invitation_key + '\n\n' +
+                           'I will then activate your account, allowing you to directly see all the contents. Many details about the initiative can be found at scipost.org/about and at scipost.org/FAQ.\n\n' +
+                           'Since this initiative has no chance of success without the involvement of the people it’s meant to serve, we’d be very grateful if you gave due consideration to this offer. To make things clear, we would expect you to commit only 2-4 hours per month to help perform Editorial duties. The number of Editorial Fellows will be adapted in order to keep things this way. You could try it out for 6 months or a year and of course quit anytime if you felt that things weren’t to your taste. If you do develop sympathy for the initiative, we’d be even more grateful if you considered submitting a publication to one of the journals within the near future, in order to help establish their reputation.\n\n' +
+                           'I’ll be happy to provide you with more detail if you require. In view of our development plans, could I possibly ask you to react 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, please let me know.\n\n')
+        elif cls.invitation.invitation_type == 'C':
+            email_text += ('The portal has been intensively developed over the last few months. It is legally based on a not-for-profit Foundation and will perpetually operate as a non-commercial entity at the service of the academic sector. We are now entering the next phase in the implementation, which is to build up the community of professional academics who will hopefully make use of the portal in their daily activities.\n\n' +
+                           'It’s perhaps best if you take the time to take a look at the website itself. At the moment, registration is by invitation only, and the site is temporarily stripped of content for non-registered users. You can personally register by visiting the following link within the next 2 weeks: \n\n' +
+                           'https://scipost.org/invitation/' + cls.invitation.invitation_key + '\n\n' +
+                           'I will then activate your account, allowing you to directly see all the contents. Many details about the initiative can be found at scipost.org/about and at scipost.org/FAQ.\n\n' +
+                           '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---------------------------------------------')
+
         emailmessage = EmailMessage(
             'SciPost registration invitation', email_text, 'jscaux@scipost.org',
             [cls.invitation.email_address, 'registration@scipost.org'], reply_to=['registration@scipost.org'])
-- 
GitLab