Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
47 changes: 47 additions & 0 deletions doajtest/testbook/new_application_form/maned_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ tests:
- step: Click "Unlock and Close"
results:
- The page closes, and you are able to return to the search interface

- title: Note features for admin
context:
role: admin
Expand Down Expand Up @@ -99,3 +100,49 @@ 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_with_continuation
- 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
77 changes: 77 additions & 0 deletions doajtest/testdrive/reject_with_continuation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
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 RejectWithContinuation(TestDrive):
def setup(self) -> dict:

random_str = self.create_random_str()

un = "ProfessorFrostfire_" + random_str
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 " + random_str,
"maned": admin.id,
"editor": admin.id,
"associates": [admin.id]
})
eg.save(blocking=True)

jsource = JournalFixtureFactory.make_journal_source(True)
jtitle = "Annals of Cryovolcanic Ecology " + random_str
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 " + random_str
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.remove_current_journal()
application.remove_related_journal()
del application.bibjson().discontinued_date
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: 4 additions & 0 deletions portality/forms/application_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ def finalise(self, account, save_target=True, email_alert=True):

# if the application was instead rejected, carry out the rejection actions
elif self.source.application_status != constants.APPLICATION_STATUS_REJECTED and self.target.application_status == constants.APPLICATION_STATUS_REJECTED:
# FIXME: I'm not really sure what `info` is for - it has been defined but unused in the
# base class for ages. This doesn't feel right, though, but since it's unused doesn't
# cause any actual problems right now
self.info = constants.APP_PROCESSOR_INFO_IS_BEING_REJECTED
# reject the application
applicationService.reject_application(self.target, current_user._get_current_object())

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,11 @@
{%- if continuation_info.initial_warning -%}
<div class="focus-overlay" id="focus-overlay"></div>
{%- endif -%}
<div class="alert alert--danger {%- if continuation_info.initial_warning %} focus {%- endif -%}">
<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_for('admin.journal_page', journal_id=continuation_info.journal.id) }}" target="_blank">{{ continuation_info.journal.bibjson().title }}</a>
</p>
{%- if continuation_info.initial_warning -%}
<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.journal %}
{% 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
15 changes: 11 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,15 @@ def application(application_id):

if request.method == "GET":
fc.processor(source=ap)

continuation_info = {"initial_warning": request.args.get("info") == constants.APP_PROCESSOR_INFO_IS_BEING_REJECTED}
replaces = Journal.find_by_issn(ap.bibjson().replaces)
if replaces:
continuation_info["journal"] = replaces[0]

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 +471,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 +540,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