SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit e64e1cab authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Alter Report numbering and add PDF functionality

PDF functionality is now read-only. Auto generating pdf's
function to be craeted.
parent 243e51c8
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
{% if comment.in_reply_to_comment %} {% if comment.in_reply_to_comment %}
(in reply to <a href="#comment_id{{comment.in_reply_to_comment.id}}">{{comment.in_reply_to_comment.comment.get_author_str}}</a> on {{comment.in_reply_to_comment.date_submitted|date:'Y-m-d'}}) (in reply to <a href="#comment_id{{comment.in_reply_to_comment.id}}">{{comment.in_reply_to_comment.comment.get_author_str}}</a> on {{comment.in_reply_to_comment.date_submitted|date:'Y-m-d'}})
{% elif comment.in_reply_to_report %} {% elif comment.in_reply_to_report %}
(in reply to <a href="#report_id{{comment.in_reply_to_report.id}}"> (in reply to <a href="#report_{{comment.in_reply_to_report.report_nr}}">
{% if not comment.in_reply_to_report.anonymous %} {% if not comment.in_reply_to_report.anonymous %}
{{comment.in_reply_to_report.get_author_str}} {{comment.in_reply_to_report.get_author_str}}
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-06-25 10:53
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('partners', '0011_auto_20170609_2234'),
]
operations = [
migrations.AlterField(
model_name='prospectivepartnerevent',
name='event',
field=models.CharField(choices=[('requested', 'Requested (from online form)'), ('comment', 'Comment added'), ('email_sent', 'Email sent'), ('negotiating', 'Initiated negotiation'), ('marked_as_uninterested', 'Marked as uninterested'), ('promoted', 'Promoted to Partner')], max_length=64),
),
]
...@@ -97,6 +97,7 @@ class ReportAdmin(admin.ModelAdmin): ...@@ -97,6 +97,7 @@ class ReportAdmin(admin.ModelAdmin):
list_display_links = ('author',) list_display_links = ('author',)
date_hierarchy = 'date_submitted' date_hierarchy = 'date_submitted'
list_filter = ('status',) list_filter = ('status',)
readonly_fields = ('report_nr',)
form = ReportAdminForm form = ReportAdminForm
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-06-25 11:11
from __future__ import unicode_literals
from django.db import migrations, models
def set_report_counters(apps, schema_editor):
Report = apps.get_model('submissions', 'Report')
for report in Report.objects.order_by('date_submitted'):
if not report.report_nr:
report.report_nr = report.submission.reports.filter(report_nr__gte=1).count() + 1
report.save()
print('Updated all Report counters.')
def do_nothing(*args):
pass
class Migration(migrations.Migration):
dependencies = [
('submissions', '0045_auto_20170608_1710'),
]
operations = [
migrations.AddField(
model_name='report',
name='report_nr',
field=models.PositiveSmallIntegerField(default=0),
),
migrations.RunPython(set_report_counters, do_nothing)
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-06-25 11:31
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('submissions', '0046_auto_20170625_1311'),
]
operations = [
migrations.AddField(
model_name='report',
name='pdf_report',
field=models.FileField(blank=True, max_length=200, upload_to='UPLOADS/REPORTS/%Y/%m/'),
),
migrations.AlterField(
model_name='report',
name='report_nr',
field=models.PositiveSmallIntegerField(default=0, help_text='This number is a unique number refeering to the Report nr. of the Submission'),
),
migrations.AlterUniqueTogether(
name='report',
unique_together=set([('submission', 'report_nr')]),
),
]
...@@ -238,6 +238,10 @@ class Report(models.Model): ...@@ -238,6 +238,10 @@ class Report(models.Model):
status = models.CharField(max_length=16, choices=REPORT_STATUSES, default=STATUS_UNVETTED) status = models.CharField(max_length=16, choices=REPORT_STATUSES, default=STATUS_UNVETTED)
submission = models.ForeignKey('submissions.Submission', related_name='reports', submission = models.ForeignKey('submissions.Submission', related_name='reports',
on_delete=models.CASCADE) on_delete=models.CASCADE)
report_nr = models.PositiveSmallIntegerField(default=0,
help_text='This number is a unique number '
'refeering to the Report nr. of '
'the Submission')
vetted_by = models.ForeignKey('scipost.Contributor', related_name="report_vetted_by", vetted_by = models.ForeignKey('scipost.Contributor', related_name="report_vetted_by",
blank=True, null=True, on_delete=models.CASCADE) blank=True, null=True, on_delete=models.CASCADE)
# `invited' filled from RefereeInvitation objects at moment of report submission # `invited' filled from RefereeInvitation objects at moment of report submission
...@@ -268,13 +272,30 @@ class Report(models.Model): ...@@ -268,13 +272,30 @@ class Report(models.Model):
remarks_for_editors = models.TextField(default='', blank=True, remarks_for_editors = models.TextField(default='', blank=True,
verbose_name='optional remarks for the Editors only') verbose_name='optional remarks for the Editors only')
anonymous = models.BooleanField(default=True, verbose_name='Publish anonymously') anonymous = models.BooleanField(default=True, verbose_name='Publish anonymously')
pdf_report = models.FileField(upload_to='UPLOADS/REPORTS/%Y/%m/', max_length=200, blank=True)
objects = ReportManager() objects = ReportManager()
class Meta:
unique_together = ('submission', 'report_nr')
def __str__(self): def __str__(self):
return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' + return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' +
self.submission.title[:50] + ' by ' + self.submission.author_list[:50]) self.submission.title[:50] + ' by ' + self.submission.author_list[:50])
def get_absolute_url(self):
return self.submission.get_absolute_url() + '#report_' + str(self.report_nr)
def save(self, *args, **kwargs):
# Control Report count per Submission.
if not self.report_nr:
self.report_nr = self.submission.reports.count() + 1
return super().save(*args, **kwargs)
def report_default_counter(self):
print(self)
raise
########################## ##########################
# EditorialCommunication # # EditorialCommunication #
......
...@@ -3,13 +3,16 @@ ...@@ -3,13 +3,16 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="report"> <div class="report" id="report_{{report.report_nr}}">
{% if user.contributor == submission.editor_in_charge or user|is_in_group:'Editorial Administrators' and user|is_not_author_of_submission:submission.arxiv_identifier_w_vn_nr %} {% if user.contributor == submission.editor_in_charge or user|is_in_group:'Editorial Administrators' and user|is_not_author_of_submission:submission.arxiv_identifier_w_vn_nr %}
<div class="reportid"> <div class="reportid">
<h3>{% if report.anonymous %}(chose public anonymity) {% endif %}<a href="{% url 'scipost:contributor_info' report.author.id %}">{{ report.author.user.first_name }} {{ report.author.user.last_name }}</a> <h3>{% if report.anonymous %}(chose public anonymity) {% endif %}<a href="{% url 'scipost:contributor_info' report.author.id %}">{{ report.author.user.first_name }} {{ report.author.user.last_name }}</a>
on {{ report.date_submitted|date:'Y-n-j' }}</h3> on {{ report.date_submitted|date:'Y-n-j' }}</h3>
</h3> </h3>
{% if report.pdf_report %}
<a href="{% url 'submissions:report_detail_pdf' report.submission.arxiv_identifier_w_vn_nr report.report_nr %}" target="_blank">Download as PDF</a>
{% endif %}
</div> </div>
{% if report.flagged %} {% if report.flagged %}
...@@ -39,9 +42,12 @@ ...@@ -39,9 +42,12 @@
</div> </div>
{% else %} {% else %}
<div class="reportid"> <div class="reportid">
<h3 id="report_id{{report.id}}">{% if report.anonymous %}Anonymous Report {{report.id}}{% else %}<a href="{% url 'scipost:contributor_info' report.author.id %}">{{ report.author.user.first_name }} {{ report.author.user.last_name }}</a>{% endif %} <h3>{% if report.anonymous %}Anonymous Report {{report.report_nr}}{% else %}<a href="{% url 'scipost:contributor_info' report.author.id %}">{{ report.author.user.first_name }} {{ report.author.user.last_name }}</a>{% endif %}
on {{ report.date_submitted|date:'Y-n-j' }}</h3> on {{ report.date_submitted|date:'Y-n-j' }}</h3>
</h3> </h3>
{% if report.pdf_report %}
<a href="{% url 'submissions:report_detail_pdf' report.submission.arxiv_identifier_w_vn_nr report.report_nr %}" target="_blank">Download as PDF</a>
{% endif %}
</div> </div>
{% include 'submissions/_single_report_content.html' with report=report %} {% include 'submissions/_single_report_content.html' with report=report %}
......
...@@ -18,6 +18,8 @@ urlpatterns = [ ...@@ -18,6 +18,8 @@ urlpatterns = [
name='submission_wo_vn_nr'), name='submission_wo_vn_nr'),
url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/$', url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/$',
views.submission_detail, name='submission'), views.submission_detail, name='submission'),
url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/reports/(?P<report_nr>[0-9]+)/pdf$',
views.report_detail_pdf, name='report_detail_pdf'),
url(r'^submit_manuscript$', views.RequestSubmission.as_view(), name='submit_manuscript'), url(r'^submit_manuscript$', views.RequestSubmission.as_view(), name='submit_manuscript'),
url(r'^submit_manuscript/prefill$', views.prefill_using_arxiv_identifier, url(r'^submit_manuscript/prefill$', views.prefill_using_arxiv_identifier,
name='prefill_using_identifier'), name='prefill_using_identifier'),
......
...@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required, permission_required ...@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.db import transaction from django.db import transaction
from django.http import Http404, HttpResponseRedirect from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render, redirect from django.shortcuts import get_object_or_404, render, redirect
from django.template import Template, Context from django.template import Template, Context
from django.utils import timezone from django.utils import timezone
...@@ -219,6 +219,16 @@ def submission_detail(request, arxiv_identifier_w_vn_nr): ...@@ -219,6 +219,16 @@ def submission_detail(request, arxiv_identifier_w_vn_nr):
return render(request, 'submissions/submission_detail.html', context) return render(request, 'submissions/submission_detail.html', context)
def report_detail_pdf(request, arxiv_identifier_w_vn_nr, report_nr):
report = get_object_or_404(Report.objects.accepted(),
submission__arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr,
pdf_report__isnull=False, report_nr=report_nr)
response = HttpResponse(report.pdf_report.read(), content_type='application/pdf')
filename = '%s_report-%i.pdf' % (report.submission.arxiv_identifier_w_vn_nr, report.report_nr)
response['Content-Disposition'] = ('filename=' + filename)
return response
###################### ######################
# Editorial workflow # # Editorial workflow #
###################### ######################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment