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 0000000000000000000000000000000000000000..1adcc31e75acd94e91bf853495e6df830f122894 --- /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 06225901ff8030dadb2293710432eae288b6d146..5410c48ffe73fc3ae9b174b69216fc497bb964e3 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 0000000000000000000000000000000000000000..e602a8820bb05d3eec81c5264b1b3af105d7269e --- /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 0adcaf9eb6fa054bde303b5f11348c022551f8bf..4dc87d39843fc4957040606eb819aaf8259f3712 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 aebd9cbcd8a5f82a50d751837c9ed48511775c57..efd231d30dac48b5caf5cf6addf0c04f7f0663c8 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 7025abe2757158aeed4e78e5dce2144ecc013401..56f960111f3f71caae0111c8e6ca43e3a8150e75 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 16fc0d726a9ca9e3a15bb4b682140828225ae015..cd2dce24d5ebcee24ff2c2c2860dec19c8319f3e 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 0000000000000000000000000000000000000000..99b8db35f47f12abc642bc14ddad4f0b96eb5a78 --- /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 163b3735fef156fa6a8c08288c0441d43fc2c81b..5570b662718dd4458c5d43ddd33f02efb8df178d 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 323702d0592277e74ecd59fc40f8c704d30612df..fb5245c315d70fd7a832e0720739ad1e19e835fc 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 4c6ce047b4f09de5e982a8ec2c4560dfc9528be7..c3a5ceea75ce50d9c58cb9ca80e8114363611c3f 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 d8d69f94ae67efdf2fa37ea723c017914d997132..b75cd60e232620161adbf8608c10400fdadfca47 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 b2a04826966cf778595b70b0fb5fed260f9ead1b..30d8031d02e0457ad6bd781490dc0aa8009e4ec6 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 0000000000000000000000000000000000000000..9d6b987794cae2f9ab974268211092cbefe438b8 --- /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 d5660b121db8bc165fb883d2ead4f648dee62649..65896271ea5b02c93bb43f65b0508f129c934139 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)