Skip to content

Commit

Permalink
Expand the document manager #4326
Browse files Browse the repository at this point in the history
  • Loading branch information
joemull authored and mauromsl committed Aug 22, 2024
1 parent 7aedd26 commit d9ac7f1
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 26 deletions.
85 changes: 77 additions & 8 deletions src/journal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import re
from importlib import import_module

from django.conf import settings
from django.contrib import messages
Expand Down Expand Up @@ -2442,18 +2443,23 @@ def document_management(request, article_id):

if request.POST and request.FILES:

label = request.POST.get('label') if request.POST.get('label') else 'File'
label = request.POST.get('label') if request.POST.get('label') else '[Unlabeled]'

if 'manu' in request.POST:
from core import files as core_files
file = request.FILES.get('manu-file')
new_file = core_files.save_file_to_article(file, document_article,
request.user, label=label, is_galley=False)
new_file = core_files.save_file_to_article(
file,
document_article,
request.user,
label=label,
is_galley=False,
)
document_article.manuscript_files.add(new_file)
messages.add_message(
request,
messages.SUCCESS,
_('Production file uploaded.'),
_('Manuscript file uploaded.'),
)

if 'fig' in request.POST:
Expand All @@ -2470,10 +2476,11 @@ def document_management(request, article_id):
messages.add_message(
request,
messages.SUCCESS,
_('Production file uploaded.'),
_('Data/figure file uploaded.'),
)

if 'prod' in request.POST:
# Deprecated. Use manuscript file instead.
from production import logic as prod_logic
file = request.FILES.get('prod-file')
prod_logic.save_prod_file(document_article, request, file, label)
Expand All @@ -2483,14 +2490,76 @@ def document_management(request, article_id):
_('Production file uploaded.'),
)

if 'proof' in request.POST:
if 'galley' in request.POST:
from production import logic as prod_logic
file = request.FILES.get('proof-file')
file = request.FILES.get('galley-file')
prod_logic.save_galley(document_article, request, file, True, label)
messages.add_message(
request,
messages.SUCCESS,
_('Proofing file uploaded.'),
_('Galley file uploaded.'),
)

if 'proofing' in request.POST:
from core import files as core_files
file = request.FILES.get('proofing-file')
new_file = core_files.save_file_to_article(
file,
document_article,
request.user,
label=label,
)
try:
typesetting_models = import_module('plugins.typesetting.models')
rounds = typesetting_models.TypesettingRound.objects.filter(
article=document_article,
)
if rounds:
current_round = rounds.first()
else:
current_round = typesetting_models.TypesettingRound.objects.create(
article=document_article,
)
request.user.add_account_role('proofreader', request.journal)
proofing = typesetting_models.GalleyProofing.objects.create(
round=current_round,
manager=request.user,
proofreader=request.user,
due=timezone.now(),
accepted=timezone.now(),
completed=timezone.now(),
)
proofing.annotated_files.add(new_file)
messages.add_message(
request,
messages.SUCCESS,
_('Proofing file uploaded.'),
)
except ModuleNotFoundError:
messages.add_message(
request,
messages.SUCCESS,
_('Saved file.'),
)

if 'supp' in request.POST:
from production import logic as prod_logic
file = request.FILES.get('supp-file')
prod_logic.save_supp_file(document_article, request, file, label)
messages.add_message(
request,
messages.SUCCESS,
_('Supplementary file uploaded.'),
)

if 'source' in request.POST:
from production import logic as prod_logic
file = request.FILES.get('source-file')
prod_logic.save_source_file(document_article, request, file, label)
messages.add_message(
request,
messages.SUCCESS,
_('Typesetting source file uploaded.'),
)

return redirect(
Expand Down
5 changes: 3 additions & 2 deletions src/production/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_all_galleys(article):


def save_prod_file(article, request, uploaded_file, label):
# Deprecated. A prod file is just a manuscript file.
new_file = files.save_file_to_article(uploaded_file, article, request.user)
new_file.label = label
new_file.is_galley = False
Expand All @@ -63,9 +64,9 @@ def save_supp_file(article, request, uploaded_file, label):
article.supplementary_files.add(supp_file)


def save_source_file(article, request, uploaded_file):
def save_source_file(article, request, uploaded_file, label='Source File'):
new_file = files.save_file_to_article(uploaded_file, article, request.user)
new_file.label = "Source File"
new_file.label = label
new_file.is_galley = False
new_file.save()

Expand Down
74 changes: 58 additions & 16 deletions src/templates/admin/journal/document_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
<tr>
<th>ID</th>
<th>Label</th>
<th>Filename</th>
<th>Type</th>
<th>Uploaded</th>
<th>Modified</th>
<th>Filename</th>
<th>Download</th>
<th>History</th>
<th>Replace</th>
<th>Delete</th>
<th>Type</th>
{% if request.user.is_admin %}
<th>Admin</th>
{% endif %}
Expand All @@ -41,9 +41,10 @@
<tr>
<td>{{ file.pk }}</td>
<td class="wrap-long-text">{% if not file.label %}No Label{% endif %}{{ file.label }}</td>
<td class="wrap-long-text">{{ file }}</td>
<td>{% file_type article file %}</td>
<td>{{ file.date_uploaded|date:"Y-m-d G:i" }}</td>
<td>{{ file.last_modified|date:"Y-m-d G:i" }}</td>
<td class="wrap-long-text">{{ file }}</td>
<td>{% if can_view_file_flag %}
<a href="{% url 'article_file_download' 'id' article.pk file.pk %}"><i
class="fa fa-download">
Expand All @@ -60,7 +61,6 @@
<a href="{% url 'file_delete' article.pk file.pk %}?return={{ request.path|urlencode }}%3Freturn%3D{{ request.GET.return|urlencode }}"><i
class="fa fa-trash">
&nbsp;</i></a>{% endif %}</td>
<td>{% file_type article file %}</td>
{% if request.user.is_admin %}
<td>
<a target="_blank" href="{% url 'admin:core_file_change' file.pk %}"><span class="fa fa-cogs">&nbsp;</span>Edit</a>
Expand Down Expand Up @@ -97,7 +97,7 @@ <h4><i class="fa fa-upload">&nbsp;</i>Upload File</h4>
</div>
</div>
<div class="card-section">
<p>Add a label and then upload a file. You can only upload one file type at a <time class=""></time></p>
<p>Add a label and then upload a file. You can only upload one file type at a time.</p>
{% if error %}
<div class="alert alert-warning" role="alert">{{ error }}</div>
{% endif %}
Expand All @@ -110,10 +110,12 @@ <h4><i class="fa fa-upload">&nbsp;</i>Upload File</h4>
<label for="label">File Label*</label>
<input type="text" maxlength="200" id="label" name="label" placeholder="Add file label here." required="required" />
<input type="hidden" name="upload" value="upload">
<h4>New Manuscript File</h4>
<h4>Manuscript File</h4>
<div class="clearfix">
<div>
<p><small>MS files are used in review and copyediting.</small></p>
<p><small>Manuscript files hold the main text content of the
article while it is being finalized. They are used across review,
copyediting, and typesetting.</small></p>
<input name="manu-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
Expand All @@ -127,7 +129,10 @@ <h4>New Manuscript File</h4>
<h4>Figure/Data File</h4>
<div class="clearfix">
<div>
<p><small>Figure files are images from manuscripts. Data files are any other file not an image or Manuscript that relate to the paper.</small></p>
<p><small>Figure files hold images that will be included
in the article. Data files hold any other other content
that is not an image or main text content
but that will be included in the published article.</small></p>
<input name="fig-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
Expand All @@ -138,28 +143,65 @@ <h4>Figure/Data File</h4>
</div>
</div>

<h4>Production</h4>
<h4>Galley File</h4>
<div class="clearfix">
<div>
<p><small>Galleys are files that have been typeset
or encoded, most often in XML, HTML, or PDF format,
so that they are ready for proofing and publication.</small></p>
<input name="galley-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
<button type="submit" class="button success float-right" name="galley"><i
class="fa fa-upload">
&nbsp;</i>Upload
</button>
</div>
</div>

<h4>Proofing File</h4>
<div class="clearfix">
<div>
<p><small>Proofing files are copies of galleys
that have been marked up to indicate corrections to be
made in subsequent rounds of typesetting.</small></p>
<input name="proofing-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
<button type="submit" class="button success float-right" name="proofing"><i
class="fa fa-upload">
&nbsp;</i>Upload
</button>
</div>
</div>

<h4>Source File</h4>
<div class="clearfix">
<div>
<p><small>Upload a new file for use in Production/Typesetting.</small></p>
<input name="prod-file" type="file" class="float-left" style="width:50%;"
<p><small>Source files are files created in typesetting
while generating a galley. They are often in
specialized file formats used by graphic design and
document layout applications.</small></p>
<input name="source-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
<button type="submit" class="button success float-right" name="prod"><i
<button type="submit" class="button success float-right" name="source"><i
class="fa fa-upload">
&nbsp;</i>Upload
</button>
</div>
</div>

<h4>Proofing</h4>
<h4>Supplementary File</h4>
<div class="clearfix">
<div>
<p><small>Upload a new file for use in Proofing.</small></p>
<input name="proof-file" type="file" class="float-left" style="width:50%;"
<p><small>Supplementary files are publication-ready
pieces of content to be published alongside the article,
often with their own DOIs.</small></p>
<input name="supp-file" type="file" class="float-left" style="width:50%;"
data-placeholder="No file"
data-buttonName="btn-primary">
<button type="submit" class="button success float-right" name="proof"><i
<button type="submit" class="button success float-right" name="supp"><i
class="fa fa-upload">
&nbsp;</i>Upload
</button>
Expand Down

0 comments on commit d9ac7f1

Please sign in to comment.