From 6427cee85819866051aeebc62c03b22a79acbbc0 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Mon, 27 Mar 2017 07:27:40 +0200
Subject: [PATCH] Add new/substitude files/templates

---
 commentaries/managers.py                      |   9 ++
 .../commentaries/_commentary_summary.html     |  45 +++++++
 .../migrations/0011_auto_20170326_1447.py     |  26 ++++
 .../templates/comments/_add_comment_form.html |  35 +++++
 .../comments/_comment_identifier.html         |  30 +++++
 .../comments/_comment_identifier_vetting.html |  12 ++
 journals/constants.py                         |  44 ++++++
 journals/exceptions.py                        |  22 +++
 journals/helpers.py                           |  34 +++++
 journals/managers.py                          |  48 +++++++
 .../journals/_publication_details.html        |  32 +++++
 news/templates/news/news_card_content.html    |  11 ++
 .../scipost/assets/css/_list_group.scss       |   4 +
 .../static/scipost/assets/css/_tables.scss    |  12 ++
 submissions/constants.py                      | 126 ++++++++++++++++++
 submissions/managers.py                       |  28 ++++
 .../submissions/_assignment_info.html         |  23 ++++
 .../_editorial_communication_content.html     |  25 ++++
 .../_recommendation_author_content.html       |  19 +++
 .../submissions/_single_public_report.html    |  10 ++
 ...single_public_report_without_comments.html |  53 ++++++++
 .../_submission_refereeing_invitations.html   |  62 +++++++++
 .../submissions/_submission_status_block.html |   7 +
 .../submissions/_submission_summary.html      |   6 +
 .../_submission_summary_short.html            |  49 +++++++
 .../submissions/_submission_version.html      |  10 ++
 26 files changed, 782 insertions(+)
 create mode 100644 commentaries/managers.py
 create mode 100644 commentaries/templates/commentaries/_commentary_summary.html
 create mode 100644 comments/migrations/0011_auto_20170326_1447.py
 create mode 100644 comments/templates/comments/_add_comment_form.html
 create mode 100644 comments/templates/comments/_comment_identifier.html
 create mode 100644 comments/templates/comments/_comment_identifier_vetting.html
 create mode 100644 journals/constants.py
 create mode 100644 journals/exceptions.py
 create mode 100644 journals/helpers.py
 create mode 100644 journals/managers.py
 create mode 100644 journals/templates/journals/_publication_details.html
 create mode 100644 news/templates/news/news_card_content.html
 create mode 100644 scipost/static/scipost/assets/css/_list_group.scss
 create mode 100644 scipost/static/scipost/assets/css/_tables.scss
 create mode 100644 submissions/constants.py
 create mode 100644 submissions/managers.py
 create mode 100644 submissions/templates/submissions/_assignment_info.html
 create mode 100644 submissions/templates/submissions/_editorial_communication_content.html
 create mode 100644 submissions/templates/submissions/_recommendation_author_content.html
 create mode 100644 submissions/templates/submissions/_single_public_report.html
 create mode 100644 submissions/templates/submissions/_single_public_report_without_comments.html
 create mode 100644 submissions/templates/submissions/_submission_refereeing_invitations.html
 create mode 100644 submissions/templates/submissions/_submission_status_block.html
 create mode 100644 submissions/templates/submissions/_submission_summary.html
 create mode 100644 submissions/templates/submissions/_submission_summary_short.html
 create mode 100644 submissions/templates/submissions/_submission_version.html

