diff --git a/submissions/forms.py b/submissions/forms.py index f6374b473b953a6dd53b3c0ea72183617fb1039a..511522b0646ba71a98a5aaa1fb45ff7467fa8487 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -20,8 +20,7 @@ from .constants import ( STATUS_DRAFT, STATUS_UNVETTED, REPORT_ACTION_ACCEPT, REPORT_ACTION_REFUSE, STATUS_UNASSIGNED, EXPLICIT_REGEX_MANUSCRIPT_CONSTRAINTS, SUBMISSION_STATUS, PUT_TO_VOTING, CYCLE_UNDETERMINED, SUBMISSION_CYCLE_CHOICES, - REPORT_PUBLISH_1, REPORT_PUBLISH_2, REPORT_PUBLISH_3, - REPORT_MINOR_REV, REPORT_MAJOR_REV, REPORT_REJECT, + EIC_REC_PUBLISH, EIC_REC_MINOR_REVISION, EIC_REC_MAJOR_REVISION, EIC_REC_REJECT, ALT_REC_CHOICES, SUBMISSION_TIERS, STATUS_VETTED, DECISION_FIXED, DEPRECATED, STATUS_COMPLETED, STATUS_EIC_ASSIGNED, CYCLE_DEFAULT, CYCLE_DIRECT_REC, STATUS_PREASSIGNED, STATUS_REPLACED, @@ -31,7 +30,7 @@ from . import exceptions, helpers from .helpers import to_ascii_only from .models import ( Submission, RefereeInvitation, Report, EICRecommendation, EditorialAssignment, - EditorialDecision, + SubmissionTiering, EditorialDecision, iThenticateReport, EditorialCommunication) from .signals import notify_manuscript_accepted @@ -1227,11 +1226,17 @@ class EICRecommendationForm(forms.ModelForm): assignment = None earlier_recommendations = [] + tier = forms.ChoiceField( + widget=forms.RadioSelect, + choices=SUBMISSION_TIERS, + required=False) + class Meta: model = EICRecommendation fields = [ 'for_journal', 'recommendation', + 'tier', 'remarks_for_authors', 'requested_changes', 'remarks_for_editorial_college' @@ -1300,12 +1305,17 @@ class EICRecommendationForm(forms.ModelForm): recommendation.voting_deadline += datetime.timedelta(days=self.DAYS_TO_VOTE) # Test this recommendation.version = len(self.earlier_recommendations) + 1 + # Delete any previous tierings (irrespective of new/updated recommendation): + SubmissionTiering.objects.filter( + submission=self.submission, + fellow=self.submission.editor_in_charge).delete() + if self.reformulate: event_text = 'The Editorial Recommendation has been reformulated for Journal {}: {}.' else: event_text = 'An Editorial Recommendation has been formulated for Journal {}: {}.' - if recommendation.recommendation in [REPORT_MINOR_REV, REPORT_MAJOR_REV]: + if recommendation.recommendation in [EIC_REC_MINOR_REVISION, EIC_REC_MAJOR_REVISION]: # Minor/Major revision: return to Author; ask to resubmit recommendation.status = DECISION_FIXED Submission.objects.filter(id=self.submission.id).update( @@ -1323,6 +1333,15 @@ class EICRecommendationForm(forms.ModelForm): str(recommendation.for_journal), recommendation.get_recommendation_display())) else: + # if rec is to publish, specify the tiering (deleting old ones first): + if recommendation.recommendation == EIC_REC_PUBLISH: + tiering = SubmissionTiering( + submission=self.submission, + fellow=self.submission.editor_in_charge, + for_journal=recommendation.for_journal, + tier=self.cleaned_data['tier']) + tiering.save() + # Add SubmissionEvent for EIC only self.submission.add_event_for_eic(event_text.format( str(recommendation.for_journal), @@ -1341,7 +1360,7 @@ class EICRecommendationForm(forms.ModelForm): return recommendation def revision_requested(self): - return self.instance.recommendation in [REPORT_MINOR_REV, REPORT_MAJOR_REV] + return self.instance.recommendation in [EIC_REC_MINOR_REVISION, EIC_REC_MAJOR_REVISION] def has_assignment(self): return self.assignment is not None @@ -1582,96 +1601,3 @@ class iThenticateReportForm(forms.ModelForm): self.add_error(None, msg) return None return data - - -# class FixCollegeDecisionForm(forms.ModelForm): -# """Fix EICRecommendation decision.""" - -# FIX, DEPRECATE = 'fix', 'deprecate' -# action = forms.ChoiceField(choices=((FIX, FIX), (DEPRECATE, DEPRECATE))) - -# class Meta: -# model = EICRecommendation -# fields = () - -# def __init__(self, *args, **kwargs): -# """Accept request as argument.""" -# self.submission = kwargs.pop('submission', None) -# self.request = kwargs.pop('request', None) -# return super().__init__(*args, **kwargs) - -# def clean(self): -# """Check if EICRecommendation has the right decision.""" -# data = super().clean() -# if self.instance.status == DECISION_FIXED: -# self.add_error(None, 'This EICRecommendation is already fixed.') -# elif self.instance.status == DEPRECATED: -# self.add_error(None, 'This EICRecommendation is deprecated.') -# return data - -# def is_fixed(self): -# """Check if decision is fixed.""" -# return self.cleaned_data['action'] == self.FIX - -# def fix_decision(self, recommendation): -# """Fix decision of EICRecommendation.""" -# EICRecommendation.objects.filter(id=recommendation.id).update( -# status=DECISION_FIXED) -# submission = recommendation.submission -# if recommendation.recommendation in [REPORT_PUBLISH_1, REPORT_PUBLISH_2, REPORT_PUBLISH_3]: -# # Publish as Tier I, II or III -# Submission.objects.filter(id=submission.id).update( -# visible_public=True, status=STATUS_ACCEPTED, acceptance_date=datetime.date.today(), -# latest_activity=timezone.now()) - -# # Start a new ProductionStream -# get_or_create_production_stream(submission) - -# if self.request: -# # Add SubmissionEvent for authors -# notify_manuscript_accepted(self.request.user, submission, False) -# elif recommendation.recommendation == REPORT_REJECT: -# # Decision: Rejection. Auto hide from public and Pool. -# Submission.objects.filter(id=submission.id).update( -# visible_public=False, visible_pool=False, -# status=STATUS_REJECTED, latest_activity=timezone.now()) -# submission.get_other_versions().update(visible_public=False) - -# # Force-close the refereeing round for new referees. -# Submission.objects.filter(id=submission.id).update( -# open_for_reporting=False, -# open_for_commenting=False) - -# # Update Editorial Assignment statuses. -# EditorialAssignment.objects.filter( -# submission=submission, to=submission.editor_in_charge).update(status=STATUS_COMPLETED) - -# # Add SubmissionEvent for authors -# submission.add_event_for_author( -# 'The Editorial Recommendation has been formulated: {0}.'.format( -# recommendation.get_recommendation_display())) -# submission.add_event_for_eic( -# 'The Editorial Recommendation has been fixed: {0}.'.format( -# recommendation.get_recommendation_display())) -# return recommendation - -# def deprecate_decision(self, recommendation): -# """Deprecate decision of EICRecommendation.""" -# EICRecommendation.objects.filter(id=recommendation.id).update( -# status=DEPRECATED, active=False) -# recommendation.submission.add_event_for_eic( -# 'The Editorial Recommendation (version {version}) has been deprecated: {decision}.'.format( -# version=recommendation.version, -# decision=recommendation.get_recommendation_display())) - -# return recommendation - -# def save(self): -# """Update EICRecommendation and related Submission.""" -# if self.is_fixed(): -# return self.fix_decision(self.instance) -# elif self.cleaned_data['action'] == self.DEPRECATE: -# return self.deprecate_decision(self.instance) -# else: -# raise ValueError('The decision given is invalid') -# return self.instance diff --git a/submissions/templates/submissions/pool/recommendation_formulate.html b/submissions/templates/submissions/pool/recommendation_formulate.html index d2c71282a741529824256564f66b77e8bb1a3403..31e49858ecc47ed2558da4c4dde697e9eed7e9ac 100644 --- a/submissions/templates/submissions/pool/recommendation_formulate.html +++ b/submissions/templates/submissions/pool/recommendation_formulate.html @@ -49,3 +49,23 @@ {% endblock content %} + + +{% block footer_script %} + <script nonce="{{ request.csp_nonce }}"> + $(document).ready(function(){ + $("input[name=tier]").parents('.form-group').hide() + $('select[name=recommendation]').on('change', function(){ + var rec = $('select[name=recommendation]').val(); + switch(rec){ + case "1": + $("input[name=tier]").parents('.form-group').show() + break; + default: + $("input[name=tier]").parents('.form-group').hide() + break; + } + }).trigger('change'); + }); + </script> +{% endblock %} diff --git a/submissions/templates/submissions/pool/recommendation_formulate_rewrite.html b/submissions/templates/submissions/pool/recommendation_formulate_rewrite.html index aa514b8f4ea33cbbf1112cb1312e76eba45eafd4..e74270c29c75100a9143dda5d210f78a7470fc23 100644 --- a/submissions/templates/submissions/pool/recommendation_formulate_rewrite.html +++ b/submissions/templates/submissions/pool/recommendation_formulate_rewrite.html @@ -53,3 +53,24 @@ {% endblock content %} + + + +{% block footer_script %} + <script nonce="{{ request.csp_nonce }}"> + $(document).ready(function(){ + $("input[name=tier]").parents('.form-group').hide() + $('select[name=recommendation]').on('change', function(){ + var rec = $('select[name=recommendation]').val(); + switch(rec){ + case "1": + $("input[name=tier]").parents('.form-group').show() + break; + default: + $("input[name=tier]").parents('.form-group').hide() + break; + } + }).trigger('change'); + }); + </script> +{% endblock %} diff --git a/submissions/urls.py b/submissions/urls.py index e6bf6e8db89bfd88f9671f01f1389f1ce51683d3..d89eba5d652eaa1483337af987e4608cd359f4a9 100644 --- a/submissions/urls.py +++ b/submissions/urls.py @@ -63,12 +63,11 @@ urlpatterns = [ views.PlagiarismView.as_view(), name='plagiarism'), url(r'^admin/{regex}/plagiarism/report$'.format(regex=SUBMISSIONS_COMPLETE_REGEX), views.PlagiarismReportPDFView.as_view(), name='plagiarism_report'), - # url(r'^admin/{regex}/recommendations/(?P<rec_id>[0-9]+)$'.format( - # regex=SUBMISSIONS_COMPLETE_REGEX), views.EICRecommendationView.as_view(), - # name='eic_recommendation_detail'), - url(r'^admin/{regex}/recommendation$'.format( + url( + r'^admin/{regex}/recommendation$'.format( regex=SUBMISSIONS_COMPLETE_REGEX), views.EICRecommendationDetailView.as_view(), - name='eic_recommendation_detail'), + name='eic_recommendation_detail' + ), url( r'^admin/{regex}/editorial_decision/create$'.format( regex=SUBMISSIONS_COMPLETE_REGEX), diff --git a/submissions/views.py b/submissions/views.py index 453461c6df62c3c0d112936e6e47f9022f206be8..17c85ad40ae2ed68550b054d272017d0edcf0a0f 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -1918,59 +1918,11 @@ class SubmissionConflictsView(SubmissionAdminViewMixin, DetailView): success_url = reverse_lazy('submissions:pool') -# TO BE DEPRECATED, replaced by EICRecommendationDetailView -# class EICRecommendationView(SubmissionAdminViewMixin, UpdateView): -# """EICRecommendation detail view.""" - -# permission_required = 'scipost.can_fix_College_decision' -# template_name = 'submissions/pool/recommendation.html' -# editorial_page = True -# form_class = FixCollegeDecisionForm -# success_url = reverse_lazy('submissions:pool') - -# def get_object(self): -# """Get EICRecommendation.""" -# submission = super().get_object() -# return get_object_or_404( -# submission.eicrecommendations.put_to_voting(), id=self.kwargs['rec_id']) - -# def get_form_kwargs(self): -# """Form accepts request as argument.""" -# kwargs = super().get_form_kwargs() -# kwargs['request'] = self.request -# return kwargs - -# def get_context_data(self, *args, **kwargs): -# """Get the EICRecommendation as a submission-related instance.""" -# ctx = super().get_context_data(*args, **kwargs) -# ctx['recommendation'] = ctx['object'] -# return ctx - -# @transaction.atomic -# def form_valid(self, form): -# """Redirect and send out mails if decision is fixed.""" -# recommendation = form.save() -# if form.is_fixed(): -# submission = recommendation.submission - -# # Temporary: Update submission instance for utils email func. -# # Won't be needed in new mail construct. -# submission = Submission.objects.get(id=recommendation.submission.id) -# SubmissionUtils.load({'submission': submission, 'recommendation': recommendation}) -# SubmissionUtils.send_author_College_decision_email() -# messages.success(self.request, 'The Editorial College\'s decision has been fixed.') -# else: -# messages.success( -# self.request, 'The Editorial College\'s decision has been deprecated.') -# return HttpResponseRedirect(self.success_url) - - class EICRecommendationDetailView(SubmissionMixin, LoginRequiredMixin, UserPassesTestMixin, DetailView): """EICRecommendation detail page, visible to EdAdmin, voting Fellows (but NOT authors).""" model = EICRecommendation - # pk_url_kwarg = 'rec_id' template_name = 'submissions/pool/recommendation.html' context_object_name = 'recommendation' @@ -1986,21 +1938,6 @@ class EICRecommendationDetailView(SubmissionMixin, LoginRequiredMixin, return True return False - # def get(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().get(request, *args, **kwargs) - - # def post(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().post(request, *args, **kwargs) - - # def get_context_data(self, *args, **kwargs): - # context = super().get_context_data(*args, **kwargs) - # context['submission'] = self.submission - # return context - def get_object(self): """Return the latest version of the EICRecommendation associated to this Submission.""" return self.submission.eicrecommendations.last() @@ -2019,20 +1956,6 @@ class EditorialDecisionCreateView(SubmissionMixin, PermissionsMixin, CreateView) form_class = EditorialDecisionForm template_name = 'submissions/admin/editorial_decision_form.html' - # def get(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().get(request, *args, **kwargs) - - # def post(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().post(request, *args, **kwargs) - - # def get_context_data(self, *args, **kwargs): - # context = super().get_context_data(*args, **kwargs) - # context['submission'] = self.submission - # return context def get_initial(self, *args, **kwargs): initial = super().get_initial(*args, **kwargs) @@ -2074,21 +1997,6 @@ class EditorialDecisionUpdateView(SubmissionMixin, PermissionsMixin, UpdateView) form_class = EditorialDecisionForm template_name = 'submissions/admin/editorial_decision_form.html' - # def get(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().get(request, *args, **kwargs) - - # def post(self, request, *args, **kwargs): - # self.submission = get_object_or_404( - # Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) - # return super().post(request, *args, **kwargs) - - # def get_context_data(self, *args, **kwargs): - # context = super().get_context_data(*args, **kwargs) - # context['submission'] = self.submission - # return context - def get_object(self): try: return self.submission.editorial_decision @@ -2203,109 +2111,6 @@ def accept_puboffer(request, identifier_w_vn_nr): return redirect(reverse('scipost:personal_page')) - -# ATTEMPT: to drop -# class EditorialDecisionFixView(PermissionsMixin, UpdateView): -# """This fixes the decision and emails the authors.""" - -# model = EditorialDecision -# permission_required = 'scipost.can_fix_College_decision' -# model = EditorialDecision -# context_object_name = 'decision' -# form_class = EditorialDecisionForm -# template_name = 'submissions/admin/editorial_decision_form.html' - - -# class EditorialDecisionBaseCreateView(PermissionsMixin, CreateView): -# """For EdAdmin to fix the editorial decision on a Submission, after voting is completed.""" - -# permission_required = 'scipost.can_fix_College_decision' -# model = EditorialDecision -# form_class = EditorialDecisionForm -# success_url = reverse_lazy('submissions:pool') - -# def get(self, request, *args, **kwargs): -# self.submission = get_object_or_404( -# Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) -# return super().get(request, *args, **kwargs) - -# def post(self, request, *args, **kwargs): -# self.submission = get_object_or_404( -# Submission, preprint__identifier_w_vn_nr=kwargs.get('identifier_w_vn_nr')) -# return super().post(request, *args, **kwargs) - -# def get_context_data(self, *args, **kwargs): -# context = super().get_context_data(*args, **kwargs) -# context['submission'] = self.submission -# return context - - -# class EditorialDecisionCreateView(EditorialDecisionBaseCreateView): -# """For EdAdmin to fix the editorial decision on a Submission, after voting is completed.""" - -# template_name = 'submissions/admin/editorial_decision_form.html' - -# def get_initial(self, *args, **kwargs): -# initial = super().get_initial(*args, **kwargs) -# eicrec = self.submission.eicrecommendations.last() -# for_journal = eicrec.for_journal -# decision = eicrec.recommendation if eicrec.recommendation in [ -# EIC_REC_PUBLISH, EIC_REC_REJECT] else EIC_REC_PUBLISH -# status = EditorialDecision.FIXED_AND_ACCEPTED -# initial.update({ -# 'submission': self.submission, -# 'for_journal': for_journal, -# 'decision': decision, -# 'status': status, -# }) -# return initial - -# def form_valid(self, form): -# """Save the form data to session variables and redirect to confirmation view.""" -# self.request.session['for_journal_id'] = form.cleaned_data['for_journal'].id -# self.request.session['decision'] = form.cleaned_data['decision'] -# self.request.session['remarks_for_authors'] = form.cleaned_data['remarks_for_authors'] -# self.request.session['remarks_for_editorial_college'] = form.cleaned_data['remarks_for_editorial_college'] -# self.request.session['status'] = form.cleaned_data['status'] -# return redirect(reverse( -# 'submissions:editorial_decision_confirm_create', -# kwargs={'identifier_w_vn_nr': self.kwargs.get('identifier_w_vn_nr')})) - - -# class EditorialDecisionConfirmCreateView(EditorialDecisionBaseCreateView): -# """For EdAdmin to fix the editorial decision on a Submission, after voting is completed. - -# This is a confirmation view.""" - -# template_name = 'submissions/admin/editorial_decision_confirm_create.html' - -# def get_initial(self, *args, **kwargs): -# initial = super().get_initial(*args, **kwargs) -# for_journal = get_object_or_404( -# Journal, pk=self.request.session['for_journal_id']) -# initial.update({ -# 'submission': self.submission, -# 'for_journal': for_journal, -# 'decision': self.request.session['decision'], -# 'remarks_for_authors': self.request.session['remarks_for_authors'], -# 'remarks_for_editorial_college': self.request.session['remarks_for_editorial_college'], -# 'status': self.request.session['status'], -# }) -# return initial - -# def form_valid(self, form): -# # Delete temp session variables -# del self.request.session['for_journal_id'] -# del self.request.session['decision'] -# del self.request.session['remarks_for_authors'] -# del self.request.session['remarks_for_editorial_college'] -# del self.request.session['status'] -# # Fix the latest EICRecommendation - -# self.object = form.save() -# return redirect(self.get_success_url()) - - class PlagiarismView(SubmissionAdminViewMixin, UpdateView): """Administration detail page of Plagiarism report."""