Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions src/core/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import json

from django import forms
from django.forms.fields import Field
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.forms import UserCreationForm
Expand All @@ -25,7 +24,6 @@
KeywordModelForm,
JanewayTranslationModelForm,
CaptchaForm,
HTMLDateInput,
)
from utils.logger import get_logger
from submission import models as submission_models
Expand Down
14 changes: 12 additions & 2 deletions src/templates/admin/workflow/manage_article_workflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ <h2>Archive</h2>
<p>This article has already been archived.</p>
{% else %}
<p>Archiving an article will remove it from the workflow, essentially tombstoning it. You can still access it through the Article Archive.</p>
<form method="POST">
<form method="POST" id="archive-article">
{% csrf_token %}
<button name="archive" class="danger button">Archive Article</button>
</form>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% if form.modal %}
{% include "admin/elements/confirm_modal.html" with modal=form.modal form_id="archive-article" %}
{% endif %}
{% endblock body %}

{% block js %}
{% if form.modal %}
{% include "admin/elements/open_modal.html" with target=form.modal.id %}
{% endif %}
{% endblock js %}

7 changes: 7 additions & 0 deletions src/workflow/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from core import forms as core_forms


class ConfirmArchivingForm(core_forms.ConfirmableForm):
CONFIRMABLE_BUTTON_NAME = 'archive'
CONFIRMED_BUTTON_NAME = 'confirmed'
QUESTION = 'Are you certain you want to archive this article?'
55 changes: 33 additions & 22 deletions src/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from security.decorators import editor_user_required, has_journal
from submission import models as submission_models
from workflow import logic
from workflow import logic, forms
from utils import models as utils_models
from events import logic as event_logic

Expand All @@ -25,6 +25,7 @@ def manage_article_workflow(request, article_id):
pk=article_id,
journal=request.journal
)
form = forms.ConfirmArchivingForm()

if request.POST:
if 'stage_to' in request.POST:
Expand All @@ -42,32 +43,42 @@ def manage_article_workflow(request, article_id):
messages.INFO,
'Processing: {}'.format(stages_string),
)
elif 'archive' in request.POST:
utils_models.LogEntry.add_entry(
types='Workflow',
description='Article has been archived.',
level='Info',
actor=request.user,
target=article,
return redirect(
reverse(
'manage_article_workflow',
kwargs={'article_id': article.pk}
)
)
article.stage = submission_models.STAGE_ARCHIVED
article.save()
messages.add_message(
request,
messages.SUCCESS,
'Article has been archived.',
)

return redirect(
reverse(
'manage_article_workflow',
kwargs={'article_id': article.pk}
elif 'archive' in request.POST or 'confirmed' in request.POST:
form = forms.ConfirmArchivingForm(
request.POST,
)
)

if form.is_valid():
if form.is_confirmed():
utils_models.LogEntry.add_entry(
types='Workflow',
description='Article has been archived.',
level='Info',
actor=request.user,
target=article,
)
article.stage = submission_models.STAGE_ARCHIVED
article.save()
messages.add_message(
request,
messages.SUCCESS,
'Article has been archived.',
)
return redirect(
reverse(
'manage_article_workflow',
kwargs={'article_id': article.pk}
)
)
template = 'workflow/manage_article_workflow.html'
context = {
'article': article,
'form': form,
}

return render(request, template, context)
Expand Down