Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository submission now has a review page before submission is complete #4330

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3890a0f
#3478 adds a proper review page for repo subs.
ajrbyers Jul 19, 2024
ee40733
#3478 updated HTML in repo/submit/review.html
ajrbyers Jul 19, 2024
1f03245
#3478 update link tag and add sr-only text.
ajrbyers Jul 19, 2024
7a76694
#3478 swap key color for dimgray hex code. Snrk.
ajrbyers Jul 19, 2024
3fa5733
#3478 simplify the template logic for repository submission breadcrumb.
ajrbyers Jul 22, 2024
ba34839
#3478 addreses inline review comments.
ajrbyers Aug 7, 2024
1c683a5
#3478 use a definition list to make content semantic
ajrbyers Aug 7, 2024
35d8340
#3478 removes stray closing paragraph tag.
ajrbyers Aug 13, 2024
494d42f
Add related name for copyeditor files BirkbeckCTP/typesteting#166
joemull Jul 15, 2024
34bffea
Add Galley.detail to display more info BirkbeckCTP/typesetting#166
joemull Jul 15, 2024
7842f90
Add a template tag for a uuid4 BirkbeckCTP/typesetting#166
joemull Jul 15, 2024
d0af16e
Set of buttons for easy input of date fields BirkbeckCTP/typesetting#166
joemull Jul 15, 2024
8fe20e7
Upgrade check_all widget to component BirkbeckCTP/janeway#166
joemull Jul 15, 2024
edf717d
Allow multiple datatables on one page BirkbeckCTP/typesetting#166
joemull Jul 15, 2024
f940957
Simplify Galley.detail method to avoid timezone issue #166
joemull Jul 17, 2024
94c15a3
Do not shorten uuid4
joemull Jul 24, 2024
470582a
Generalize and document offset_date
joemull Jul 24, 2024
ca66a1c
#4342 add revisions to logic check on revision dashboard.
ajrbyers Aug 5, 2024
2f7bd84
Rebase.
ajrbyers Aug 13, 2024
7eb9b5d
3911 updated article template Download and Checksum to test for galle…
StephDriver Jun 24, 2024
4fff209
3911 autogenerated list of table of contents removed if it has no con…
StephDriver Jun 24, 2024
5ed264d
3911 minor debugging changes
StephDriver Jun 25, 2024
8ccd6c4
3911 update consistency of approach across all themes
StephDriver Jun 26, 2024
581e5a4
3911 debugging clean theme changes following testing
StephDriver Jun 26, 2024
e612f05
3911 more debugging clean theme changes following testing
StephDriver Jun 26, 2024
4c13005
3911 Material and Clean hide TOC debugging
StephDriver Jun 26, 2024
33a2c03
3911 OLH fix not avaliable until published logic error introduced ear…
StephDriver Jun 26, 2024
0fd7cb0
3911 material update to same hide TOC structure
StephDriver Jun 26, 2024
3c0d46c
3911 clean update to ensure proofing download note appears when there…
StephDriver Jun 27, 2024
65a7725
Updates clean to use frozen authors for citation modals.
ajrbyers Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/copyediting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class CopyeditAssignment(models.Model):
date_decided = models.DateTimeField(null=True, blank=True)

files_for_copyediting = models.ManyToManyField('core.File', related_name='files_for_copyediting')
copyeditor_files = models.ManyToManyField('core.File', blank=True)
copyeditor_files = models.ManyToManyField(
'core.File',
blank=True,
related_name='copyeditor_files',
)
copyeditor_completed = models.DateTimeField(blank=True, null=True)

copyedit_reopened = models.DateTimeField(blank=True, null=True)
Expand Down
12 changes: 11 additions & 1 deletion src/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import statistics
import json
from datetime import timedelta
from django.utils.html import format_html
import pytz
from hijack.signals import hijack_started, hijack_ended
import warnings
Expand All @@ -32,7 +33,7 @@
from django.dispatch import receiver
from django.urls import reverse
from django.utils.functional import cached_property
from django.template.defaultfilters import linebreaksbr
from django.template.defaultfilters import date
import swapper

from core import files, validators
Expand Down Expand Up @@ -1225,6 +1226,15 @@ def unlink_files(self):
def __str__(self):
return "{0} ({1})".format(self.id, self.label)

def detail(self):
return format_html(
'{} galley linked to <a href="#file_{}">file {}: {}</a>',
self.label,
self.file.pk,
self.file.pk,
self.file.original_filename,
)

