Skip to content
Closed
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
24 changes: 18 additions & 6 deletions cms/data/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,30 @@ bg:job:admin_reports:export_available:
short:
Report "{name}" ready for download

bg:job:approaching_flag_deadline:notify:
long: |
"The deadline for the flag in "{journal_title}" (id: {id}) is in 7 days."
short:
Deadline reminder

flag:assigned:notify:
long: |
"A new flag in "{journal_title}" (id: {id}) has been assigned to you"
short:
New flag

journal:assed:assigned:notify:
long: |
The journal **{journal_name}** has been assigned to you by the Editor of your group **{group_name}**. Please start work on this within 10 days.
short:
New journal ({issns}) assigned to you

journal:maned:discontinuing_soon:notify:
long: |
Journal "{title}" (id: {id}) will discontinue in {days} days.
short:
Journal discontinuing

journal:editor_group:assigned:notify:
long: |
The journal **{journal_name}** has been assigned to your group by a Managing Editor. Please assign this to an Associate Editor within 5 working days.
Expand Down Expand Up @@ -186,9 +204,3 @@ update_request:publisher:submitted:notify:
**This is an automated message.**
short:
Your update request ({issns}) has been submitted

journal:maned:discontinuing_soon:notify:
long: |
Journal "{title}" (id: {id}) will discontinue in {days} days.
short:
Journal discontinuing
3 changes: 2 additions & 1 deletion dev.template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ HUEY_SCHEDULE = {
"datalog_journal_added_update": CRON_NEVER,
"auto_assign_editor_group_data": CRON_NEVER,
"ris_export": CRON_NEVER,
"site_statistics": CRON_NEVER
"site_statistics": CRON_NEVER,
"approaching_flag_deadline": CRON_NEVER
}

###########################################
Expand Down
69 changes: 62 additions & 7 deletions doajtest/testbook/flagged_journals/flagged_journals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,32 @@ tests:
role: Admin
steps:
- step: Navigate to /testdrive/flags
- step: Login as an admin
- step: Open Feline Aerodynamics Review application (available on your dashboard)
- step: In a separate tab login as LordWiggleworth (admin)
- step: Open Feline Aerodynamics Review journal (available on your dashboard)
results:
- Above the notes there is the Add Flag button visible and active
- step: Click Add Flag button
results:
- An empty flag form is displayed
- step: In assigned_to input attempt to add editor's id (you can find it in your testdrive/flags data)
- step: In assigned_to input attempt to add "MadamPonderleaf" (an editor)
results:
- No matches found is displayed and it is not possible to assign the editor
- step: In assigned_to input add random_user's id (you can find it in your testdrive/flags data)
- step: In assigned_to input add "ProfessorQuibbleton" (admin)
results:
- Id is found and it can be selected
- step: Select the random_user's id
- step: Select "ProfessorQuibbleton"
- step: In deadline input add an improbable date (e.g., 2025-02-31)
results:
- It's not possible to enter an improbable date
- step: In deadline input add a valid date
- step: In deadline input add a date in a past
results:
- A warning "Provided deadline is in the past. Is it correct?" is displayed under the deadline input
- step: Save the form (do not close it)
results:
- Journal form is saved correctly
- step: In deadline input add a date in exactly 1 week
results:
- Warning disappears
- step: In text area add flag's note (any text)
- step: Save application
results:
Expand Down Expand Up @@ -72,6 +80,53 @@ tests:
- In the flag form, in the Assign a User input, there is your id with a red flag icon
- Resolve Flag button is active and all fields are editable

- title: Admin - Flags Notifications
context:
role: Admin
setup:
- If you haven't performed previous test (Admin - Add, Edit, Resolve) prepare the Journal by following all the steps; otherwise you may omit steps 2-9
steps:
- step: Navigate to /testdrive/flags
- step: In a separate tab login as LordWiggleworth (admin)
- step: Open Feline Aerodynamics Review journal (available on your dashboard)
- step: Click Add Flag button
- step: Assign "ProfessorQuibbleton" (admin)
- step: Add deadline in exactly 1 week
- step: In text area add flag's note (any text)
- step: Save application, Unlock & Close the form
- step: Log out
- step: In a separate tab log in as "ProfessorQuibbleton"
results:
- At the top navbar Notifications indicate a new notification
- step: Hover over Notifications button
result:
- At the top of the list new notification "New flag" is listed
- step: Click on the notification
results:
- Feline Aerodynamics Review journal form is opened in a new tab
- On the right the flag is displayed and assigned to you ("ProfessorQuibbleton")
- step: Unlock & Close the form, close the tab
- step: Click the Notifications button at the top navigation bar
results:
- /dashboard/notifications opens
- At the top of the list "New flag" notification is displayed.
- The long description says "A new flag in 'Feline Aerodynamics Review' (id) has been assigned to you"
- step: Open the testdrive/flags page <b>do not close the page where you are logged in</b>
- step: Click "Run background task" button, wait for the task to execute
result:
- Message "Script executed successfully!" is displayed
- step: Go back to the tab where you are logged as ProfessorQuibbleton
- step: refresh the page
- step: navigate to /dashboard/notifications if not already there
results:
- At the top of the notifications list a new notification "Deadline reminder" is listed
- Long description says "The deadline for the flag in 'Feline Aerodynamics Review' (id) is in 7 days."
- At the top navbar Notifications button has a new notification marked
- step: Click "See action" link at the right of the new "Deadline reminder" notification
results:
- Feline Aerodynamics Review journal form is opened in a new tab
- step: Unlock & Close the form, close the tab

