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
10 changes: 10 additions & 0 deletions cms/sass/base/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,13 @@ fieldset {
height: 1em;
width: auto;
}

.focus-overlay {
position: fixed;
height: 100%;
width: 100%;
background-color: rgba($dark-grey, 0.7);
z-index: 999;
top: 0;
left: 0;
}
21 changes: 21 additions & 0 deletions cms/sass/components/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@
cursor: pointer;
}

button {
margin-bottom: 0;
}
p {
margin-bottom: 0;
}

&.focus {
position: relative;
width: 100%;
display: flex;
flex-direction: column;
background-color: $white;
z-index: 1000;
button {
margin-top: 1.5rem;
width: max-content;
align-self: center;
}
}

&--message {
background-color: $warm-black;
color: $white;
Expand Down
45 changes: 45 additions & 0 deletions doajtest/testbook/new_application_form/maned_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,48 @@ tests:
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
- title: Reject application that is a continuation
steps:
- step: go to /testdrive/reject
- step: login as ProfessorFrostfire (you may want to log in using an incognito window)
- step: open "Advances in Cold Lava Mechanics" application (available on your dashboard)
- step: change the status to "Rejected" in the "Change status" input
- step: save the application
results:
- application is saved
- a warning appears with information about an older journal and a link in "focus" mode
- the form is dimmed; interactions outside the warning are blocked
- the "Got it!" button is displayed at the bottom
- step: click the link in the warning
results:
- the "Annals of Cryovolcanic Ecology" form opens in a new tab
- step: Unlock & Close the journal form, close the tab, and return to the application form
- step: click the "Got it" button
results:
- the warning is now in standard mode
- the "Got it!" button is hidden
- the application is active and can be unlocked & closed
- step: Unlock & Close
- step: open the application again (navigate to `/admin/application/<application_id>` or search for "Advances in Cold Lava Mechanics" in `/admin/applications`)
results:
- the warning about the older journal is displayed at the top
- the application is active and editable
- it can be unlocked & closed
- step: change the status back to "In progress" and save (do not close)
results:
- the warning disappears
- step: once saved, click the "Quick Reject" button
- step: choose any rejection reason and click "Quick Reject"
results:
- application is saved
- the warning appears again at the top
- the form is dimmed; interactions outside the warning are blocked
- step: click "Got it"
results:
- the warning returns to standard mode
- the application is active and editable
- it can be unlocked & closed
- step: change any information (except status) and save
results:
- the application is saved correctly
- the warning remains in standard mode
4 changes: 2 additions & 2 deletions doajtest/testdrive/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def create_random_str(self, n_char=10):

def generate_unique_issn(self):
while True:
s = self.create_random_str(n_char=8)
issn = s[:4] + '-' + s[4:]
s = string.digits
issn = ''.join(random.choices(s, k=4)) + '-' + ''.join(random.choices(s, k=4))
if len(models.Journal.find_by_issn(issn)) == 0 :
return issn

Expand Down
72 changes: 72 additions & 0 deletions doajtest/testdrive/reject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from doajtest.fixtures import ApplicationFixtureFactory, JournalFixtureFactory
from portality import constants
from doajtest.testdrive.factory import TestDrive
from portality import models
from portality.models import EditorGroup

class Reject(TestDrive):
def setup(self) -> dict:

un = "ProfessorFrostfire"
pw1 = self.create_random_str()
admin = models.Account.make_account(un + "@example.com", un, un, [constants.ROLE_ADMIN])
admin.set_password(pw1)
admin.save(blocking=True)

eg = EditorGroup(**{
"name": "The Quill & Gavel Club",
"maned": admin.id,
"editor": admin.id,
"associates": [admin.id]
})
eg.save(blocking=True)

jsource = JournalFixtureFactory.make_journal_source(True)
jtitle = "Annals of Cryovolcanic Ecology"
journal = models.Journal(**jsource)
journal.set_id(jtitle.replace(" ", "").lower())
jeissn = self.generate_unique_issn()
peissn = self.generate_unique_issn()
journal.bibjson().eissn = jeissn
journal.bibjson().pissn = peissn
journal.bibjson().title = jtitle
journal.set_editor_group(eg.id)
journal.set_editor(admin.id)
journal.save()

asource = ApplicationFixtureFactory.make_application_source()
atitle = "Advances in Cold Lava Mechanics"
application = models.Application(**asource)
application.set_id(atitle.replace(" ", "").lower())
application.bibjson().eissn = self.generate_unique_issn()
application.bibjson().pissn = self.generate_unique_issn()
application.bibjson().title = atitle
application.bibjson().replaces = [jeissn]
application.set_application_status(constants.APPLICATION_STATUS_IN_PROGRESS)
application.set_editor_group(eg.id)
application.set_editor(admin.id)
application.save(blocking=True)

return {
"admin": {
"username": admin.id,
"password": pw1
},
"records": {
"application": {"title": application.bibjson().title, "id": application.id},
"journal": journal.bibjson().title,
},
"non_renderable": {
"journal": journal.id,
"application": application.id,
"edgroup": eg.id
}
}

def teardown(self, params):
models.Account.remove_by_id(params["admin"]["username"])
eg = EditorGroup.remove_by_id(params["non_renderable"]["edgroup"])
models.Journal.remove_by_id(params["non_renderable"]["journal"])
models.Application.remove_by_id(params["non_renderable"]["application"])

return {"status": "success"}
2 changes: 2 additions & 0 deletions portality/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
APPLICATION_TYPE_UPDATE_REQUEST = "update_request"
APPLICATION_TYPE_NEW_APPLICATION = "new_application"

APP_PROCESSOR_INFO_IS_BEING_REJECTED = "is_being_rejected"

INDEX_RECORD_TYPE_UPDATE_REQUEST_UNFINISHED = "Update Request (in progress)"
INDEX_RECORD_TYPE_UPDATE_REQUEST_FINISHED = "Update Request (finished)"
INDEX_RECORD_TYPE_NEW_APPLICATION_UNFINISHED = "Application (in progress)"
Expand Down
4 changes: 3 additions & 1 deletion portality/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from portality.error_handler import setup_error_logging
from portality.lib import es_data_mapping, dates, paths
from portality.ui.debug_toolbar import DoajDebugToolbar
from portality.ui import templates
from portality.ui import templates, ui_copy

import elasticsearch

Expand Down Expand Up @@ -293,6 +293,8 @@ def setup_jinja(app):
app.jinja_env.globals['type'] = type
#~~->Constants:Config~~
app.jinja_env.globals['constants'] = constants
app.jinja_env.globals['copy'] = ui_copy
app.jinja_env.globals['render_copy'] = ui_copy.render_copy
app.jinja_env.globals['templates'] = templates
#~~-> Dates:Library~~
app.jinja_env.globals['dates'] = dates
Expand Down
5 changes: 5 additions & 0 deletions portality/forms/application_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ def finalise(self, account, save_target=True, email_alert=True):
self.add_alert(Messages.FORMS__APPLICATION_PROCESSORS__ADMIN_APPLICATION__FINALISE__COULD_NOT_UNREJECT)
return

# is the application is being rejected now?
self.info = None
if self.target.application_status == constants.APPLICATION_STATUS_REJECTED and self.source.application_status != constants.APPLICATION_STATUS_REJECTED:
self.info = constants.APP_PROCESSOR_INFO_IS_BEING_REJECTED

# if this application is being accepted, then do the conversion to a journal
if self.target.application_status == constants.APPLICATION_STATUS_ACCEPTED:
j = applicationService.accept_application(self.target, account)
Expand Down
6 changes: 6 additions & 0 deletions portality/static/js/application_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ doaj.af.EditorialApplicationForm = class extends doaj.af.BaseApplicationForm {
$(sec).show();
});