def render(self, recover=False):
return files.render_xml(
self.file, self.article,
Expand Down
30 changes: 30 additions & 0 deletions src/core/templatetags/dates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django import template
from django.utils import timezone


register = template.Library()

@register.simple_tag
def offset_date(days=0, input_type="date"):
"""
Get a string representing today's date or the now datetime,
with an offset of X days.
:param days: number of days from now that the date should be set
:param date: date or datetime-local

Usage:

<input
id="due"
name="due"
type="{{ input_type }}"
value="{% offset_date days=3 input_type=input_type %}">

See admin.core.widgets.soon_date_buttons for a use case.

"""
due = timezone.now() + timezone.timedelta(days=days)
if input_type == "date":
return due.strftime("%Y-%m-%d")
elif input_type == "datetime-local":
return due.strftime("%Y-%m-%dT%H:%M")
8 changes: 8 additions & 0 deletions src/core/templatetags/uuid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django import template
from uuid import uuid4

register = template.Library()

@register.simple_tag
def get_uuid4():
return f'u{str(uuid4())}'
7 changes: 7 additions & 0 deletions src/repository/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ def __init__(self, *args, **kwargs):
self.admin = kwargs.pop('admin', False)
elements = self.request.repository.additional_submission_fields()
super(PreprintInfo, self).__init__(*args, **kwargs)

if self.admin:
self.fields.pop('submission_agreement')
self.fields.pop('comments_editor')

# If using this form and there is an instance then this has
# previously been checked as it is required.
if self.instance:
self.fields['submission_agreement'].initial = True

self.fields['subject'].queryset = models.Subject.objects.filter(
enabled=True,
repository=self.request.repository,
Expand Down Expand Up @@ -487,6 +493,7 @@ class Meta:
'limit_access_to_submission',
'submission_access_request_text',
'submission_access_contact',
'review_submission_text',
'custom_js_code',
'review_helper',
)
Expand Down
31 changes: 31 additions & 0 deletions src/repository/migrations/0044_alter_repositoryfield_help_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2 on 2024-06-26 10:12

from django.db import migrations, models
from django.template.defaultfilters import striptags


def strip_html_tags_from_repo_field_help_text(apps, schema_editor):
RepositoryField = apps.get_model('repository', 'RepositoryField')

for field in RepositoryField.objects.all():
field.help_text = striptags(field.help_text)
field.save()


class Migration(migrations.Migration):

dependencies = [
('repository', '0043_auto_20240402_1256'),
]

operations = [
migrations.AlterField(
model_name='repositoryfield',
name='help_text',
field=models.TextField(blank=True, null=True),
),
migrations.RunPython(
strip_html_tags_from_repo_field_help_text,
reverse_code=migrations.RunPython.noop,
)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2 on 2024-07-18 15:38

import core.model_utils
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('repository', '0043_auto_20240402_1256'),
]

operations = [
migrations.AddField(
model_name='historicalrepository',
name='review_submission_text',
field=core.model_utils.JanewayBleachField(blank=True, default='<p>Please review your submission carefully. Make any necessary changes to ensure that all information is accurate and complete.</p><p>When you are satisfied with your review click the button below to finalize your submission.</p>', help_text='Text that displays on the review page just before the author completes their submission.'),
),
migrations.AddField(
model_name='repository',
name='review_submission_text',
field=core.model_utils.JanewayBleachField(blank=True, default='<p>Please review your submission carefully. Make any necessary changes to ensure that all information is accurate and complete.</p><p>When you are satisfied with your review click the button below to finalize your submission.</p>', help_text='Text that displays on the review page just before the author completes their submission.'),
),
migrations.AlterField(
model_name='repositoryfield',
name='help_text',
field=models.TextField(blank=True, null=True),
),
]
20 changes: 18 additions & 2 deletions src/repository/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ class Repository(model_utils.AbstractSiteModel):
help_text='eg. preprints or articles',
)
managers = models.ManyToManyField('core.Account', blank=True)
submission_notification_recipients = models.ManyToManyField('core.Account', blank=True, related_name='submission_notification_repositories')
submission_notification_recipients = models.ManyToManyField(
'core.Account',
blank=True,
related_name='submission_notification_repositories',
)
logo = model_utils.SVGImageField(
blank=True,
null=True,
Expand Down Expand Up @@ -226,6 +230,15 @@ class Repository(model_utils.AbstractSiteModel):
help_text='Describe any supporting information you want users to supply when requesting'
'access permissions for this repository. Linked to Limit Access to Submissions.',
)
review_submission_text = model_utils.JanewayBleachField(
blank=True,
default="<p>Please review your submission carefully. Make any "
"necessary changes to ensure that all information is accurate "
"and complete.</p><p>When you are satisfied with your review "
"click the button below to finalize your submission.</p>",
help_text="Text that displays on the review page just before the "
"author completes their submission."
)
submission_access_contact = models.EmailField(
blank=True,
null=True,
Expand Down Expand Up @@ -343,7 +356,10 @@ class RepositoryField(models.Model):
)
required = models.BooleanField(default=True)
order = models.IntegerField()
help_text = model_utils.JanewayBleachField(blank=True, null=True)
help_text = models.TextField(
blank=True,
null=True,
)
display = models.BooleanField(
default=False,
help_text='Whether or not display this field in the article page',
Expand Down
31 changes: 14 additions & 17 deletions src/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,21 +747,6 @@ def repository_files(request, preprint_id):

if 'complete' in request.POST:
if preprint.submission_file:
preprint.submit_preprint()
kwargs = {'request': request, 'preprint': preprint}
event_logic.Events.raise_event(
event_logic.Events.ON_PREPRINT_SUBMISSION,
**kwargs,
)

messages.add_message(
request,
messages.SUCCESS,
'{object} {title} submitted.'.format(
object=request.repository.object_name,
title=preprint.title
)
)
return redirect(
reverse(
'repository_review',
Expand Down Expand Up @@ -798,12 +783,24 @@ def repository_review(request, preprint_id):
models.Preprint,
pk=preprint_id,
owner=request.user,
date_submitted__isnull=False,
repository=request.repository,
)

if request.POST and 'complete' in request.POST:

preprint.submit_preprint()
kwargs = {'request': request, 'preprint': preprint}
event_logic.Events.raise_event(
event_logic.Events.ON_PREPRINT_SUBMISSION,
**kwargs,
)
messages.add_message(
request,
messages.SUCCESS,
'{object} {title} submitted.'.format(
object=request.repository.object_name,
title=preprint.title
)
)
return redirect(reverse('repository_dashboard'))

template = 'admin/repository/submit/review.html'
Expand Down
39 changes: 39 additions & 0 deletions src/static/admin/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,42 @@ ul.menu {
/* Temporary hotfix for compatibility with TinyMCE */
z-index: 10 !important;
}

.key-value-pair {
font-family: "Open Sans", sans-serif;
margin-bottom: 1.25rem;
}

.key-value-pair.key-above .key {
font-size: 1rem;
line-height: 1.4;
text-align: left;
color: #696969;
margin-bottom: 0.31rem;
font-weight: normal;
}

.key-value-pair.key-above .value {
font-size: 1.125rem;
line-height: 1.4;
text-align: left;
}

.key-value-pair.key-above .value .inline-list {
display: inline;
list-style: none;
padding: 0;
margin: 0;
}

.key-value-pair.key-above .value .inline-list li {
display: inline;
}

.key-value-pair.key-above .value .inline-list li:after {
content: ", ";
}

.key-value-pair.key-above .value .inline-list li:last-child:after {
content: "";
}
4 changes: 3 additions & 1 deletion src/static/admin/js/check_all.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Deprecated. Use select_all.html instead.

$("#checkall").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
});
44 changes: 44 additions & 0 deletions src/templates/admin/core/widgets/select_all.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% comment %}
Easily select or deselect all the checkboxes for a given field.