- title: Admin - Dashboard [NOT CURRENTLY USED]
context:
role: Admin
Expand Down Expand Up @@ -129,7 +184,7 @@ tests:
role: Editor
steps:
- step: Navigate to /testdrive/flags
- step: Login as an editor
- step: Login as MadamPonderleaf (editor)
- step: Navigate to /applications
- step: Open to Open Journal of Intergalactic Diplomacy - make sure you haven't resolved the flag while logged as an admin in one of the previous tests
results:
Expand Down
95 changes: 51 additions & 44 deletions doajtest/testdrive/flags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from doajtest.fixtures import ApplicationFixtureFactory
from doajtest.fixtures import JournalFixtureFactory
from doajtest.testdrive.factory import TestDrive
from portality.lib import dates
from portality import models, constants
Expand All @@ -8,24 +8,30 @@ class Flags(TestDrive):

def __init__(self):
self.another_eg = None
self.apps = []
self.journals = []
self.admin_password = None
self.admin = None
self.anotheradmin = None
self.editor = None
self.editor_password = None
self.random_user = None
self.random_user_password = None
self.eg = None

def setup(self) -> dict:
self.create_accounts()
self.build_applications()
random_str = self.create_random_str()
self.create_accounts(random_str)
self.build_journals(random_str)
return {
"accounts": {
"admin": {
"username": self.admin.id,
"password": self.admin_password
},
"another admin": {
"username": self.anotheradmin.id,
"password": self.anotheradmin_password
},
"editor": {
"username": self.editor.id,
"password": self.editor_password
Expand All @@ -35,30 +41,42 @@ def setup(self) -> dict:
"password": self.random_user_password
}
},
"applications": self.apps,
"journals": self.journals,
"non_renderable": {
"editor_groups": [self.eg.name, self.another_eg.name]
},
"script": {
"script_name": "approaching_flag_deadline",
"title": "Run background task"
}
}

def create_accounts(self):
admin_name = self.create_random_str()
def create_accounts(self, random_str):

admin_name = "LordWiggleworth_" + random_str
self.admin_password = self.create_random_str()
self.admin = models.Account.make_account(admin_name + "@example.com", admin_name, "FlagsManed " + admin_name,
["admin", "editor"])
self.admin.set_password(self.admin_password)
self.admin.save()

random_name = self.create_random_str()
anotheradmin_name = "ProfessorQuibbleton_" + random_str
self.anotheradmin_password = self.create_random_str()
self.anotheradmin = models.Account.make_account(anotheradmin_name + "@example.com", anotheradmin_name, "Admin " + anotheradmin_name,
["admin", "editor"])
self.anotheradmin.set_password(self.anotheradmin_password)
self.anotheradmin.save()

random_name = "BaronFeatherfall_" + random_str
self.random_user_password = self.create_random_str()
self.random_user = models.Account.make_account(random_name + "@example.com", random_name,
"FlagsManed " + random_name,
"Admin " + random_name,
["admin"])
self.random_user.set_password(self.random_user_password)
self.random_user.save()

