diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py index 05df150ab0683d6a9aa9999c7ec7d6f716d1fff5..d4d3509138ded063f4c1dcf5b06de07e6f5e449c 100644 --- a/SciPost_v1/settings/base.py +++ b/SciPost_v1/settings/base.py @@ -225,7 +225,7 @@ TIME_ZONE = 'CET' USE_I18N = True USE_L10N = False -DATE_FORMAT = 'Y-m-d' +SHORT_DATE_FORMAT = DATE_FORMAT = 'Y-m-d' DATETIME_FORMAT = 'Y-m-d H:i' USE_TZ = True diff --git a/comments/templates/partials/comments/comments_list.html b/comments/templates/partials/comments/comments_list.html new file mode 100644 index 0000000000000000000000000000000000000000..169158b74a83ba6cc6039057fbc73bc444fcaa6f --- /dev/null +++ b/comments/templates/partials/comments/comments_list.html @@ -0,0 +1,8 @@ +{% if comments %} + <ul class="{{ css_class|default:'' }}"> + {% for comment in comments %} + <li><a href="{{ comment.get_absolute_url }}">{% if comment.is_author_reply %}Author Reply{% else %}Comment{% endif %} by {{ comment.author.get_title_display }} {{ comment.author.user.last_name }} on {{ comment.date_submitted|date:'DATE_FORMAT' }}</a></li> + {% include 'partials/comments/comments_list.html' with comments=comment.nested_comments.vetted css_class='m-0 pl-4' %} + {% endfor %} + </ul> +{% endif %} diff --git a/journals/admin.py b/journals/admin.py index 1011ffaea461237dfb56b9a384b174c7d80d64da..5aff8e167e095df8f086ba9002fc7eaa29a3e80f 100644 --- a/journals/admin.py +++ b/journals/admin.py @@ -7,13 +7,12 @@ from journals.models import UnregisteredAuthor, Journal, Volume, Issue, Publicat from scipost.models import Contributor from submissions.models import Submission -admin.site.register(Reference) - class UnregisteredAuthorAdmin(admin.ModelAdmin): search_fields = ['last_name'] ordering = ['last_name'] + admin.site.register(UnregisteredAuthor, UnregisteredAuthorAdmin) @@ -56,11 +55,16 @@ class PublicationAdminForm(forms.ModelForm): fields = '__all__' +class ReferenceInline(admin.TabularInline): + model = Reference + + class PublicationAdmin(admin.ModelAdmin): search_fields = ['title', 'author_list'] list_display = ['title', 'author_list', 'in_issue', 'doi_string', 'publication_date'] date_hierarchy = 'publication_date' list_filter = ['in_issue'] + inlines = [ReferenceInline] form = PublicationAdminForm admin.site.register(Publication, PublicationAdmin) diff --git a/journals/forms.py b/journals/forms.py index 12ec2553258242d43497e4b735ba05d325ccb7ad..bcbf9ce526eed8f1877e32df781652cd0744e4f1 100644 --- a/journals/forms.py +++ b/journals/forms.py @@ -113,16 +113,15 @@ class BaseReferenceFormSet(BaseModelFormSet): except KeyError: author_list.append(author['name']) - if len(author_list) > 3: - authors = author_list[0] + ' et al.' - elif len(author_list) == 3: - authors = '{}, {} and {}'.format( - author_list[0], author_list[1], author_list[2]) + if len(author_list) > 2: + authors = ', '.join(author_list[:-1]) + authors += ' and ' + author_list[-1] else: authors = ' and '.join(author_list) # Citation - citation = '{} <b>{}</b>, {} ({})'.format( + citation = '<em>{}</em> {} <b>{}</b>, {} ({})'.format( + caller.data['title'], caller.data['journal'], caller.data['volume'], caller.data['pages'], @@ -131,16 +130,15 @@ class BaseReferenceFormSet(BaseModelFormSet): self.initial_references.append({ 'reference_number': cite['key'][3:], 'authors': authors, - 'title': caller.data['title'], 'citation': citation, - 'vor': cite['doi'], - 'vor_url': 'https://doi.org/{}'.format(cite['doi']), + 'identifier': cite['doi'], + 'link': 'https://doi.org/{}'.format(cite['doi']), }) else: self.initial_references.append({ 'reference_number': cite['key'][3:], - 'vor': cite['doi'], - 'vor_url': 'https://doi.org/{}'.format(cite['doi']), + 'identifier': cite['doi'], + 'link': 'https://doi.org/{}'.format(cite['doi']), }) # Add prefill information to the form @@ -157,10 +155,9 @@ class ReferenceForm(forms.ModelForm): fields = [ 'reference_number', 'authors', - 'title', 'citation', - 'vor', - 'vor_url', + 'identifier', + 'link', ] def __init__(self, *args, **kwargs): diff --git a/journals/migrations/0008_auto_20180203_1229.py b/journals/migrations/0008_auto_20180203_1229.py new file mode 100644 index 0000000000000000000000000000000000000000..dfe8d465222f55212f57eff4ffd76e3a640072bd --- /dev/null +++ b/journals/migrations/0008_auto_20180203_1229.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-02-03 11:29 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0007_auto_20180129_1814'), + ] + + operations = [ + migrations.RenameField( + model_name='reference', + old_name='vor', + new_name='identifier', + ), + migrations.RenameField( + model_name='reference', + old_name='vor_url', + new_name='link', + ), + migrations.RemoveField( + model_name='reference', + name='title', + ), + migrations.AlterField( + model_name='reference', + name='authors', + field=models.CharField(max_length=1028), + ), + migrations.AlterField( + model_name='reference', + name='citation', + field=models.CharField(blank=True, max_length=1028), + ), + ] diff --git a/journals/models.py b/journals/models.py index a79b7e3ed746cb3302b93e2c600677da896fdc50..c583a4c5221d25c8d9f2f6cc0b95493b0e06a683 100644 --- a/journals/models.py +++ b/journals/models.py @@ -331,12 +331,10 @@ class Reference(models.Model): reference_number = models.IntegerField() publication = models.ForeignKey('journals.Publication', on_delete=models.CASCADE) - authors = models.CharField(max_length=512) - title = models.CharField(max_length=512) - citation = models.CharField(max_length=512, blank=True) - - vor = models.CharField(blank=True, max_length=128) - vor_url = models.URLField(blank=True) + authors = models.CharField(max_length=1028) + citation = models.CharField(max_length=1028, blank=True) + identifier = models.CharField(blank=True, max_length=128) + link = models.URLField(blank=True) class Meta: unique_together = ('reference_number', 'publication') @@ -344,7 +342,7 @@ class Reference(models.Model): default_related_name = 'references' def __str__(self): - return '[{}] {}'.format(self.reference_number, self.publication.doi_label) + return '[{}] {}, {}'.format(self.reference_number, self.authors[:30], self.citation[:30]) class Deposit(models.Model): diff --git a/journals/templates/partials/journals/references.html b/journals/templates/partials/journals/references.html index 97f8a5e55a23325db01acdcf0a76c932fdf350c6..466487979c9624ab686722b8605e2914baa29769 100644 --- a/journals/templates/partials/journals/references.html +++ b/journals/templates/partials/journals/references.html @@ -3,15 +3,27 @@ <a class="mb-2 d-block" href="javascript:;" data-toggle="toggle" data-target="#reference_list">Click to expand</a> <ul class="references" id="reference_list" style="display:none;"> {% for reference in publication.references.all %} - <li> - <span class="counter">[{{ reference.reference_number }}]</span> - <span class="authors">{{ reference.authors }}</span>, - <span class="title">{{ reference.title }}</span>{% if reference.citation %}, <span class="citation">{{ reference.citation|safe }}</span>{% endif %} - {% if reference.vor_url and reference.vor %} - <span class="doi">doi: <a href="{{ reference.vor_url }}" target="_blank">{{ reference.vor }}</a></span> - {% elif reference.vor_url %} - <span class="doi"><a href="{{ reference.vor_url }}" target="_blank">link</a></span> - {% endif %} + <li class="mt-1"> + <div class="d-flex flex-row"> + <div class="px-1"> + <span class="counter">[{{ reference.reference_number }}]</span> + </div> + <div class="px-1"> + <div class="authors">{{ reference.authors }}</div> + {% if reference.citation %} + <div class="citation">{{ reference.citation|safe }}</div> + {% endif %} + <div class="reference"> + {% if reference.link and reference.identifier %} + <a href="{{ reference.link }}" target="_blank">{{ reference.identifier }}</a> + {% elif reference.link %} + <a href="{{ reference.link }}" target="_blank">link</a> + {% elif reference.identifier %} + <span>{{ reference.identifier }}</span> + {% endif %} + </div> + </div> + </div> </li> {% endfor %} </ul> diff --git a/scipost/templates/partials/scipost/personal_page/submissions.html b/scipost/templates/partials/scipost/personal_page/submissions.html index 0e9c098facb4ad2ada8762c20f92b591de04c308..2af5125f616fa08dae91440a3704a180b2b6e801 100644 --- a/scipost/templates/partials/scipost/personal_page/submissions.html +++ b/scipost/templates/partials/scipost/personal_page/submissions.html @@ -21,7 +21,7 @@ </div> <div class="col-12"> <ul class="list-group list-group-flush"> - {% for sub in own_submissions %}, + {% for sub in own_submissions %} <li class="list-group-item"> <div class="card-body px-0"> {% include 'partials/submissions/submission_card_content.html' with submission=sub %} diff --git a/scipost/templatetags/request_filters.py b/scipost/templatetags/request_filters.py index d28599705956a345fecefd81acf1492296bc6e14..124ebd9aeae4a9c3852d32ab5bccea0271b8bad5 100644 --- a/scipost/templatetags/request_filters.py +++ b/scipost/templatetags/request_filters.py @@ -1,4 +1,8 @@ +import re + from django import template +from django.core.urlresolvers import reverse, NoReverseMatch + from urllib.parse import urlencode register = template.Library() @@ -9,3 +13,15 @@ def url_replace(context, **kwargs): query = context['request'].GET.dict() query.update(kwargs) return urlencode(query) + + +@register.simple_tag(takes_context=True) +def active(context, pattern_or_urlname): + try: + pattern = '^' + reverse(pattern_or_urlname) + except NoReverseMatch: + pattern = pattern_or_urlname + path = context['request'].path + if re.search(pattern, path): + return 'active' + return '' diff --git a/submissions/models.py b/submissions/models.py index d322603d05fbd16a1dd2b9e39a1f2fb2282590aa..8b2f21ef33d4a28af2dbff7bac6b30cd99a96e1b 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -192,6 +192,15 @@ class Submission(models.Model): return Submission.objects.filter( arxiv_identifier_wo_vn_nr=self.arxiv_identifier_wo_vn_nr).first().submission_date + @cached_property + def thread(self): + """ + Return all versions of the Submission with that arxiv id. + """ + return Submission.objects.public().filter( + arxiv_identifier_wo_vn_nr=self.arxiv_identifier_wo_vn_nr + ).order_by('-arxiv_vn_nr') + @cached_property def other_versions(self): """ diff --git a/submissions/templates/partials/submissions/submission_refereeing_history.html b/submissions/templates/partials/submissions/submission_refereeing_history.html new file mode 100644 index 0000000000000000000000000000000000000000..f18c535463acc976ac0e9efe5227c6f24809351c --- /dev/null +++ b/submissions/templates/partials/submissions/submission_refereeing_history.html @@ -0,0 +1,20 @@ +{% load request_filters %} + +<div class="card"> + <div class="card-body"> + <h3 class="card-title">Submission & Refereeing History</h3> + {% for sibling in submission.thread %} + <div class="my-2"> + {% if forloop.last %}Submission{% else %}Resubmission{% endif %} <a href="{{ sibling.get_absolute_url }}" class="pubtitleli">{{ sibling.arxiv_identifier_w_vn_nr }}</a> ({{ sibling.submission_date|date:'j F Y' }}) + </div> + <ul class="m-0 pl-4"> + {% for report in sibling.reports.accepted %} + <li><a href="{{ report.get_absolute_url }}">Report {{ report.report_nr }} submitted on {{ report.date_submitted }} by {% if report.anonymous %}<em>Anonymous</em>{% else %}{{ report.author.get_title_display }} {{ report.author.user.last_name }}{% endif %}</a></li> + {% include 'partials/comments/comments_list.html' with comments=report.comments.vetted css_class='my-1 pl-4' %} + {% endfor %} + </ul> + + {% include 'partials/comments/comments_list.html' with comments=sibling.comments.vetted css_class='my-1 pl-4' %} + {% endfor %} + </div> +</div> diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html index dfd390661a321543e2c64ad961c8f6b529e7063c..3642ad9bda4636c439c99105244da83e4edd0e7c 100644 --- a/submissions/templates/submissions/submission_detail.html +++ b/submissions/templates/submissions/submission_detail.html @@ -20,7 +20,7 @@ {% block content %} <div class="row"> - <div class="col"> + <div class="col-md-8"> <h2>SciPost Submission Page</h2> <h1 class="text-primary">{{submission.title}}</h1> <h3 class="mb-3">by {{submission.author_list}}</h3> @@ -36,28 +36,34 @@ {% endif %} {% if unfinished_report_for_user %} - <h3 class="mt-0">- <span class="circle text-danger border-danger">!</span> You have an unfinished report for this submission, <a href="{% url 'submissions:submit_report' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">finish your report here.</a></h3> + <h3>- <span class="circle text-danger border-danger">!</span> You have an unfinished report for this submission, <a href="{% url 'submissions:submit_report' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">finish your report here.</a></h3> {% endif %} - {% if submission.other_versions or not submission.is_current %} - <ul class="mt-3 mb-1 list-unstyled pl-4"> - {% if not submission.is_current %} - <li><h3 class="text-danger">This is not the current version.</h3></li> - {% endif %} - - {% if submission.other_versions %} - <li>Other versions of this Submission (with Reports) exist:</li> - <ul class="list-unstyled"> - {% for vn in submission.other_versions %} - <li>{% include 'submissions/_submission_version.html' with submission=vn %}</li> - {% endfor %} - </ul> - {% endif %} - </ul> + {% if not submission.is_current %} + <h3><span class="text-danger">- This is not the current version.</span></h3> {% endif %} + + {% comment %} + {% if submission.other_versions or not submission.is_current %} + <ul class="mt-3 mb-1 list-unstyled pl-4"> + {% if not submission.is_current %} + <li><h3 class="text-danger">This is not the current version.</h3></li> + {% endif %} + + {% if submission.other_versions %} + <li>Other versions of this Submission (with Reports) exist:</li> + <ul class="list-unstyled"> + {% for vn in submission.other_versions %} + <li>{% include 'submissions/_submission_version.html' with submission=vn %}</li> + {% endfor %} + </ul> + {% endif %} + </ul> + {% endif %} + {% endcomment %} </div> - <h3>Submission summary</h3> + <h3 class="mt-2">Submission summary</h3> {% include 'submissions/_submission_summary.html' with submission=submission hide_title=1 %} {% include 'submissions/_submission_status_block.html' with submission=submission %} @@ -77,13 +83,14 @@ {% endif %} </div> - {% if invitations %} - <div class="col-md-4"> - {% for invitation in invitations %} - {% include 'partials/submissions/refereeing_status_card.html' with invitation=invitation %} - {% endfor %} - </div> - {% endif %} + <div class="col-md-4"> + {% for invitation in invitations %} + {% include 'partials/submissions/refereeing_status_card.html' with invitation=invitation %} + {% endfor %} + + {% include 'partials/submissions/submission_refereeing_history.html' with submission=submission %} + </div> + </div> {% if is_author or user|is_in_group:'Editorial College' or user|is_in_group:'Editorial Administrators' %}