Coverage for portality/ui/messages.py: 98%
162 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-20 13:43 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-20 13:43 +0000
1from flask import flash
4class Messages(object):
5 ADMIN__QUICK_REJECT__NO_OWNER = """There is no user attached to this application.
6 <a href="https://testdoaj.cottagelabs.com/account/register" target="_blank">Assign a user account first</a>."""
8 PUBLISHER_APPLICATION_UPDATE_SUBMITTED_FLASH = ("""
9 Your update request has been submitted. You may make further changes until the DOAJ Editorial Team picks it up
10 for review. Click the 'Edit' button to make further changes or 'Delete' to cancel the request.
11 """, 'success')
12 PUBLISHER_UPLOAD_ERROR = """An error has occurred and your upload did not succeed. {error_str} <br \> If the problem persists, please send the error details from the Notes column of the History of Uploads box below and a screenshot of the entire error message"""
13 NO_FILE_UPLOAD_ID="""No file upload record has been specified"""
15 ARTICLE_METADATA_SUBMITTED_FLASH = ("<a href='{url}' target='_blank'>Article created/updated</a>", "success")
16 ARTICLE_METADATA_MERGE_CONFLICT = ("""Article could not be submitted, as it matches more than one existing article.
17 Please check your metadata, and contact us if you cannot resolve the issue yourself.""", "error")
18 ARTICLE_METADATA_UPDATE_CONFLICT = ("""Article could not be updated, as it matches another existing article.
19 Please check your metadata, and contact us if you cannot resolve the issue yourself.""", "error")
21 # Account-related flash messages (from portality/view/account.py)
22 ACCOUNT__PWLESS__RESEND_RATE_LIMIT = (
23 "You requested a code recently. Please wait {wait} before trying again.",
24 "error",
25 )
26 ACCOUNT__PWLESS__EMAIL_SENT = (
27 "A login link along with login code has been sent to your email.",
28 "success",
29 )
30 ACCOUNT__PWLESS__EMAIL_ERROR = (
31 "There was a problem generating the login email.",
32 "error",
33 )
34 ACCOUNT__EMAIL_REQUIRED_FOR_RESEND = (
35 "Email address is required to resend the code.",
36 "error",
37 )
38 ACCOUNT__NOT_RECOGNISED = "Account not recognised."
39 ACCOUNT__REQUIRED_PARAMS_NOT_AVAILABLE = "Required parameters not available."
40 ACCOUNT__INVALID_OR_EXPIRED_CODE = "Invalid or expired verification code"
41 ACCOUNT__WELCOME_BACK = ("Welcome back.", "success")
42 ACCOUNT__STATUS_LOGIN_FAILED = ("Login could not be completed due to account status.", "error")
43 ACCOUNT__REQUEST_PROBLEM = ("There was a problem with your request.", "error")
44 ACCOUNT__RESET_EMAIL_SENT = "Instructions to reset your password have been sent to you. Please check your emails."
45 ACCOUNT__PASSWORDS_NOT_MATCH = ("Passwords do not match - please try again", "error")
46 ACCOUNT__PASSWORD_SET_AND_LOGGED_IN = ("New password has been set and you're now logged in.", "success")
47 ACCOUNT__LOGGED_OUT = ("You are now logged out", "success")
48 ACCOUNT__VERIFY_EMAIL_TO_SET_PASSWORD = (
49 "Thank you, please verify email address {email} to set your password and verify your account.",
50 "success",
51 )
52 ACCOUNT__PLEASE_CORRECT_ERRORS = ("Please correct the errors", "error")
53 ACCOUNT__CONFIRM_CHECKBOX_REQUIRED = ("Check the box to confirm you really mean it!", "error")
54 ACCOUNT__DELETED = "Account {id} deleted"
55 ACCOUNT__RECORD_UPDATED = "Record updated"
56 ACCOUNT__EMAIL_UPDATED_LOGGED_OUT = (
57 "Email address updated. You have been logged out for email address verification.",
58 "success",
59 )
61 CONCURRENT_UPDATE_REQUEST = """You have submitted an Update Request for the same journal in a short period of time. If this is in error, you don't need to do anything, your first request is being processed. If this was intentional, please try again in a moment."""
63 SENT_ACCEPTED_APPLICATION_EMAIL = """Sent notification to '{user}' to tell them that their journal was accepted."""
64 SENT_REJECTED_APPLICATION_EMAIL_TO_OWNER = """Sent notification to user '{user}' to tell them that their journal application was rejected."""
65 SENT_ACCEPTED_UPDATE_REQUEST_EMAIL = """Sent notification to '{user}' to tell them that their journal update was accepted."""
66 SENT_REJECTED_UPDATE_REQUEST_EMAIL = """Sent email to user '{user}' ({name}, {email}) to tell them that their journal update was rejected."""
67 SENT_REJECTED_UPDATE_REQUEST_REVISIONS_REQUIRED_EMAIL = """Sent email to user '{user}' to tell them that their journal update requires revisions. You will need to contact them separately with details."""
68 SENT_JOURNAL_CONTACT_ACCEPTED_APPLICATION_EMAIL = """Sent email to journal contact '{email}' to tell them their journal was accepted."""
69 SENT_JOURNAL_CONTACT_ACCEPTED_UPDATE_REQUEST_EMAIL = """Sent email to journal contact '{email}' to tell that an update to their journal was accepted."""
70 SENT_JOURNAL_CONTACT_IN_PROGRESS_EMAIL = """An email has been sent to the Journal Contact alerting them that you are working on their application."""
71 SENT_JOURNAL_CONTACT_ASSIGNED_EMAIL = """An email has been sent to the Journal Contact alerting them that an editor has been assigned to their application."""
73 NOT_SENT_ACCEPTED_APPLICATION_EMAIL = """Did not send notification to '{user}' to tell them that their journal was accepted. Email may be disabled, or there is a problem with the email address."""
74 NOT_SENT_REJECTED_APPLICATION_EMAILS = """Did not send email to user '{user}' or application suggester to tell them that their journal was rejected Email may be disabled, or there is a problem with the email address."""
75 NOT_SENT_ACCEPTED_UPDATE_REQUEST_EMAIL = """Did not send notification to '{user}' to tell them that their update was accepted Email may be disabled, or there is a problem with the email address."""
76 NOT_SENT_REJECTED_UPDATE_REQUEST_EMAIL = """Did not send email to user '{user}' to tell them that their update was rejected. Email may be disabled, or there is a problem with the email address"""
77 NOT_SENT_REJECTED_UPDATE_REQUEST_REVISIONS_REQUIRED_EMAIL = """Did not send email to user '{user}' to tell them that their update required revisions. Email may be disabled, or there is a problem with the email address"""
78 NOT_SENT_JOURNAL_CONTACT_ACCEPTED_APPLICATION_EMAIL = """Did not send email to '{email}' to tell them that their application/update request was accepted. Email may be disabled, or there is a problem with the email address"""
79 NOT_SENT_JOURNAL_CONTACT_IN_PROGRESS_EMAIL = """An email could not be sent to the Journal Contact alerting them that you are working on their application. Email may be disabled, or there is a problem with the email address"""
80 NOT_SENT_JOURNAL_CONTACT_ASSIGNED_EMAIL = """An email could not be sent to the Journal Contact alerting them that an editor has been assigned to their application. Email may be disabled, or there is a problem with the email address"""
82 IN_PROGRESS_NOT_SENT_EMAIL_DISABLED = """Did not send email to Owner or Journal Contact about the status change, as publisher emails are disabled."""
84 DIFF_TABLE_NOT_PRESENT = """-- Not held in journal metadata --"""
86 REJECT_NOTE_WRAPPER = """{editor}: This application was rejected with the reason '{note}'"""
88 EXCEPTION_ARTICLE_BATCH_DUPLICATE = "One or more articles in this batch have duplicate identifiers"
89 EXCEPTION_ARTICLE_BATCH_FAIL = "One or more articles failed to ingest; entire batch ingest halted"
90 EXCEPTION_ARTICLE_BATCH_CONFLICT = "One or more articles in this batch matched multiple articles as duplicates; entire batch ingest halted"
91 EXCEPTION_DETECT_DUPLICATE_NO_ID = "The article you provided has neither doi nor fulltext URL, and as a result cannot be deduplicated"
92 EXCEPTION_ARTICLE_MERGE_CONFLICT = "The article matched multiple existing articles as duplicates, and we cannot tell which one to update"
93 EXCEPTION_NO_DOI_NO_FULLTEXT = "The article must have a DOI and/or a Full-Text URL"
94 EXCEPTION_ARTICLE_OVERRIDE = "Cannot update the article. An article with this URL and DOI already exists. If you are sure you want to replace it please delete it and then re-create it."
95 EXCEPTION_SCRIPT_TAG_FOUND = "Metadata contains <script> tag. Please remove any <script> tags from your metadata and try again."
96 EXCEPTION_ADDING_ARTICLE_TO_WITHDRAWN_JOURNAL = "You are trying to add the articles to a journal that has been withdrawn from DOAJ. We accept articles only for journals currently in DOAJ"
98 EXCEPTION_NO_CONTRIBUTORS_FOUND = "No contributors found."
99 EXCEPTION_NO_CONTRIBUTORS_EXPLANATION = "DOAJ requires at least one author for each article."
101 EXCEPTION_TOO_MANY_ISSNS = "Too many ISSNs. Only 2 ISSNs are allowed: one Print ISSN and one Online ISSN."
102 EXCEPTION_MISMATCHED_ISSNS = "ISSNs provided don't match any journal."
103 EXCEPTION_ISSNS_OF_THE_SAME_TYPE = "Both ISSNs have the same type: {type}"
104 EXCEPTION_IDENTICAL_PISSN_AND_EISSN = "The Print and Online ISSNs supplied are identical. If you supply two ISSNs, they must be different."
105 EXCEPTION_NO_ISSNS = "Neither the Print ISSN nor Online ISSN have been supplied. DOAJ requires at least one ISSN."
106 EXCEPTION_INVALID_BIBJSON = "Invalid article bibjson: " # + Dataobj exception message
108 EXCEPTION_IDENTIFIER_CHANGE_CLASH = "DOI or Fulltext URL has been changed to match another article that already exists in DOAJ"
109 EXCEPTION_IDENTIFIER_CHANGE = "Either the DOI or Fulltext URL has been changed. This operation is not permitted; please contact an administrator for help."
110 EXCEPTION_DUPLICATE_NO_PERMISSION = "You do not have permission to carry out the requested change"
112 EXCEPTION_EDITING_ACCEPTED_JOURNAL = "You cannot edit applications which have been accepted into DOAJ."
113 EXCEPTION_EDITING_WITHDRAWN_JOURNAL = "This journal has been withdrawn, update request cannot be accepted."
114 EXCEPTION_EDITING_DELETED_JOURNAL = "This journal has been deleted, update request cannot be accepted."
115 EXCEPTION_EDITING_NON_EXISTING_APPLICATION = "You cannot edit a not-existent application"
117 EXCEPTION_NOTIFICATION_NO_ACCOUNT = "Account with id `{x}` not found"
118 EXCEPTION_NOTIFICATION_NO_EMAIL = "Account with id {x} does not have an email address"
119 EXCEPTION_NOTIFICATION_NO_NOTIFICATION = "Notification with id {n} does not exist"
121 EXCEPTION_NOTIFICATION_JOURNAL_NOT_FOUND = "Journal with id {x} not found"
123 EXCEPTION_UNABLE_TO_CONSTRUCT_JOURNAL = "Unable to construct Journal from supplied source - data structure validation error, {x}"
124 EXCEPTION_UNABLE_TO_CONSTRUCT_ACCOUNT = "Unable to construct Account from supplied source - data structure validation error, {x}"
127 PREVENT_DEEP_PAGING_IN_API = """You cannot access results beyond {max_records} records via this API.
128 If you would like to see more results, you can download all of our data from
129 {data_dump_url}. You can also harvest from our OAI-PMH endpoints; articles: {oai_article_url}, journals: {oai_journal_url}"""
131 FORMS__APPLICATION_PROCESSORS__NEW_APPLICATION__FINALISE__USER_EMAIL_ERROR = "We were unable to send you an email confirmation - possible problem with the email address provided"
132 FORMS__APPLICATION_PROCESSORS__NEW_APPLICATION__FINALISE__LOG_EMAIL_ERROR = 'Error sending application received email.'
133 FORMS__APPLICATION_PROCESSORS__ADMIN_APPLICATION__FINALISE__COULD_NOT_UNREJECT = "Could not unreject application, as a new Update Request for the journal now exists"
134 FORMS__APPLICATION_PROCESSORS__ASSOCIATE_APPLICATION__FINALISE__STATUS_COMPLETED_NOTIFIED = "A confirmation email has been sent to notify the editor of the change in status."
136 BLL__UNREJECT_APPLICATION__NO_APPLICATION = "You must supply an application to unreject_application"
137 BLL__UNREJECT_APPLICATION__NO_ACCOUNT = "You must supply an account to unreject_application"
138 BLL__UNREJECT_APPLICATION__WRONG_ROLE = "This user is not allowed to unreject applications"
139 BLL__UNREJECT_APPLICATION__ILLEGAL_STATE_REJECTED = "The application {id} is in 'rejected' state; place it into the correct new state before calling unreject_application"
140 BLL__UNREJECT_APPLICATION__ILLEGAL_STATE_DISALLOWED = "The application {id} is in '{x}' status, which is disallowed in this call context"
141 BLL__UNREJECT_APPLICATION__DUPLICATE_UR = """Creating an update request from rejected application {id} is not possible as another application {urid} exists which is an update request for journal {jid}"""
142 BLL__UNREJECT_APPLICATION__JOURNAL_MISSING = "Journal {jid} related to application {id} does not exist"
143 BLL__UNREJECT_APPLICATION__SAVE_FAIL = "Save on {obj} {id} in unreject_application failed"
145 ADMIN__WITHDRAW_REINSTATE = "<a href='{url}'>Job to withdraw/reinstate journal has been submitted</a>"
147 CANNOT_CHANGE_THE_STATUS__OTHER_JOURNAL_IN_DOAJ_EXISTS = "The journal could not be reinstated because at least one other record with matching ISSN(s) already exists in DOAJ"
149 AUTOMATICALLY_REJECTED_UPDATE_REQUEST_NOTE = "Update request was automatically rejected because the associated journal was withdrawn or deleted."
150 AUTOMATICALLY_REJECTED_UPDATE_REQUEST_WITH_ID = "Update request {urid} automatically rejected"
151 NO_UPDATE_REQUESTS = "No update requests found."
153 LAST_FULL_REVIEW_NOTE = "Last full review completed on {date} by `{username}`"
154 OWNER_CHANGED_NOTE = "Owner changed from `{old_owner}` to `{new_owner}` by `{changed_by}` on {date}"
155 JOURNAL_REINSTATED_NOTE = "Journal reinstated into DOAJ by `{username}` on {date}."
156 JOURNAL_WITHDRAWN_NOTE = "Journal withdrawn from DOAJ by `{username}` on {date}."
158 BULK_JOURNAL_DELETE = "About to delete an estimated {journal_no} journals with {article_no} articles associated with their ISSNs. Existing update requests will be automatically rejected."
159 BULK_JOURNAL_DELETE_COMPLETED = "Deleted {journal_no} journals and all articles associated with their ISSNs."
161 NOTIFY__DEFAULT_SHORT_NOTIFICATION = "You have a new notification"
162 NOTIFY__DEFAULT_ACTION_INTRO = "To take action based on this notification, follow this link: "
164 DISCONTINUED_JOURNAL_FOUND_LOG = "Journal discontinuing soon found: {id}"
165 DISCONTINUED_JOURNALS_FOUND_NOTIFICATION_SENT_LOG = "Notification with journals discontinuing soon sent."
166 DISCONTINUED_JOURNALS_FOUND_NOTIFICATION_ERROR_LOG = "Error sending notification with journals discontinuing soon."
167 NO_DISCONTINUED_JOURNALS_FOUND_LOG = "No journals discontinuing soon found"
169 JOURNALS_WITH_APPROACHING_DEADLINES_FOUND = "Journal with deadline in {delta} days found: {id}"
170 JOURNALS_WITH_APPROACHING_DEADLINES_FOUND_NOTIFICATION_SENT_LOG = "Notification with approaching deadlines sent."
171 NO_JOURNALS_WITH_APPROACHING_DEADLINES_FOUND_LOG = "No approaching deadlines found."
173 FORMS__APPLICATION_STATUS__PENDING = "Pending"
174 FORMS__APPLICATION_STATUS__IN_PROGRESS = 'In Progress'
175 FORMS__APPLICATION_STATUS__COMPLETED = 'Completed'
176 FORMS__APPLICATION_STATUS__POST_SUBMISSION_REVIEW = 'Post Submission Automation'
177 FORMS__APPLICATION_STATUS__UPDATE_REQUEST = 'Update Request'
178 FORMS__APPLICATION_STATUS__REVISIONS_REQUIRED = 'Revisions Required'
179 FORMS__APPLICATION_STATUS__ON_HOLD = 'On Hold'
180 FORMS__APPLICATION_STATUS__READY = 'Ready'
181 FORMS__APPLICATION_STATUS__REJECTED = 'Rejected'
182 FORMS__APPLICATION_STATUS__ACCEPTED = 'Accepted'
184 JOURNAL_CSV_VALIDATE__HEADER_CASE_MISMATCH = '"{h}" has a mismatching case to the expected header "{expected}".'
185 JOURNAL_CSV_VALIDATE__INVALID_HEADER = '"{h}" is not a valid column header. Please revert it to match what was sent to you in the original file.'
186 JOURNAL_CSV_VALIDATE__REQUIRED_HEADER_MISSING = '"{h}" is a required column missing from this upload. Please refer to the original file and restore the column.'
187 JOURNAL_CSV_VALIDATE__MISSING_JOURNAL = "There is no journal record in DOAJ for ISSN(s) {issns}. The record may not exist, or it may be withdrawn."
188 JOURNAL_CSV_VALIDATE__OWNER_MISMATCH = "Your account '{acc}' doesn't own the journal with ISSN(s) {issns}. You may not update it."
189 JOURNAL_CSV_VALIDATE__NO_DATA_CHANGE = "The data you supplied didn't change anything in the journal record."
190 JOURNAL_CSV_VALIDATE__QUESTION_CANNOT_CHANGE = 'You may not change "{question}". Please revert it to match what was sent to you in the original file.'
191 JOURNAL_CSV_VALIDATE__CANNOT_MAKE_UR = "We couldn't create an update for this journal because: {reason}"
192 JOURNAL_CSV_VALIDATE__INVALID_DATA = "We couldn't understand the information in '{question}'"
194 PRESERVATION_NO_FILE = "No file provided for upload"
196 ARE_YOU_A_HUMAN = "Are you sure you're a human? If you're having trouble logging in, please <a href='/contact'>contact us</a>."
198 AUTOASSIGN__OWNER_MAPPED = "owner '{owner}' is mapped to editor group '{target}'"
199 AUTOASSIGN__COUNTRY_MAPPED = "country '{country}' ({country_code}) is mapped to editor group '{target}'"
200 AUTOASSIGN__NOTE__EDITOR_GROUP_MISSING = "Autoassign: Editor group '{target}' does not exist, cannot auto assign"
201 AUTOASSIGN__NOTE__ASSIGN = "Autoassign: Editor group auto assigned to '{target}' because {reason}"
203 FORMS__APPLICATION_FLAG__RESOLVED = "Flag resolved on {date} by {username}; \n Original flag: created on {created_date}, by {author}, assigned to {assignee}, deadline {deadline}. \n Note: {note}"
204 FORMS_APPLICATION_FLAG__PAST_DEADLINE_WARNING = "Provided deadline is in the past. Is it correct?"
206 ARTICLE_BELONGS_TO_TOO_MANY_JOURNALS = "Article found that belongs to more than 1 journal. Article's id: {article_id}"
207 ARTICLE_ABANDONED_LOG = """An article was found that doesn't seem to match any journal articles\'s id: {article.id}"""
208 ARTICLE_ABANDONED_PUBLIC = """This article doesn't seem to match any journal in our database. If you think this is wrong, contact us quoting 'Abandoned article: {article.id}'"""
209 ARTICLE_NOT_FOUND = "We couldn't find this article"
211 TOO_MANY_JOURNALS = """This identifier seems to match more than one journal. Please contact us quoting 'More than one journal found with identifier: {identifier}'"""
212 TOO_MANY_JOURNALS_LOG = """More than one journal found with identifier: {identifier}'"""
214 DEFAULT_500_DESCRIPTION = "An error has occurred. It looks like something has gone wrong."
216 JOURNAL__YOU_ARE_NOT_OWNER = "You are not the owner of a journal you're trying to access. Here are the journals associated with your account."
218 @classmethod
219 def flash(cls, tup):
220 if isinstance(tup, tuple):
221 flash(tup[0], tup[1])
222 else:
223 flash(tup)
225 @classmethod
226 def flash_with_url(cls, message, category):
227 flash(message, category + '+contains-url')
229 @classmethod
230 def flash_with_param(cls, message, category="error", **kwargs):
231 for key, value in kwargs.items():
232 if key != "message" or key != "category":
233 message = message + (" {0}: {1},".format(key, value))
234 flash(message, category)