editor_name = self.create_random_str()
self.editor = models.Account.make_account(editor_name + "@example.com", editor_name, "editor " + editor_name,
editor_name = "MadamPonderleaf_" + random_str
self.editor = models.Account.make_account(editor_name + "@example.com", editor_name, "Editor " + editor_name,
["editor"])
self.editor_password = self.create_random_str()
self.editor.set_password(self.editor_password)
Expand All @@ -80,90 +98,77 @@ def create_accounts(self):
self.another_eg.set_editor(self.editor.id)
self.another_eg.save()

def build_applications(self):
applications = [
def build_journals(self, random_str):
journals = [
{
"type": models.Journal,
"title": "Journal of Quantum Homeopathy",
"title": "Journal of Quantum Homeopathy " + random_str,
"assigned_to": self.admin.id,
"flagged_to": self.admin.id,
"group": self.eg.name,
"deadline": 2,
"note": "Peer review process unclear. The journal claims to use “ancient wisdom and telepathic consensus” to select papers. Should we request further clarification, or just accept that the universe decides?"
},
{
"type": models.Application,
"title": "The Mars Agricultural Review",
"application_type": constants.APPLICATION_TYPE_NEW_APPLICATION,
"status": "in progress",
"type": models.Journal,
"title": "The Mars Agricultural Review " + random_str,
"assigned_to": self.editor.id,
"flagged_to": self.admin.id,
"group": self.eg.name,
"deadline": 10,
"note": "Ethical concerns? Their conflict of interest statement is just 'Trust us.' Also, every editorial board member shares the same last name. Suspicious? Or just an enthusiastic family business?"
},
{
"type": models.Application,
"title": "Cryptid Behavioral Studies Quarterly",
"application_type": constants.APPLICATION_TYPE_UPDATE_REQUEST,
"type": models.Journal,
"title": "Cryptid Behavioral Studies Quarterly " + random_str,
"assigned_to": self.editor.id,
"flagged_to": self.admin.id,
"group": self.eg.name,
"note": "Formatting issues. Their abstracts are in Comic Sans, their references are in Wingdings, and their figures appear to be hand-drawn with crayon. Surprisingly, it almost adds to the charm."
},
{
"type": models.Application,
"title": "The Bermuda Triangle Journal of Lost and Found",
"application_type": constants.APPLICATION_TYPE_NEW_APPLICATION,
"status": "on hold",
"type": models.Journal,
"title": "The Bermuda Triangle Journal of Lost and Found " + random_str,
"assigned_to": self.editor.id,
"flagged_to": self.editor.id,
"group": self.eg.name,
"note": "Reviewer qualifications unclear. The journal states that all peer reviews are conducted by 'a highly trained team of clairvoyant pigeons.' While I admire their commitment to interdisciplinary methods, I feel we should request ORCID iDs… or at least some proof that the pigeons exist."
},
{
"type": models.Journal,
"title": "Feline Aerodynamics Review",
"title": "Feline Aerodynamics Review " + random_str,
"assigned_to": self.admin.id,
"group": self.eg.name
},
{
"type": models.Application,
"title": "Journal of Intergalactic Diplomacy",
"application_type": constants.APPLICATION_TYPE_NEW_APPLICATION,
"type": models.Journal,
"title": "Journal of Intergalactic Diplomacy " + random_str,
"assigned_to": self.random_user.id,
"flagged_to": self.admin.id,
"group": self.another_eg.name,
"deadline": 0,
"note": "Editorial process... innovative? They claim to have a 100% acceptance rate because “rejecting knowledge is against our values.” Admirable, but I feel like that’s not how this works."
},
{
"type": models.Application,
"title": "Applied Alchemy & Unstable Chemistry",
"application_type": constants.APPLICATION_TYPE_UPDATE_REQUEST,
"type": models.Journal,
"title": "Applied Alchemy & Unstable Chemistry " + random_str,
"assigned_to": self.random_user.id,
"flagged_to": self.editor.id,
"note": "Journal scope mismatch. The journal is called The International Review of Advanced Neuroscience but 90\% of its articles are about cat memes. Honestly, I’d subscribe, but should we approve it?",
"group": self.another_eg.name
}
]

for record in applications:
source = ApplicationFixtureFactory.make_application_source()
ap = models.Application(**source)
if "application_type" in record:
source["admin"]["application_type"] = record["application_type"]
for record in journals:
source = JournalFixtureFactory.make_journal_source(True)
ap = models.Journal(**source)
bj = ap.bibjson()
bj.title = record["title"]
ap.set_id(ap.makeid())
ap.set_last_manual_update(dates.today())
ap.set_created(dates.before_now(200))
ap.remove_current_journal()
ap.remove_related_journal()
ap.set_editor_group(record["group"])
ap.set_editor(record["assigned_to"])
if "status" in record:
ap.set_application_status(record["status"])
if "flagged_to" in record:
note = {"id": self.create_random_str(),
"note": record["note"],
Expand All @@ -176,14 +181,16 @@ def build_applications(self):
}}
ap.set_notes(note)
ap.save()
self.apps.append(ap.id)
self.journals.append(ap.id)

return self.journals

def teardown(self, params):
for acc in params.get("accounts").values():
models.Account.remove_by_id(acc["username"])

for app in params.get("applications"):
models.Application.remove_by_id(app)
for app in params.get("journals"):
models.Journal.remove_by_id(app)

print(params.get("non_renderable"))
print(params.get("non_renderable").get("editor_groups"))
Expand Down
Loading