diff --git a/commentaries/managers.py b/commentaries/managers.py
new file mode 100644
index 000000000..545a1740f
--- /dev/null
+++ b/commentaries/managers.py
@@ -0,0 +1,9 @@
+from django.db import models
+
+
+class CommentaryManager(models.Manager):
+    def vetted(self, **kwargs):
+        return self.filter(vetted=True, **kwargs)
+
+    def awaiting_vetting(self, **kwargs):
+        return self.filter(vetted=False, **kwargs)
diff --git a/commentaries/templates/commentaries/_commentary_summary.html b/commentaries/templates/commentaries/_commentary_summary.html
new file mode 100644
index 000000000..681641bf6
--- /dev/null
+++ b/commentaries/templates/commentaries/_commentary_summary.html
@@ -0,0 +1,45 @@
+<table class="commentary summary">
+    <tr>
+        <td>Title:</td>
+        <td>{{commentary.pub_title}}</td>
+    </tr>
+    <tr>
+        <td>Author(s):</td>
+        <td>{{commentary.author_list}}</td>
+    </tr>
+    <tr>
+        <td>As Contributors:</td>
+        <td>
+            {% for author in commentary.authors.all %}
+                <a href="{% url 'scipost:contributor_info' author.id %}">{{author.user.first_name}} {{author.user.last_name}}</a>
+            {% empty %}
+                (none claimed)
+            {% endfor %}
+        </td>
+    </tr>
+    {% if commentary.type == 'published' %}
+    <tr>
+        <td>Journal ref.:</td>
+        <td>{{commentary.journal}} {{commentary.volume}}, {{commentary.pages}}</td>
+    </tr>
+    <tr>
+        <td>DOI:</td>
+        <td>
+            <a href="{{commentary.pub_DOI_link}}" target="_blank">{{commentary.pub_DOI_link}}</a>
+        </td>
+    </tr>
+    {% elif commentary.type == 'preprint' %}
+    <tr>
+        <td>arxiv Link:</td>
+        <td>
+            <a href="{{commentary.arxiv_link}}" target="_blank">{{commentary.arxiv_link}}</a>
+        </td>
+    </tr>
+    {% endif %}
+    {% if commentary.pub_date %}
+    <tr>
+        <td>Date:</td>
+        <td>{{commentary.pub_date}}</td>
+    </tr>
+    {% endif %}
+</table>
diff --git a/comments/migrations/0011_auto_20170326_1447.py b/comments/migrations/0011_auto_20170326_1447.py
new file mode 100644
index 000000000..1876386c0
--- /dev/null
+++ b/comments/migrations/0011_auto_20170326_1447.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2017-03-26 12:47
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('comments', '0010_auto_20170219_1006'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='comment',
+            name='in_reply_to_comment',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='nested_comments', to='comments.Comment'),
+        ),
+        migrations.AlterField(
+            model_name='comment',
+            name='status',
+            field=models.SmallIntegerField(choices=[(1, 'vetted'), (0, 'not yet vetted (pending)'), (-1, 'rejected (unclear)'), (-2, 'rejected (incorrect)'), (-3, 'rejected (not useful)')], default=0),
+        ),
+    ]
diff --git a/comments/templates/comments/_add_comment_form.html b/comments/templates/comments/_add_comment_form.html
new file mode 100644
index 000000000..aa5a8bd0a
--- /dev/null
+++ b/comments/templates/comments/_add_comment_form.html
@@ -0,0 +1,35 @@
+<script>
+  $(document).ready(function(){
+
+    var comment_text_input = $("#id_comment_text");
+
+    function set_comment_text(value) {
+      $("#preview-comment_text").text(value)
+    }
+    set_comment_text(comment_text_input.val())
+
+    comment_text_input.keyup(function(){
+      var new_text = $(this).val()
+      set_comment_text(new_text)
+      MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
+    })
+
+  });
+</script>
+
+<div class="row">
+    <div class="col-12">
+        <form enctype="multipart/form-data" action="{{url}}" method="post">
+            {% csrf_token %}
+            {% load crispy_forms_tags %}
+            {% crispy form %}
+        </form>
+    </div>
+</div>
+
+<div class="row">
+    <div class="col-md-10">
+        <h3>Preview of your comment:</h3>
+        <p id="preview-comment_text"></p>
+    </div>
+</div>
diff --git a/comments/templates/comments/_comment_identifier.html b/comments/templates/comments/_comment_identifier.html
new file mode 100644
index 000000000..3407a7c0b
--- /dev/null
+++ b/comments/templates/comments/_comment_identifier.html
@@ -0,0 +1,30 @@
+<div class="commentid" id="comment_id{{comment.id}}">
+    <h3>
+        {% if comment.is_author_reply %}Author{% endif %}
+
+        {% block comment_author %}
+            {% if not comment.anonymous %}
+                <a href="{% url 'scipost:contributor_info' comment.get_author.id  %}">{{comment.get_author_str}}</a>
+            {% else %}
+                Anonymous
+            {% endif %}
+        {% endblock comment_author %}
+        on {{comment.date_submitted|date:'Y-m-d'}}
+    </h3>
+    <h4>
+        {% 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'}})
+        {% elif comment.in_reply_to_report %}
+            (in reply to <a href="#report_id{{comment.in_reply_to_report.id}}">
+
+            {% if not comment.in_reply_to_report.anonymous %}
+                {{comment.in_reply_to_report.get_author_str}}
+            {% else %}
+                Report {{comment.in_reply_to_report.id}}
+            {% endif %}
+
+            </a> on {{comment.in_reply_to_report.date_submitted|date:'Y-m-d'}})
+        {% endif %}
+
+    </h4>
+</div>
diff --git a/comments/templates/comments/_comment_identifier_vetting.html b/comments/templates/comments/_comment_identifier_vetting.html
new file mode 100644
index 000000000..edf903c7e
--- /dev/null
+++ b/comments/templates/comments/_comment_identifier_vetting.html
@@ -0,0 +1,12 @@
+{% extends 'comments/_comment_identifier.html' %}
+
+{% comment %}
+
+    Be careful using this template!!!
+    It overwrites the anonymity of the writer!
+
+{% endcomment %}
+
+{% block comment_author %}
+    <a href="{% url 'scipost:contributor_info' comment.author.id %}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>
+{% endblock comment_author %}
diff --git a/journals/constants.py b/journals/constants.py
new file mode 100644
index 000000000..60fe1b1ab
--- /dev/null
+++ b/journals/constants.py
@@ -0,0 +1,44 @@
+SCIPOST_JOURNAL_PHYSICS_SELECT = 'SciPost Physics Select'
+SCIPOST_JOURNAL_PHYSICS = 'SciPost Physics'
+SCIPOST_JOURNAL_LECTURE_NOTES = 'SciPost Physics Lecture Notes'
+SCIPOST_JOURNALS = (
+    (SCIPOST_JOURNAL_PHYSICS_SELECT, 'SciPost Physics Select'),
+    (SCIPOST_JOURNAL_PHYSICS, 'SciPost Physics'),
+    (SCIPOST_JOURNAL_LECTURE_NOTES, 'SciPost Physics Lecture Notes'),
+)
+
+# Same as SCIPOST_JOURNALS, but SciPost Select deactivated
+SCIPOST_JOURNALS_SUBMIT = (
+    (SCIPOST_JOURNAL_PHYSICS, 'SciPost Physics'),
+    (SCIPOST_JOURNAL_LECTURE_NOTES, 'SciPost Physics Lecture Notes'),
+)
+
+SCIPOST_JOURNALS_DOMAINS = (
+    ('E', 'Experimental'),
+    ('T', 'Theoretical'),
+    ('C', 'Computational'),
+    ('ET', 'Exp. & Theor.'),
+    ('EC', 'Exp. & Comp.'),
+    ('TC', 'Theor. & Comp.'),
+    ('ETC', 'Exp., Theor. & Comp.'),
+)
+
+SCIPOST_JOURNALS_SPECIALIZATIONS = (
+    ('A', 'Atomic, Molecular and Optical Physics'),
+    ('B', 'Biophysics'),
+    ('C', 'Condensed Matter Physics'),
+    ('F', 'Fluid Dynamics'),
+    ('G', 'Gravitation, Cosmology and Astroparticle Physics'),
+    ('H', 'High-Energy Physics'),
+    ('M', 'Mathematical Physics'),
+    ('N', 'Nuclear Physics'),
+    ('Q', 'Quantum Statistical Mechanics'),
+    ('S', 'Statistical and Soft Matter Physics'),
+)
+
+STATUS_DRAFT = 'draft'
+STATUS_PUBLISHED = 'published'
+ISSUE_STATUSES = (
+    (STATUS_DRAFT, 'Draft'),
+    (STATUS_PUBLISHED, 'Published'),
+)
diff --git a/journals/exceptions.py b/journals/exceptions.py
new file mode 100644
index 000000000..16248c28c
--- /dev/null
+++ b/journals/exceptions.py
@@ -0,0 +1,22 @@
+class JournalNameError(Exception):
+    def __init__(self, name):
+        self.name = name
+
+    def __str__(self):
+        return self.name
+
+
+class PaperNumberError(Exception):
+    def __init__(self, nr):
+        self.nr = nr
+
+    def __str__(self):
+        return self.nr
+
+
+class PaperNumberingError(Exception):
+    def __init__(self, nr):
+        self.nr = nr
+
+    def __str__(self):
+        return self.nr
diff --git a/journals/helpers.py b/journals/helpers.py
new file mode 100644
index 000000000..fb08cf89e
--- /dev/null
+++ b/journals/helpers.py
@@ -0,0 +1,34 @@
+from .exceptions import JournalNameError, PaperNumberError
+
+
+def journal_name_abbrev_citation(journal_name):
+    if journal_name == 'SciPost Physics':
+        return 'SciPost Phys.'
+    elif journal_name == 'SciPost Physics Select':
+        return 'SciPost Phys. Sel.'
+    elif journal_name == 'SciPost Physics Lecture Notes':
+        return 'SciPost Phys. Lect. Notes'
+    else:
+        raise JournalNameError(journal_name)
+
+
+def journal_name_abbrev_doi(journal_name):
+    if journal_name == 'SciPost Physics':
+        return 'SciPostPhys'
+    elif journal_name == 'SciPost Physics Select':
+        return 'SciPostPhysSel'
+    elif journal_name == 'SciPost Physics Lecture Notes':
+        return 'SciPostPhysLectNotes'
+    else:
+        raise JournalNameError(journal_name)
+
+
+def paper_nr_string(nr):
+    if nr < 10:
+        return '00' + str(nr)
+    elif nr < 100:
+        return '0' + str(nr)
+    elif nr < 1000:
+        return str(nr)
+    else:
+        raise PaperNumberError(nr)
diff --git a/journals/managers.py b/journals/managers.py
new file mode 100644
index 000000000..1c31bb440
--- /dev/null
+++ b/journals/managers.py
@@ -0,0 +1,48 @@
+from django.db import models
+from django.http import Http404
+from django.utils import timezone
+
+from .constants import STATUS_PUBLISHED, STATUS_DRAFT
+
+
+class IssueManager(models.Manager):
+    def get_published(self, *args, **kwargs):
+        try:
+            return self.published(*args, **kwargs)[0]
+        except IndexError:
+            raise Http404
+
+    def published(self, journal=None, **kwargs):
+        issues = self.filter(status=STATUS_PUBLISHED, **kwargs)
+        if journal:
+            issues.filter(in_volume__in_journal__name=journal)
+        return issues
+
+    def in_draft(self, journal=None, **kwargs):
+        issues = self.filter(status=STATUS_DRAFT, **kwargs)
+        if journal:
+            issues.filter(in_volume__in_journal__name=journal)
+        return issues
+
+    def get_current_issue(self, *args, **kwargs):
+        return self.published(start_date__lte=timezone.now(),
+                              until_date__gte=timezone.now(),
+                              **kwargs).order_by('-until_date').first()
+
+    def get_last_filled_issue(self, *args, **kwargs):
+        return self.published(publication__isnull=False,
+                              **kwargs).order_by('-until_date').first()
+
+
+class PublicationManager(models.Manager):
+    def get_published(self, *args, **kwargs):
+        try:
+            return self.published(*args, **kwargs)[0]
+        except IndexError:
+            raise Http404
+
+    def published(self, **kwargs):
+        return self.filter(in_issue__status=STATUS_PUBLISHED, **kwargs)
+
+    def in_draft(self, **kwargs):
+        return self.filter(in_issue__status=STATUS_DRAFT, **kwargs)
diff --git a/journals/templates/journals/_publication_details.html b/journals/templates/journals/_publication_details.html
new file mode 100644
index 000000000..ef9a81384
--- /dev/null
+++ b/journals/templates/journals/_publication_details.html
@@ -0,0 +1,32 @@
+<div class="row">
+    <div class="col-12">
+        <h3 class="highlight py-3">
+            <a href="{% url 'scipost:publication_detail' publication.doi_string %}">{{publication.title}}</a>
+        </h3>
+
+        <p class="font-weight-bold">{{ publication.author_list }}</p>
+        <p>{{ publication.citation }} | published {{ publication.publication_date|date:'j F Y' }}</p>
+
+        <ul class="publicationClickables">
+            <li>doi:  {{publication.doi_string}}</li>
+            <li class="publicationPDF">
+                <a href="{% url 'scipost:publication_pdf' publication.doi_string %}" target="_blank">pdf</a>
+            </li>
+            <li><a href="#openModal">BiBTeX</a></li>
+            <li><a href="{% url 'submissions:submission' publication.accepted_submission.arxiv_identifier_w_vn_nr %}">Submissions/Reports</a></li>
+        </ul>
+    </div>
+</div>
+<div class="row">
+    <div class="col-12">
+        <h3>Abstract</h3>
+        <p class="abstract">{{ publication.abstract }}</p>
+    </div>
+</div>
+<div id="openModal" class="modalDialog">
+    <div>
+        <a href="#close" title="Close" class="close">X</a>
+        <h2>BiBTeX</h2>
+        <p>{{publication.BiBTeX_entry|linebreaks}}</p>
+    </div>
+</div>
diff --git a/news/templates/news/news_card_content.html b/news/templates/news/news_card_content.html
new file mode 100644
index 000000000..fe8b19596
--- /dev/null
+++ b/news/templates/news/news_card_content.html
@@ -0,0 +1,11 @@
+<div class="card-header p-2 border-0">
+    <h3 class="card-title mb-0">{{news.headline}}</h3>
+</div>
+<div class="card-block px-2">
+    <h4 class="text-muted font-weight-bold">{{news.date|date:'Y-n-j'}}</h4>
+    <p>{{news.blurb|linebreaks}}</p>
+
+    {% if news.followup_link %}
+        <a href="{{news.followup_link}}">{{news.followup_link_text}}</a>
+    {% endif %}
+</div>
diff --git a/scipost/static/scipost/assets/css/_list_group.scss b/scipost/static/scipost/assets/css/_list_group.scss
new file mode 100644
index 000000000..773da713e
--- /dev/null
+++ b/scipost/static/scipost/assets/css/_list_group.scss
@@ -0,0 +1,4 @@
+ .list-group-noborder,
+ .list-group-noborder .list-group-item {
+     border: 0;
+ }
diff --git a/scipost/static/scipost/assets/css/_tables.scss b/scipost/static/scipost/assets/css/_tables.scss
new file mode 100644
index 000000000..f5804cd57
--- /dev/null
+++ b/scipost/static/scipost/assets/css/_tables.scss
@@ -0,0 +1,12 @@
+.table {
+    th,
+    td {
+    padding: $table-cell-padding;
+        vertical-align: middle;
+    }
+}
+
+
+.table-invitations {
+    background-color: #ddd;
+}
diff --git a/submissions/constants.py b/submissions/constants.py
new file mode 100644
index 000000000..109aa6d3a
--- /dev/null
+++ b/submissions/constants.py
@@ -0,0 +1,126 @@
+
+SUBMISSION_STATUS = (
+    ('unassigned', 'Unassigned, undergoing pre-screening'),
+    ('assignment_failed', 'Failed to assign Editor-in-charge; manuscript rejected'),
+    ('EICassigned', 'Editor-in-charge assigned, manuscript under review'),
+    ('review_closed', 'Review period closed, editorial recommendation pending'),
+    # If revisions required: resubmission creates a new Submission object
+    ('revision_requested', 'Editor-in-charge has requested revision'),
+    ('resubmitted', 'Has been resubmitted'),
+    ('resubmitted_and_rejected', 'Has been resubmitted and subsequently rejected'),
+    ('resubmitted_and_rejected_visible',
+     'Has been resubmitted and subsequently rejected (still publicly visible)'),
+    # If acceptance/rejection:
+    ('voting_in_preparation', 'Voting in preparation (eligible Fellows being selected)'),
+    ('put_to_EC_voting', 'Undergoing voting at the Editorial College'),
+    ('EC_vote_completed', 'Editorial College voting rounded up'),
+    ('accepted', 'Publication decision taken: accept'),
+    ('rejected', 'Publication decision taken: reject'),
+    ('rejected_visible', 'Publication decision taken: reject (still publicly visible)'),
+    ('published', 'Published'),
+    # If withdrawn:
+    ('withdrawn', 'Withdrawn by the Authors'),
+)
+
+SUBMISSION_STATUS_OUT_OF_POOL = [
+    'assignment_failed',
+    'resubmitted',
+    'published',
+    'withdrawn',
+    'rejected',
+    'rejected_visible',
+]
+
+# Submissions which should not appear in search lists
+SUBMISSION_STATUS_PUBLICLY_UNLISTED = [
+    'unassigned',
+    'assignment_failed',
+    'resubmitted',
+    'resubmitted_rejected',
+    'resubmitted_rejected_visible',
+    'rejected',
+    'published',
+    'withdrawn',
+]
+
+# Submissions which should not be viewable (except by admins, Fellows and authors)
+SUBMISSION_STATUS_PUBLICLY_INVISIBLE = [
+    'unassigned',
+    'assignment_failed',
+    'resubmitted_rejected',
+    'rejected',
+    'withdrawn',
+]
+
+# Submissions for which voting on a related recommendation is deprecated:
+SUBMISSION_STATUS_VOTING_DEPRECATED = [
+    'rejected',
+    'published',
+    'withdrawn',
+]
+
+SUBMISSION_TYPE = (
+    ('Letter', 'Letter (broad-interest breakthrough results)'),
+    ('Article', 'Article (in-depth reports on specialized research)'),
+    ('Review', 'Review (candid snapshot of current research in a given area)'),
+)
+
+ED_COMM_CHOICES = (
+    ('EtoA', 'Editor-in-charge to Author'),
+    ('EtoR', 'Editor-in-charge to Referee'),
+    ('EtoS', 'Editor-in-charge to SciPost Editorial Administration'),
+    ('AtoE', 'Author to Editor-in-charge'),
+    ('RtoE', 'Referee to Editor-in-Charge'),
+    ('StoE', 'SciPost Editorial Administration to Editor-in-charge'),
+)
+
+ASSIGNMENT_BOOL = ((True, 'Accept'), (False, 'Decline'))
+ASSIGNMENT_NULLBOOL = ((None, 'Response pending'), (True, 'Accept'), (False, 'Decline'))
+
+ASSIGNMENT_REFUSAL_REASONS = (
+    ('BUS', 'Too busy'),
+    ('VAC', 'Away on vacation'),
+    ('COI', 'Conflict of interest: coauthor in last 5 years'),
+    ('CCC', 'Conflict of interest: close colleague'),
+    ('NIR', 'Cannot give an impartial assessment'),
+    ('NIE', 'Not interested enough'),
+    ('DNP', 'SciPost should not even consider this paper'),
+)
+
+REFEREE_QUALIFICATION = (
+    (4, 'expert in this subject'),
+    (3, 'very knowledgeable in this subject'),
+    (2, 'knowledgeable in this subject'),
+    (1, 'generally qualified'),
+    (0, 'not qualified'),
+)
+
+QUALITY_SPEC = (
+    (6, 'perfect'),
+    (5, 'excellent'),
+    (4, 'good'),
+    (3, 'reasonable'),
+    (2, 'acceptable'),
+    (1, 'below threshold'),
+    (0, 'mediocre'),
+)
+
+# Only values between 0 and 100 are kept, anything outside those limits is discarded.
+RANKING_CHOICES = (
+    (101, '-'),
+    (100, 'top'),
+    (80, 'high'),
+    (60, 'good'),
+    (40, 'ok'),
+    (20, 'low'),
+    (0, 'poor')
+)
+
+REPORT_REC = (
+    (1, 'Publish as Tier I (top 10% of papers in this journal, qualifies as Select) NOTE: SELECT NOT YET OPEN, STARTS EARLY 2017'),
+    (2, 'Publish as Tier II (top 50% of papers in this journal)'),
+    (3, 'Publish as Tier III (meets the criteria of this journal)'),
+    (-1, 'Ask for minor revision'),
+    (-2, 'Ask for major revision'),
+    (-3, 'Reject')
+)
diff --git a/submissions/managers.py b/submissions/managers.py
new file mode 100644
index 000000000..f9f30092c
--- /dev/null
+++ b/submissions/managers.py
@@ -0,0 +1,28 @@
+from django.db import models
+from django.db.models import Q
+
+from .constants import SUBMISSION_STATUS_OUT_OF_POOL
+
+
+class SubmissionManager(models.Manager):
+    def get_pool(self, user):
+        return self.exclude(status__in=SUBMISSION_STATUS_OUT_OF_POOL)\
+                .exclude(is_current=False)\
+                .exclude(authors=user.contributor)\
+                .exclude(Q(author_list__icontains=user.last_name),
+                         ~Q(authors_false_claims=user.contributor))\
+                .order_by('-submission_date')
+
+
+class EditorialAssignmentManager(models.Manager):
+    def get_for_user_in_pool(self, user):
+        return self.exclude(submission__authors=user.contributor)\
+                .exclude(Q(submission__author_list__icontains=user.last_name),
+                         ~Q(submission__authors_false_claims=user.contributor))
+
+
+class EICRecommendationManager(models.Manager):
+    def get_for_user_in_pool(self, user):
+        return self.exclude(submission__authors=user.contributor)\
+                .exclude(Q(submission__author_list__icontains=user.last_name),
+                         ~Q(submission__authors_false_claims=user.contributor))
diff --git a/submissions/templates/submissions/_assignment_info.html b/submissions/templates/submissions/_assignment_info.html
new file mode 100644
index 000000000..e5618fa3a
--- /dev/null
+++ b/submissions/templates/submissions/_assignment_info.html
@@ -0,0 +1,23 @@
+<li class="py-1">
+    {{ assignment.to.user.first_name }} {{ assignment.to.user.last_name }}
+
+    {% if assignment.accepted %}
+        <span class="label label-sm label-outline-success">accepted</span>
+    {% endif %}
+    {% if assignment.deprecated %}
+        <span class="label label-sm label-outline-info">deprecated</span>
+    {% endif %}
+    {% if assignment.refusal_reason %}
+        <span class="label label-sm label-outline-{% if assignment.refusal_reason == 'NIE' or assignment.refusal_reason == 'DNP' %}danger{% else %}warning{% endif %}">declined
+            | Reason: {{ assignment.get_refusal_reason_display }}
+        </span>
+    {% endif %}
+
+    <br>
+    <span class="text-muted">
+        requested {{ assignment.date_created }}
+        {% if assignment.date_answered %}
+            | anwsered {{ assignment.date_answered }}
+        {% endif %}
+    </span>
+</li>
diff --git a/submissions/templates/submissions/_editorial_communication_content.html b/submissions/templates/submissions/_editorial_communication_content.html
new file mode 100644
index 000000000..9086065ca
--- /dev/null
+++ b/submissions/templates/submissions/_editorial_communication_content.html
@@ -0,0 +1,25 @@
+<div class="card-block pt-3{% if communication.comtype == 'EtoA' or communication.comtype == 'EtoR' or communication.comtype == 'EtoS' %} text-right{% endif %}">
+    <div class="label label-sm label-secondary">
+        {% if communication.comtype == 'EtoA' %}
+            From you to Authors
+        {% elif communication.comtype == 'EtoR' %}
+            From you to Referee
+            {% if communication.referee %}
+                {{communication.referee.user.first_name}} {{communication.referee.user.last_name}}
+            {% endif %}
+        {% elif communication.comtype == 'EtoS' %}
+            From you to SciPost Ed Admin
+        {% elif communication.comtype == 'AtoE' %}
+            From Authors to you
+        {% elif communication.comtype == 'RtoE' %}
+            From Referee
+            {% if communication.referee %}
+                {{communication.referee.user.first_name}} {{communication.referee.user.last_name}}
+            {% endif %} to you
+        {% elif communication.comtype == 'StoE' %}
+            From SciPost Ed Admin to you
+        {% endif %}
+    </div>
+    <div class="text pb-1 pt-1">{{communication.text|linebreaks}}</div>
+    <div class="text-muted">on {{communication.timestamp}}</div>
+</div>
diff --git a/submissions/templates/submissions/_recommendation_author_content.html b/submissions/templates/submissions/_recommendation_author_content.html
new file mode 100644
index 000000000..7f4646b6e
--- /dev/null
+++ b/submissions/templates/submissions/_recommendation_author_content.html
@@ -0,0 +1,19 @@
+<div class="card-block">
+    {% block recommendation_header %}
+        <h3 class="card-title">Date {{recommendation.date_submitted}}</h3>
+    {% endblock %}
+
+    <h3 class="pb-0">Remarks for authors</h3>
+    <p class="pl-md-3">{{recommendation.remarks_for_authors}}</p>
+
+    <h3 class="pb-0">Requested changes</h3>
+    <p class="pl-md-3">{{recommendation.requested_changes}}</p>
+
+    <h3 class="pb-0">Remarks for Editorial College</h3>
+    <p class="pl-md-3">{{recommendation.remarks_for_editorial_college}}</p>
+
+    {% block recommendation_before_recommendation %}{% endblock %}
+
+    <h3 class="pb-0">Recommendation</h3>
+    <p class="pl-md-3 mb-0">{{recommendation.get_recommendation_display}}</p>
+</div>
diff --git a/submissions/templates/submissions/_single_public_report.html b/submissions/templates/submissions/_single_public_report.html
new file mode 100644
index 000000000..a73393656
--- /dev/null
+++ b/submissions/templates/submissions/_single_public_report.html
@@ -0,0 +1,10 @@
+{% extends 'submissions/_single_public_report_without_comments.html' %}
+
+{% block single_report_footer %}
+    <hr class="small">
+    <h3><a href="{% url 'comments:reply_to_report' report_id=report.id %}">Reply to this Report</a> (authors only)</h3>
+
+    {% for reply in report.comment_set.vetted %}
+        {% include 'comments/_single_comment_with_link.html' with comment=reply perms=perms user=user %}
+    {% endfor %}
+{% endblock %}
diff --git a/submissions/templates/submissions/_single_public_report_without_comments.html b/submissions/templates/submissions/_single_public_report_without_comments.html
new file mode 100644
index 000000000..c983cd7ac
--- /dev/null
+++ b/submissions/templates/submissions/_single_public_report_without_comments.html
@@ -0,0 +1,53 @@
+{% load scipost_extras %}
+{% load submissions_extras %}
+
+<div class="row">
+    <div class="col-12">
+        <div class="report">
+            {% if user.contributor == submission.editor_in_charge or user|is_in_group:'Editorial Administrators'  and not is_author or user|is_in_group:'Editorial Administrators' and not is_author_unchecked %}
+
+                <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>
+                        on {{ report.date_submitted|date:'Y-n-j' }}</h3>
+                    </h3>
+                </div>
+
+                {% if report.flagged %}
+                    <h4 class="text-danger font-weight-bold">CAUTION: check if this referee has been flagged by the authors</h4>
+                {% endif %}
+
+                <div class="row">
+                    <div class="col-12">
+                        <h3 class="highlight tight">Qualification</h3>
+                        <div class="pl-md-4">{{ report.get_qualification_display}}</div>
+                    </div>
+                </div>
+
+                {% include 'submissions/_single_report_content.html' with report=report %}
+
+                <div class="row">
+                    <div class="col-12">
+                        <h3>Remarks for editors</h3>
+                        <div class="pl-md-4">{{ report.remarks_for_editors }}</div>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="col-12">
+                        <h3>Recommendation</h3>
+                        <div class="pl-md-4">{{report.get_recommendation_display}}</div>
+                    </div>
+                </div>
+            {% else %}
+                <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 %}
+                        on {{ report.date_submitted|date:'Y-n-j' }}</h3>
+                    </h3>
+                </div>
+
+                {% include 'submissions/_single_report_content.html' with report=report %}
+            {% endif %}
+
+            {% block single_report_footer %}{% endblock %}
+        </div>
+    </div>
+</div>
diff --git a/submissions/templates/submissions/_submission_refereeing_invitations.html b/submissions/templates/submissions/_submission_refereeing_invitations.html
new file mode 100644
index 000000000..cda5c83f1
--- /dev/null
+++ b/submissions/templates/submissions/_submission_refereeing_invitations.html
@@ -0,0 +1,62 @@
+<table class="table table-invitations">
+    <tbody>
+    {% for invitation in invitations %}
+        <tr>
+            <td>{{invitation.first_name}} {{invitation.last_name}}</td>
+            <td>
+                invited <br/>
+                {{invitation.date_invited}}
+            </td>
+            <td>
+                {% if invitation.fulfilled %}
+                    <strong style="color: green">task fulfilled</strong>
+                {% elif invitation.cancelled %}
+                    <strong class="text-danger">cancelled</strong>
+                {% elif invitation.accepted is not None %}
+                    {% if invitation.accepted %}
+                        <strong style="color: green">task accepted</strong>
+                    {% else %}
+                        <strong class="text-danger">task declined</strong>
+                    {% endif %}
+                    <div>{{invitation.date_responded}}</div>
+                {% else %}
+                    reponse pending
+                {% endif %}
+            </td>
+
+            {% if not invitation.accepted == False and not invitation.cancelled %}
+                <td>
+                    {% if invitation.referee %}
+                    <a href="{% url 'submissions:communication' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr comtype='EtoR' referee_id=invitation.referee.id %}">Write a communication</a>
+                    {% else %}
+                    (not yet registered)
+                    {% endif %}
+                </td>
+                <td>
+                    {% if not invitation.fulfilled %}
+                        <a href="{% url 'submissions:ref_invitation_reminder' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr invitation_id=invitation.id %}">Send reminder email</a>
+                    {% else %}
+                        <strong style="color: green">Report has been delivered</strong>
+                    {% endif %}
+                </td>
+                <td>
+                    {% if invitation.nr_reminders > 0 %}
+                    (nr reminders sent: {{ invitation.nr_reminders }}, <br/>last on {{ invitation.date_last_reminded }})
+                    {% endif %}
+                </td>
+                <td>
+                    {% if not invitation.fulfilled %}
+                    <a href="{% url 'submissions:cancel_ref_invitation' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr invitation_id=invitation.id %}">Cancel invitation</a>
+                    {% endif %}
+                </td>
+            {% else %}
+                <td colspan="4"></td>
+            {% endif %}
+        </tr>
+    {% empty %}
+        <tr>
+            <td class="text-center py-3">You have not invited any referees yet.</td>
+        </tr>
+    {% endfor %}
+    </tbody>
+</table>
diff --git a/submissions/templates/submissions/_submission_status_block.html b/submissions/templates/submissions/_submission_status_block.html
new file mode 100644
index 000000000..3229f263d
--- /dev/null
+++ b/submissions/templates/submissions/_submission_status_block.html
@@ -0,0 +1,7 @@
+<h3 class="d-inline-block">Current status:</h3>
+<div class="d-inline">
+    <span class="label label-secondary">{{submission.get_status_display}}</span>
+    {% if submission.publication %}
+        as {{submission.publication.citation_for_web_linked}}
+    {% endif %}
+</div>
diff --git a/submissions/templates/submissions/_submission_summary.html b/submissions/templates/submissions/_submission_summary.html
new file mode 100644
index 000000000..334f2d679
--- /dev/null
+++ b/submissions/templates/submissions/_submission_summary.html
@@ -0,0 +1,6 @@
+{% extends 'submissions/_submission_summary_short.html' %}
+
+{% block submission_summary_footer %}
+    <h3 class="mt-3">Abstract</h3>
+    <p>{{submission.abstract}}</p>
+{% endblock %}
diff --git a/submissions/templates/submissions/_submission_summary_short.html b/submissions/templates/submissions/_submission_summary_short.html
new file mode 100644
index 000000000..ca045cbf8
--- /dev/null
+++ b/submissions/templates/submissions/_submission_summary_short.html
@@ -0,0 +1,49 @@
+<table class="submission summary">
+    <tr>
+        <td>Title:</td>
+        <td>{{submission.title}}</td>
+    </tr>
+    <tr>
+        <td>Author(s):</td>
+        <td>{{submission.author_list}}</td>
+    </tr>
+    <tr>
+        <td>As Contributors:</td>
+        <td>
+            {% for author in submission.authors.all %}
+                <a href="{% url 'scipost:contributor_info' author.id %}">{{author.user.first_name}} {{author.user.last_name}}</a>
+            {% empty %}
+                (none claimed)
+            {% endfor %}
+        </td>
+    </tr>
+
+    <tr>
+        <td>arxiv Link:</td>
+        <td>
+            <a href="{{submission.arxiv_link}}" target="_blank">{{submission.arxiv_link}}</a>
+        </td>
+    </tr>
+    <tr>
+        <td>Date submitted:</td>
+        <td>{{submission.submission_date}}</td>
+    </tr>
+    <tr>
+        <td>Submitted by:</td>
+        <td>{{submission.submitted_by}}</td>
+    </tr>
+    <tr>
+        <td>Submitted to:</td>
+        <td>{{submission.get_submitted_to_journal_display}}</td>
+    </tr>
+    <tr>
+        <td>Domain(s):</td>
+        <td>{{submission.get_domain_display}}</td>
+    </tr>
+    <tr>
+        <td>Subject area:</td>
+        <td>{{submission.get_subject_area_display}}</td>
+    </tr>
+</table>
+
+{% block submission_summary_footer %}{% endblock %}
diff --git a/submissions/templates/submissions/_submission_version.html b/submissions/templates/submissions/_submission_version.html
new file mode 100644
index 000000000..9bb1c6e24
--- /dev/null
+++ b/submissions/templates/submissions/_submission_version.html
@@ -0,0 +1,10 @@
+<div class="py-1">
+    <a href="{% url 'submissions:submission' submission.arxiv_identifier_w_vn_nr %}" class="pubtitleli">version {{submission.arxiv_vn_nr}}</a>
+    <span class="version-suffix">
+        {% if submission.is_current %}
+            (current version)
+        {% else %}
+            (deprecated version {{submission.arxiv_vn_nr}})
+        {% endif %}
+    </span>
+</div>
-- 
GitLab