From 57b4b1e788224918d947cc33b0cc78e5bbb114f2 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sun, 27 Mar 2016 11:52:25 +0200 Subject: [PATCH] Registration only by invitation; correct bug in authorship vetting --- scipost/models.py | 4 +- scipost/templates/scipost/register.html | 11 ++- .../scipost/registration_invitations.html | 26 +++--- .../scipost/vet_authorship_claims.html | 27 ++---- scipost/urls.py | 4 +- scipost/utils.py | 4 +- scipost/views.py | 93 +++++++++---------- 7 files changed, 78 insertions(+), 91 deletions(-) diff --git a/scipost/models.py b/scipost/models.py index 083017f00..ec91a8063 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -62,7 +62,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(Contributor, related_name='vetted_by') TO ACTIVATE + vetted_by = models.OneToOneField('self', blank=True, null=True) def __str__ (self): @@ -135,7 +135,7 @@ class AuthorshipClaim(models.Model): submission = models.ForeignKey('submissions.Submission', blank=True, null=True) commentary = models.ForeignKey('commentaries.Commentary', blank=True, null=True) thesislink = models.ForeignKey('theses.ThesisLink', blank=True, null=True) - vetted = models.BooleanField(default=False) +# vetted = models.BooleanField(default=False) vetted_by = models.ForeignKey (Contributor, blank=True, null=True) status = models.SmallIntegerField(choices=AUTHORSHIP_CLAIM_STATUS, default=0) diff --git a/scipost/templates/scipost/register.html b/scipost/templates/scipost/register.html index 7a14b25ae..975913639 100644 --- a/scipost/templates/scipost/register.html +++ b/scipost/templates/scipost/register.html @@ -6,11 +6,13 @@ <section> <h1>Register to SciPost</h1> - {% if welcome_message %} + + {% if welcome_message %}<!-- Temporary: only see form if invited (thus welcome_message exists) --> + <div class="flex-greybox"> <h2>{{ welcome_message }}</h2> </div> - {% endif %} + <div class="row"> <div class="col-4"> <h3>Notes:</h3> @@ -35,6 +37,11 @@ {% endif %} </div> </div> + + {% else %} <!-- Temporary: no welcome, registration not yet open --> + <p>At the moment, registration is by invitation only. Come back again after 1 May!</p> + {% endif %} + </section> {% endblock bodysup %} diff --git a/scipost/templates/scipost/registration_invitations.html b/scipost/templates/scipost/registration_invitations.html index d01f13ad7..edb5ff3c4 100644 --- a/scipost/templates/scipost/registration_invitations.html +++ b/scipost/templates/scipost/registration_invitations.html @@ -25,9 +25,10 @@ <div class="flex-greybox"> <h2>Invitations sent (response pending):</h2> </div> - <h3>Editorial Fellows</h3> + <hr class="hr6"/> + <h3>Editorial Fellows ({{ nr_sent_reg_inv_fellows }})</h3> <table class="tableofInvitees"> - <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td><td>Responded</td></tr> + <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td></tr> {% for fellow in sent_reg_inv_fellows %} <tr> <td>{{ fellow.last_name }}</td> @@ -36,13 +37,13 @@ <td>{{ fellow.date_sent }} </td> <td>{{ fellow.invitation_type }}</td> <td>{{ fellow.invited_by.user.last_name }}</td> - <td>{{ fellow.responded }}</td></tr> + </tr> {% endfor %} </table> <hr class="hr6"/> - <h3>Normal Contributors</h3> + <h3>Normal Contributors ({{ nr_sent_reg_inv_contrib }})</h3> <table class="tableofInvitees"> - <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td><td>Responded</td></tr> + <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td></tr> {% for fellow in sent_reg_inv_contrib %} <tr> <td>{{ fellow.last_name }}</td> @@ -51,7 +52,7 @@ <td>{{ fellow.date_sent }} </td> <td>{{ fellow.invitation_type }}</td> <td>{{ fellow.invited_by.user.last_name }}</td> - <td>{{ fellow.responded }}</td></tr> + </tr> {% endfor %} </table> </section> @@ -60,9 +61,10 @@ <div class="flex-greybox"> <h2>Invitations sent (responded):</h2> </div> - <h3>Editorial Fellows</h3> + <hr class="hr6"/> + <h3>Editorial Fellows ({{ nr_resp_reg_inv_fellows }})</h3> <table class="tableofInvitees"> - <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td><td>Responded</td></tr> + <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td></tr> {% for fellow in resp_reg_inv_fellows %} <tr> <td>{{ fellow.last_name }}</td> @@ -71,13 +73,13 @@ <td>{{ fellow.date_sent }} </td> <td>{{ fellow.invitation_type }}</td> <td>{{ fellow.invited_by.user.last_name }}</td> - <td>{{ fellow.responded }}</td></tr> + </tr> {% endfor %} </table> <hr class="hr6"/> - <h3>Normal Contributors</h3> + <h3>Normal Contributors ({{ nr_resp_reg_inv_contrib}})</h3> <table class="tableofInvitees"> - <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td><td>Responded</td></tr> + <tr><td>Last name</td><td>First name</td><td>Email</td><td>Date sent</td><td>Type</td><td>Invited by</td></tr> {% for fellow in resp_reg_inv_contrib %} <tr> <td>{{ fellow.last_name }}</td> @@ -86,7 +88,7 @@ <td>{{ fellow.date_sent }} </td> <td>{{ fellow.invitation_type }}</td> <td>{{ fellow.invited_by.user.last_name }}</td> - <td>{{ fellow.responded }}</td></tr> + </tr> {% endfor %} </table> diff --git a/scipost/templates/scipost/vet_authorship_claims.html b/scipost/templates/scipost/vet_authorship_claims.html index f0de36185..b58b4b70c 100644 --- a/scipost/templates/scipost/vet_authorship_claims.html +++ b/scipost/templates/scipost/vet_authorship_claims.html @@ -15,48 +15,33 @@ {% if not claims_to_vet %} <h3>There are no authorship claims to vet</h3> {% else %} + <hr class="hr12"> <ul> {% for claim in claims_to_vet %} {% if claim.submission %} <h4>Contributor {{ claim.claimant.user.first_name }} {{ claim.claimant.user.last_name }} claims to be an author of Submission:</h4> {{ claim.submission.header_as_li | safe }} - <form action="{% url 'scipost:vet_sub_authorship_claim' submission_id=claim.submission.id claim=1%}" method="post"> - {% csrf_token %} - <input type="submit" value="Accept" /> - </form> - <form action="{% url 'scipost:vet_sub_authorship_claim' submission_id=claim.submission.id claim=0%}" method="post"> - {% csrf_token %} - <input type="submit" value="Deny" /> - </form> - {% elif claim.commentary %} <h4>Contributor {{ claim.claimant.user.first_name }} {{ claim.claimant.user.last_name }} claims to be an author of Submission:</h4> {{ claim.commentary.header_as_li | safe }} - <form action="{% url 'scipost:vet_com_authorship_claim' commentary_id=claim.commentary.id claim=1%}" method="post"> - {% csrf_token %} - <input type="submit" value="Accept" /> - </form> - <form action="{% url 'scipost:vet_com_authorship_claim' commentary_id=claim.commentary.id claim=0%}" method="post"> - {% csrf_token %} - <input type="submit" value="Deny" /> - </form> - {% elif claim.thesislink %} <h4>Contributor {{ claim.claimant.user.first_name }} {{ claim.claimant.user.last_name }} claims to be an author of Thesis:</h4> {{ claim.thesislink.header_as_li | safe }} - <form action="{% url 'scipost:vet_thesis_authorship_claim' thesis_id=claim.thesislink.id claim=1%}" method="post"> + {% endif %} + + <form action="{% url 'scipost:vet_authorship_claim' claim_id=claim.id claim=1%}" method="post"> {% csrf_token %} <input type="submit" value="Accept" /> </form> - <form action="{% url 'scipost:vet_thesis_authorship_claim' thesis_id=claim.thesislink.id claim=0%}" method="post"> + <form action="{% url 'scipost:vet_authorship_claim' claim_id=claim.id claim=0%}" method="post"> {% csrf_token %} <input type="submit" value="Deny" /> </form> - {% endif %} {% endfor %} </ul> {% endif %} + </section> {% endblock bodysup %} diff --git a/scipost/urls.py b/scipost/urls.py index dc8afb052..dd0f417e6 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -53,7 +53,5 @@ urlpatterns = [ url(r'^claim_com_authorship/(?P<commentary_id>[0-9]+)/(?P<claim>[0-1])$', views.claim_com_authorship, name='claim_com_authorship'), url(r'^claim_thesis_authorship/(?P<thesis_id>[0-9]+)/(?P<claim>[0-1])$', views.claim_thesis_authorship, name='claim_thesis_authorship'), url(r'^vet_authorship_claims$', views.vet_authorship_claims, name="vet_authorship_claims"), - url(r'^vet_sub_authorship_claim/(?P<submission_id>[0-9]+)/(?P<claim>[0-1])$', views.vet_sub_authorship_claim, name='vet_sub_authorship_claim'), - url(r'^vet_com_authorship_claim/(?P<commentary_id>[0-9]+)/(?P<claim>[0-1])$', views.vet_com_authorship_claim, name='vet_com_authorship_claim'), - url(r'^vet_thesis_authorship_claim/(?P<thesis_id>[0-9]+)/(?P<claim>[0-1])$', views.vet_thesis_authorship_claim, name='vet_thesis_authorship_claim'), + url(r'^vet_authorship_claim/(?P<claim_id>[0-9]+)/(?P<claim>[0-1])$', views.vet_authorship_claim, name='vet_authorship_claim'), ] diff --git a/scipost/utils.py b/scipost/utils.py index cdeee1f79..5e6fd5f46 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -121,7 +121,9 @@ class Utils(object): email_text += title_dict[cls.invitation.title] + ' ' + cls.invitation.last_name else: email_text += cls.invitation.first_name - email_text += ',\n\n' + cls.invitation.personal_message + '\n\n' + 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' + '- a means to comment on all existing literature\n\n' + '- a repository of links to theses (Habilitation, PhD, Master’s)\n\n' + diff --git a/scipost/views.py b/scipost/views.py index 0ec820022..9f3a1da83 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -12,6 +12,7 @@ from django.core.mail import EmailMessage from django.core.urlresolvers import reverse from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import redirect +from django.template import RequestContext from django.views.decorators.csrf import csrf_protect from django.db.models import Avg @@ -153,6 +154,7 @@ def vet_registration_request_ack(request, contributor_id): if form.is_valid(): if form.cleaned_data['promote_to_rank_1']: contributor.rank = 1 + contributor.vetted_by = request.user.contributor contributor.save() email_text = ('Dear ' + title_dict[contributor.title] + ' ' + contributor.user.last_name + ', \n\nYour registration to the SciPost publication portal has been accepted. ' + @@ -193,14 +195,18 @@ def registration_invitations(request): else: reg_inv_form = RegistrationInvitationForm() sent_reg_inv_fellows = RegistrationInvitation.objects.filter(invitation_type='F', responded=False).order_by('last_name') + nr_sent_reg_inv_fellows = sent_reg_inv_fellows.count() sent_reg_inv_contrib = RegistrationInvitation.objects.filter(invitation_type='C', responded=False).order_by('last_name') + nr_sent_reg_inv_contrib = sent_reg_inv_contrib.count() resp_reg_inv_fellows = RegistrationInvitation.objects.filter(invitation_type='F', responded=True).order_by('last_name') + nr_resp_reg_inv_fellows = resp_reg_inv_fellows.count() resp_reg_inv_contrib = RegistrationInvitation.objects.filter(invitation_type='C', responded=True).order_by('last_name') + nr_resp_reg_inv_contrib = resp_reg_inv_contrib.count() context = {'reg_inv_form': reg_inv_form, - 'sent_reg_inv_fellows': sent_reg_inv_fellows, - 'sent_reg_inv_contrib': sent_reg_inv_contrib, - 'resp_reg_inv_fellows': resp_reg_inv_fellows, - 'resp_reg_inv_contrib': resp_reg_inv_contrib} + 'sent_reg_inv_fellows': sent_reg_inv_fellows, 'nr_sent_reg_inv_fellows': nr_sent_reg_inv_fellows, + 'sent_reg_inv_contrib': sent_reg_inv_contrib, 'nr_sent_reg_inv_contrib': nr_sent_reg_inv_contrib, + 'resp_reg_inv_fellows': resp_reg_inv_fellows, 'nr_resp_reg_inv_fellows': nr_resp_reg_inv_fellows, + 'resp_reg_inv_contrib': resp_reg_inv_contrib, 'nr_resp_reg_inv_contrib': nr_resp_reg_inv_contrib } return render(request, 'scipost/registration_invitations.html', context) @@ -435,57 +441,44 @@ def claim_thesis_authorship(request, thesis_id, claim): def vet_authorship_claims(request): - contributor = Contributor.objects.get(user=request.user) claims_to_vet = AuthorshipClaim.objects.filter(status='0') context = {'claims_to_vet': claims_to_vet} return render(request, 'scipost/vet_authorship_claims.html', context) - -def vet_sub_authorship_claim(request, submission_id, claim): - if request.method == 'POST': - contributor = Contributor.objects.get(user=request.user) - submission = Submission.objects.get(pk=submission_id) - submission.authors_claims.remove(contributor) - claim_to_vet = AuthorshipClaim.objects.get(claimant=contributor, submission=submission) - if claim == '1': - submission.authors.add(contributor) - claim_to_vet.status = '1' - elif claim == '0': - submission.authors_false_claims.add(contributor) - claim_to_vet.status = '-1' - submission.save() - claim_to_vet.save() - return redirect('scipost:vet_authorship_claims') - - -def vet_com_authorship_claim(request, commentary_id, claim): +def vet_authorship_claim(request, claim_id, claim): if request.method == 'POST': - contributor = Contributor.objects.get(user=request.user) - commentary = Commentary.objects.get(pk=commentary_id) - commentary.authors_claims.remove(contributor) - claim_to_vet = AuthorshipClaim.objects.get(claimant=contributor, commentary=commentary) - if claim == '1': - commentary.authors.add(contributor) - elif claim == '0': - commentary.authors_false_claims.add(contributor) - claim_to_vet.status = claim - commentary.save() - claim_to_vet.save() - return redirect('scipost:vet_authorship_claims') - - -def vet_thesis_authorship_claim(request, thesis_id, claim): - if request.method == 'POST': - contributor = Contributor.objects.get(user=request.user) - thesislink = ThesisLink.objects.get(pk=thesis_id) - thesislink.author_claims.remove(contributor) - claim_to_vet = AuthorshipClaim.objects.get(claimant=contributor, thesislink=thesislink) - if claim == '1': - thesislink.author_as_cont.add(contributor) - elif claim == '0': - thesislink.author_false_claims.add(contributor) - claim_to_vet.status = claim - thesislink.save() + vetting_contributor = Contributor.objects.get(user=request.user) + claim_to_vet = AuthorshipClaim.objects.get(pk=claim_id) + + if claim_to_vet.submission is not None: + claim_to_vet.submission.authors_claims.remove(claim_to_vet.claimant) + if claim == '1': + claim_to_vet.submission.authors.add(claim_to_vet.claimant) + claim_to_vet.status = '1' + elif claim == '0': + claim_to_vet.submission.authors_false_claims.add(claim_to_vet.claimant) + claim_to_vet.status = '-1' + claim_to_vet.submission.save() + if claim_to_vet.commentary is not None: + claim_to_vet.commentary.authors_claims.remove(claim_to_vet.claimant) + if claim == '1': + claim_to_vet.commentary.authors.add(claim_to_vet.claimant) + claim_to_vet.status = '1' + elif claim == '0': + claim_to_vet.commentary.authors_false_claims.add(claim_to_vet.claimant) + claim_to_vet.status = '-1' + claim_to_vet.commentary.save() + if claim_to_vet.thesislink is not None: + claim_to_vet.thesislink.author_claims.remove(claim_to_vet.claimant) + if claim == '1': + claim_to_vet.thesislink.author_as_cont.add(claim_to_vet.claimant) + claim_to_vet.status = '1' + elif claim == '0': + claim_to_vet.thesislink.author_false_claims.add(claim_to_vet.claimant) + claim_to_vet.status = '-1' + claim_to_vet.thesislink.save() + + claim_to_vet.vetted_by = vetting_contributor claim_to_vet.save() return redirect('scipost:vet_authorship_claims') -- GitLab