$("#cont_confirmation").click(function() {
$(this).parent().removeClass("focus");
$(this).hide();
$("#focus-overlay").hide();
})

var that = this;
$("#unlock").click(function(event) {
event.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{%- if continuation_info.first_rejection -%}
<div class="focus-overlay" id="focus-overlay"></div>
{%- endif -%}
<div class="alert alert--danger {%- if continuation_info.first_rejection %} focus {%- endif -%}">
{{ render_copy(copy.WARNING, url=url_for('admin.journal_page', journal_id=continuation_info.id), title=continuation_info.title) }}
{%- if continuation_info.first_rejection -%}
<button class="button button--cta" id="cont_confirmation" tabindex="1">Got it</button>
{%- endif -%}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
{% block page_title %}{% if obj.application_type == constants.APPLICATION_TYPE_UPDATE_REQUEST %}Update Request{% else %}Application{% endif %}: {{ obj.bibjson().title }}{% endblock %}
{% block body_id %}apply{% endblock %}

{% block permanent_warnings %}
{% if obj.application_status == constants.APPLICATION_STATUS_REJECTED and continuation_info.id %}
{% include "management/admin/includes/_warning_continuation.html" with context %}
{% endif %}
{% endblock %}

{% block admin_content scoped %}
{% include "management/_application-form/includes/_editorial_form_body.html" %}

Expand Down
1 change: 1 addition & 0 deletions portality/templates-v2/management/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ <h1>
</nav>
</div>
</header>
{% block permanent_warnings %}{% endblock %}
{% include "includes/_flash_notification.html" %}
{% block management_content %}{% endblock %}

Expand Down
9 changes: 9 additions & 0 deletions portality/ui/ui_copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from jinja2 import Template
from markupsafe import Markup

WARNING = """<p>This application has been rejected. We found a related older journal record. <strong>You may want to withdraw it.</strong><br />
<a href="{{ url }}" target="_blank">{{ title }}</a>
</p>"""

def render_copy(template_str, **context):
return Markup(Template(template_str).render(**context))
14 changes: 10 additions & 4 deletions portality/view/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def update_requests():
@write_required()
@login_required
@ssl_required
def application(application_id):
def application(application_id, **kwargs):
auth_svc = DOAJ.authorisationService()
application_svc = DOAJ.applicationService()

Expand All @@ -448,8 +448,14 @@ def application(application_id):

if request.method == "GET":
fc.processor(source=ap)
continuation_info = {"first_rejection": request.args.get("info") == constants.APP_PROCESSOR_INFO_IS_BEING_REJECTED}
replaces = Journal.find_by_issn(ap.bibjson().replaces)
if replaces:
r = replaces[0]
continuation_info["id"] = r.id
continuation_info["title"] = r.bibjson().title
return fc.render_template(obj=ap, lock=lockinfo, form_diff=form_diff,
current_journal=current_journal, lcc_tree=lcc_jstree, autochecks=autochecks)
current_journal=current_journal, lcc_tree=lcc_jstree, autochecks=autochecks, continuation_info=continuation_info)

elif request.method == "POST":
processor = fc.processor(formdata=request.form, source=ap)
Expand All @@ -464,7 +470,7 @@ def application(application_id):
flash('Application updated.', 'success')
for a in processor.alert:
flash_with_url(a, "success")
return redirect(url_for("admin.application", application_id=ap.id, _anchor='done'))
return redirect(url_for("admin.application", application_id=ap.id, _anchor='done', info=processor.info))
except Exception as e:
flash("unexpected field " + str(e))
return redirect(url_for("admin.application", application_id=ap.id, _anchor='cannot_edit'))
Expand Down Expand Up @@ -533,7 +539,7 @@ def application_quick_reject(application_id):
flash(msg, "success")

# redirect the user back to the edit page
return redirect(url_for('.application', application_id=application_id))
return redirect(url_for('admin.application', application_id=application_id, info=constants.APP_PROCESSOR_INFO_IS_BEING_REJECTED))


@blueprint.route("/admin_site_search", methods=["GET"])
Expand Down