From 89cc34afd044df4b3d9ae04824a3820a704af47a Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sun, 10 Sep 2017 15:45:02 +0200 Subject: [PATCH] Major work on deposits and further general metadata --- .../0020_comment_doideposit_needs_updating.py | 20 +++++++++++ comments/models.py | 5 +-- ...4_publication_doideposit_needs_updating.py | 20 +++++++++++ journals/models.py | 1 + .../journals/manage_comment_metadata.html | 2 ++ .../templates/journals/manage_metadata.html | 10 +++--- .../journals/manage_report_metadata.html | 2 ++ .../journals/sign_existing_report.html | 33 +++++++++++++++++++ journals/urls/general.py | 3 ++ journals/views.py | 28 ++++++++++++++++ scipost/forms.py | 28 ++++++++++++++++ scipost/templates/scipost/personal_page.html | 6 +++- scipost/views.py | 2 ++ .../0069_report_doideposit_needs_updating.py | 20 +++++++++++ submissions/models.py | 1 + 15 files changed, 174 insertions(+), 7 deletions(-) create mode 100644 comments/migrations/0020_comment_doideposit_needs_updating.py create mode 100644 journals/migrations/0044_publication_doideposit_needs_updating.py create mode 100644 journals/templates/journals/sign_existing_report.html create mode 100644 submissions/migrations/0069_report_doideposit_needs_updating.py diff --git a/comments/migrations/0020_comment_doideposit_needs_updating.py b/comments/migrations/0020_comment_doideposit_needs_updating.py new file mode 100644 index 000000000..1adcc31e7 --- /dev/null +++ b/comments/migrations/0020_comment_doideposit_needs_updating.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-10 12:17 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comments', '0019_auto_20170909_1649'), + ] + + operations = [ + migrations.AddField( + model_name='comment', + name='doideposit_needs_updating', + field=models.BooleanField(default=False), + ), + ] diff --git a/comments/models.py b/comments/models.py index 06225901f..5410c48ff 100644 --- a/comments/models.py +++ b/comments/models.py @@ -38,8 +38,6 @@ class Comment(TimeStampedModel): content_object = GenericForeignKey() nested_comments = GenericRelation('comments.Comment', related_query_name='comments') - genericdoideposit = GenericRelation('journals.GenericDOIDeposit', - related_query_name='genericdoideposit') # -- U/S # These fields will be removed in the future. @@ -90,6 +88,9 @@ class Comment(TimeStampedModel): blank=True) needs_doi = models.NullBooleanField(default=None) + doideposit_needs_updating = models.BooleanField(default=False) + genericdoideposit = GenericRelation('journals.GenericDOIDeposit', + related_query_name='genericdoideposit') doi_label = models.CharField(max_length=200, blank=True) objects = CommentQuerySet.as_manager() diff --git a/journals/migrations/0044_publication_doideposit_needs_updating.py b/journals/migrations/0044_publication_doideposit_needs_updating.py new file mode 100644 index 000000000..e602a8820 --- /dev/null +++ b/journals/migrations/0044_publication_doideposit_needs_updating.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-10 12:54 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0043_auto_20170909_1649'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='doideposit_needs_updating', + field=models.BooleanField(default=False), + ), + ] diff --git a/journals/models.py b/journals/models.py index 0adcaf9eb..4dc87d398 100644 --- a/journals/models.py +++ b/journals/models.py @@ -155,6 +155,7 @@ class Publication(models.Model): BiBTeX_entry = models.TextField(blank=True, null=True) doi_label = models.CharField(max_length=200, unique=True, db_index=True, validators=[doi_publication_validator]) + doideposit_needs_updating = models.BooleanField(default=False) submission_date = models.DateField(verbose_name='submission date') acceptance_date = models.DateField(verbose_name='acceptance date') publication_date = models.DateField(verbose_name='publication date') diff --git a/journals/templates/journals/manage_comment_metadata.html b/journals/templates/journals/manage_comment_metadata.html index aebd9cbcd..efd231d30 100644 --- a/journals/templates/journals/manage_comment_metadata.html +++ b/journals/templates/journals/manage_comment_metadata.html @@ -28,6 +28,7 @@ event: "focusin" <th>Comment</th> <th>Needs doi</th> <th>Latest successful Crossref deposit</th> + <th>Deposit needs updating?</th> </tr> </thead> @@ -37,6 +38,7 @@ event: "focusin" <td>{{ comment }}</td> <td>{{ comment.needs_doi }}</td> <td>{{ comment|latest_successful_crossref_deposit_comment }}</td> + <td>{{ comment.doideposit_needs_updating }}</td> </tr> <tr id="collapse{{ comment.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ comment.id }}" style="background-color: #fff;"> <td colspan="5"> diff --git a/journals/templates/journals/manage_metadata.html b/journals/templates/journals/manage_metadata.html index 7025abe27..56f960111 100644 --- a/journals/templates/journals/manage_metadata.html +++ b/journals/templates/journals/manage_metadata.html @@ -46,6 +46,7 @@ event: "focusin" <th>Publication date</th> <th>Latest metadata update</th> <th>Latest successful Crossref deposit</th> + <th>Deposit needs updating?</th> <th>DOAJ</th> </tr> </thead> @@ -63,10 +64,11 @@ event: "focusin" <td>No info available</td> {% endif %} <td>{{ publication|latest_successful_crossref_deposit }}</td> + <td>{{ publication.doideposit_needs_updating }}</td> <td>{{ publication|latest_successful_DOAJ_deposit }}</td> </tr> <tr id="collapse{{ publication.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ publication.id }}" style="background-color: #fff;"> - <td colspan="5"> + <td colspan="6"> <h2 class="ml-3">Actions</h2> <div class="row"> @@ -174,7 +176,7 @@ event: "focusin" </tr> {% empty %} <tr> - <td colspan="5">No Deposits found for this publication</td> + <td colspan="6">No Deposits found for this publication</td> </tr> {% endfor %} </tbody> @@ -203,7 +205,7 @@ event: "focusin" </tr> {% empty %} <tr> - <td colspan="4">No Deposits found for this publication</td> + <td colspan="6">No Deposits found for this publication</td> </tr> {% endfor %} </tbody> @@ -213,7 +215,7 @@ event: "focusin" </tr> {% empty %} <tr> - <td colspan="4">No publications found.</td> + <td colspan="6">No publications found.</td> </tr> {% endfor %} </tbody> diff --git a/journals/templates/journals/manage_report_metadata.html b/journals/templates/journals/manage_report_metadata.html index 16fc0d726..cd2dce24d 100644 --- a/journals/templates/journals/manage_report_metadata.html +++ b/journals/templates/journals/manage_report_metadata.html @@ -29,6 +29,7 @@ event: "focusin" <th>Report nr</th> <th>Needs doi</th> <th>Latest successful Crossref deposit</th> + <th>Deposit needs updating?</th> </tr> </thead> @@ -39,6 +40,7 @@ event: "focusin" <td>{{ report.report_nr }}</td> <td>{{ report.needs_doi }}</td> <td>{{ report|latest_successful_crossref_deposit_report }}</td> + <td>{{ report.doideposit_needs_updating }}</td> </tr> <tr id="collapse{{ report.id }}" class="collapse" role="tabpanel" aria-labelledby="heading{{ report.id }}" style="background-color: #fff;"> <td colspan="5"> diff --git a/journals/templates/journals/sign_existing_report.html b/journals/templates/journals/sign_existing_report.html new file mode 100644 index 000000000..99b8db35f --- /dev/null +++ b/journals/templates/journals/sign_existing_report.html @@ -0,0 +1,33 @@ +{% extends 'scipost/base.html' %} + +{% load bootstrap %} + +{% block pagetitle %}: sign existing Report{% endblock pagetitle %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <hr class="hr12"> + <div class="row"> + <div class="col-6"> + <h2>Confirmation page: do you wish to sign this Report?</h2> + <h3>(your Report is reproduced below for your convenience)</h3> + </div> + <div class="col-6"> + <form action="{% url 'journals:sign_existing_report' report_id=report.id %}" method="post"> + {% csrf_token %} + {{ form|bootstrap }} + <input class="btn btn-secondary" type="submit" value="Submit" /> + </form> + </div> + </div> + + <h3>Report on Submission <a href="{{report.submission.get_absolute_url}}">{{report.submission.title}}</a></h3> + + {% include 'submissions/_single_public_report_without_comments.html' with report=report user=request.user perms=perms %} + + </div> +</div> + +{% endblock %} diff --git a/journals/urls/general.py b/journals/urls/general.py index 163b3735f..5570b6627 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -86,6 +86,9 @@ urlpatterns = [ url(r'^harvest_citedby_links/(?P<doi_label>[a-zA-Z]+.[0-9]+.[0-9]+.[0-9]{3,})$', journals_views.harvest_citedby_links, name='harvest_citedby_links'), + url(r'^sign_existing_report/(?P<report_id>[0-9]+)$', + journals_views.sign_existing_report, + name='sign_existing_report'), url(r'^manage_report_metadata/$', journals_views.manage_report_metadata, name='manage_report_metadata'), diff --git a/journals/views.py b/journals/views.py index 323702d05..fb5245c31 100644 --- a/journals/views.py +++ b/journals/views.py @@ -6,6 +6,7 @@ import requests import string import xml.etree.ElementTree as ET +from django.contrib.auth.decorators import login_required from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.core.files.base import ContentFile @@ -31,6 +32,7 @@ from submissions.models import Submission, Report from scipost.models import Contributor from funders.forms import FunderSelectForm, GrantSelectForm +from scipost.forms import ConfirmationForm from guardian.decorators import permission_required @@ -937,6 +939,30 @@ def harvest_citedby_links(request, doi_label): return render(request, 'journals/harvest_citedby_links.html', context) +@login_required +def sign_existing_report(request, report_id): + """ + Allows the author of a Report, originally submitted anonymously, + to sign the Report. + """ + report = get_object_or_404(Report, pk=report_id) + if report.author != request.user.contributor: + errormessage = 'Only the author of this Report can change its anonymity status' + return render(request, 'scipost/error.html', context={'errormessage': errormessage}) + form = ConfirmationForm(request.POST or None) + if form.is_valid(): + if form.cleaned_data['confirm'] == 'True': + report.anonymous = False + report.doideposit_needs_updating = True + report.save() + messages.success(request, 'Your Report is now publicly signed.') + else: + messages.error(request, 'Report signing operation cancelled.') + return redirect(reverse('scipost:personal_page')) + context = {'report': report, 'form': form} + return render(request, 'journals/sign_existing_report.html', context) + + @permission_required('scipost.can_publish_accepted_submission', return_403=True) def manage_report_metadata(request): """ @@ -1073,6 +1099,8 @@ def mark_generic_deposit_success(request, deposit_id, success): deposit = get_object_or_404(GenericDOIDeposit, pk=deposit_id) if success == '1': deposit.deposit_successful = True + deposit.content_object.doideposit_needs_updating = False + deposit.content_object.save() elif success == '0': deposit.deposit_successful = False deposit.save() diff --git a/scipost/forms.py b/scipost/forms.py index 4c6ce047b..c3a5ceea7 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -25,7 +25,10 @@ from .models import Contributor, DraftInvitation, RegistrationInvitation,\ from common.forms import MonthYearWidget from partners.decorators import has_contact + +from comments.models import Comment from journals.models import Publication +from submissions.models import Report REGISTRATION_REFUSAL_CHOICES = ( @@ -287,6 +290,26 @@ class UpdatePersonalDataForm(forms.ModelForm): # for _list in original_lists: # _list.update_membership([contributor], status='unsubscribed') + def propagate_orcid(self): + """ + This method is called if a Contributor updates his/her personal data, + and changes the orcid_id. It marks all Publications, Reports and Comments + authors by this Contributor with a deposit_requires_update == True. + """ + publications = Publication.objects.filter(authors__in=self.instance) + for publication in publications: + publication.doideposit_needs_updating = True + publication.save() + reports = Report.objects.filter(author=self.instance, anonymous=False) + for report in reports: + report.doideposit_needs_updating = True + report.save() + comments = Comment.objects.filter(author=contributor, anonymous=False) + for comment in comments: + comment.doideposit_needs_updating = True + comment.save() + return + class VetRegistrationForm(forms.Form): decision = forms.ChoiceField(widget=forms.RadioSelect, @@ -500,3 +523,8 @@ class SendPrecookedEmailForm(forms.Form): required=False, initial=False, label='Include SciPost summary at end of message') from_address = forms.ChoiceField(choices=SCIPOST_FROM_ADDRESSES) + + +class ConfirmationForm(forms.Form): + confirm = forms.ChoiceField(widget=forms.RadioSelect, + choices=((True, 'Confirm'), (False, 'Abort'))) diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index d8d69f94a..b75cd60e2 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -444,8 +444,12 @@ <tr> <th>Status:</th><td {% if report.status == 'vetted' %}class="text-success"{% elif report.status == 'unvetted' %}class="text-danger"{% endif %}>{{report.get_status_display}}</td> </tr> + {% if report.doi_label %} + <tr> + <th>DOI:</th><td>{{ report.doi_string }}</td></th> +{% endif %} <tr> - <th>Anonymous:</th><td>{{report.anonymous|yesno:'Yes,No'}}</td> + <th>Anonymous:</th><td>{{report.anonymous|yesno:'Yes,No'}}</td>{% if report.anonymous %}<td>You can <a href="{% url 'journals:sign_existing_report' report_id=report.id %}">click here to sign this Report</a> (leads to confirmation page){% endif %}</td> </tr> </table> </div> diff --git a/scipost/views.py b/scipost/views.py index b2a048269..30d8031d0 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -871,6 +871,8 @@ def _update_personal_data_contributor(request): user_form.save() cont_form.save() cont_form.sync_lists() + if 'orcid_id' in cont_form.changed_data: + cont_form.propagate_orcid() messages.success(request, 'Your personal data has been updated.') return redirect(reverse('scipost:personal_page')) else: diff --git a/submissions/migrations/0069_report_doideposit_needs_updating.py b/submissions/migrations/0069_report_doideposit_needs_updating.py new file mode 100644 index 000000000..9d6b98779 --- /dev/null +++ b/submissions/migrations/0069_report_doideposit_needs_updating.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-10 12:15 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0068_auto_20170909_1649'), + ] + + operations = [ + migrations.AddField( + model_name='report', + name='doideposit_needs_updating', + field=models.BooleanField(default=False), + ), + ] diff --git a/submissions/models.py b/submissions/models.py index d5660b121..65896271e 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -385,6 +385,7 @@ class Report(SubmissionRelatedObjectMixin, models.Model): remarks_for_editors = models.TextField(blank=True, verbose_name='optional remarks for the Editors only') needs_doi = models.NullBooleanField(default=None) + doideposit_needs_updating = models.BooleanField(default=False) genericdoideposit = GenericRelation('journals.GenericDOIDeposit', related_query_name='genericdoideposit') doi_label = models.CharField(max_length=200, blank=True) -- GitLab