Make sure to wrap this widget and the checkboxes in fieldset.

Usage:

<fieldset>
<legend>Which colours?</legend>
{% include "admin/core/widgets/select_all.html" %}
<input id="red" name="red" type="checkbox"><label for="red">Red</label>
<input id="blue" name="blue" type="checkbox"><label for="blue">Blue</label>
</fieldset>

{% endcomment %}

{% load uuid %}

{% get_uuid4 as pid %}

<div id="{{ pid }}" style="button-group">
<button class="button selectall" type="button">
<span class="fa fa-check"></span>
Select all
</button>
<button class="button deselectall" type="button">
<span class="fa fa-close"></span>
Deselect all
</button>
</div>
<script defer type="module">
function toggleInputsInFieldset(event) {
const checked = event.currentTarget.classList.contains('selectall');
const fieldset = event.currentTarget.closest('fieldset');
const checkboxes = fieldset.querySelectorAll('input[type="checkbox"]');
Array.from(checkboxes).forEach(checkbox => {
checkbox.checked = checked;
});
}
const selectAll = document.querySelector('#{{ pid }} .selectall');
selectAll.addEventListener('click', toggleInputsInFieldset);
const deselectAll = document.querySelector('#{{ pid }} .deselectall');
deselectAll.addEventListener('click', toggleInputsInFieldset);
</script>
Loading