Skip to content

Commit

Permalink
Merge branch 'master' into static_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Eardley committed Sep 13, 2023
2 parents 17b4b33 + a4a9876 commit 271d0a3
Show file tree
Hide file tree
Showing 28 changed files with 271 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cms/sass/components/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
border-left: 1px solid $sanguine;
}

.form__long-help {
.form__long-help, .form__click-to-copy {
cursor: pointer;

&:hover {
Expand Down
5 changes: 5 additions & 0 deletions cms/sass/components/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@
color: $white;
}
}

.tag--confirmation {
background: $dark-green;
color: $white;
}
54 changes: 41 additions & 13 deletions deploy/nginx/doaj
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,27 @@ map $http_user_agent $block_ua {
~*curl 1;
}

# the public server (deprecated, use failover)
upstream doaj_apps {
server 10.131.191.139:5050;
server 10.131.191.139:5050; #doaj-public-app-1
}

# Background server runs async tasks
upstream doaj_bg_apps {
#server 10.131.56.133:5050; #old bg machine
server 10.131.12.33:5050;
server 10.131.12.33:5050; #doaj-background-app-1
}

# Editor and admin site components
upstream doaj_ed_failover {
server 10.131.56.133:5050; #doaj-editor-app-1
server 10.131.12.33:5050 backup; #doaj-background-app-1
}

# For public site components, try all servers
upstream doaj_apps_failover {
server 10.131.191.139:5050;
#server 10.131.56.133:5050 backup; #old bg machine
server 10.131.12.33:5050 backup;
server 10.131.191.139:5050; #doaj-public-app-1
server 10.131.12.33:5050 backup; #doaj-background-app-1
server 10.131.56.133:5050 backup; #doaj-editor-app-1
}
upstream doaj_index {
server 10.131.191.132:9200;
Expand Down Expand Up @@ -121,6 +131,7 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

location /search {
if ($block_ua) {return 403;}
limit_req zone=general burst=10 nodelay;
Expand All @@ -144,9 +155,7 @@ server {
proxy_buffering off;
}

# for now we are going to send all login functions to the bg machine
# technically ONLY the routes that require file upload need to go to the bg machine
# but we think it is handy to separate them out, and later we could send them to other machines
# technically only the routes that require file upload need to go to the bg machine, but separate for consistency
location /account {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
Expand All @@ -157,6 +166,19 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

# prefer the editor machine for application form work (but application_quick_reject goes to background async)
location ~* /admin/application/ {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_ed_failover;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

location /admin { # there are admin bulk actions that MUST go to bg machine
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
Expand All @@ -167,27 +189,30 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

location /editor {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_pass http://doaj_ed_failover;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

location /journal/readonly {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_pass http://doaj_ed_failover;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
location /publisher { # only /publisher/uploadfile MUST go to bg, and /publisher/uploadFile

location /publisher { # only /publisher/uploadfile MUST go to background
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
Expand All @@ -197,7 +222,8 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
location /service {

location /service { # performs locks etc - handle on the background server
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
Expand All @@ -221,6 +247,7 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}

location /csv {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
Expand All @@ -235,6 +262,7 @@ server {
location =/robots.txt {
alias /home/cloo/doaj/src/doaj/deploy/robots-production.txt;
}

location /static/ {
alias /home/cloo/doaj/src/doaj/portality/static/;
autoindex off;
Expand Down
6 changes: 6 additions & 0 deletions doajtest/testbook/journal_form/associate_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ tests:
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted

6 changes: 6 additions & 0 deletions doajtest/testbook/journal_form/editor_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ tests:
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
6 changes: 6 additions & 0 deletions doajtest/testbook/journal_form/maned_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ tests:
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ tests:
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
8 changes: 7 additions & 1 deletion doajtest/testbook/new_application_form/editor_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ tests:
- you are unable to edit the note
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
6 changes: 6 additions & 0 deletions doajtest/testbook/new_application_form/maned_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ tests:
- step: Attempt to click the "Remove" button
results:
- You are unable to delete the note
- step: Click "copy" button next to one of the fields (eg. Title)
results:
- Confirmation with fields value is displayed for 3 seconds
- step: Attempt to paste the value (use separate editor)
results:
- Correct value is pasted
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ def editor_account_pull(self, _id):
ACTUAL_ACCOUNT_PULL = models.Account.pull

# A regex string for searching the log entries
email_log_regex = 'template.*%s.*to:\[u{0,1}\'%s.*subject:.*%s'
email_log_regex = r'template.*%s.*to:\[u{0,1}\'%s.*subject:.*%s'

# A string present in each email log entry (for counting them)
email_count_string = 'Email template'

NOTIFICATIONS_INTERCEPT = []


class TestPublicApplicationEmails(DoajTestCase):
def setUp(self):
super(TestPublicApplicationEmails, self).setUp()
Expand Down
8 changes: 8 additions & 0 deletions doajtest/unit/test_formrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
# Form context for basic test
################################################################


class TestForm(Form):
__test__ = False # Prevent collection by PyTest
one = StringField("One")
two = StringField("Two")


class TestRenderer(Renderer):
__test__ = False # Prevent collection by PyTest

def __init__(self):
super(TestRenderer, self).__init__()
self.FIELD_GROUPS = {
Expand All @@ -20,7 +25,10 @@ def __init__(self):
]
}


class TestContext(FormContext):
__test__ = False # Prevent collection by PyTest

def data2form(self):
self.form = TestForm(formdata=self.form_data)

Expand Down
2 changes: 1 addition & 1 deletion doajtest/unit/test_oaipmh.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_06_identify(self):
records = t.xpath('/oai:OAI-PMH/oai:Identify', namespaces=self.oai_ns)
assert len(records) == 1
assert records[0].xpath('//oai:repositoryName', namespaces=self.oai_ns)[0].text == 'Directory of Open Access Journals'
assert records[0].xpath('//oai:adminEmail', namespaces=self.oai_ns)[0].text == '[email protected]'
assert records[0].xpath('//oai:adminEmail', namespaces=self.oai_ns)[0].text == '[email protected]'
assert records[0].xpath('//oai:granularity', namespaces=self.oai_ns)[0].text == 'YYYY-MM-DDThh:mm:ssZ'

def test_07_bad_verb(self):
Expand Down
2 changes: 1 addition & 1 deletion portality/bll/services/background_task_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create_queues_status(self, queue_name) -> dict:
# prepare for err_msgs
limited_sec = app.config.get('BG_MONITOR_LAST_COMPLETED', {}).get(queue_name)
if limited_sec is None:
app.logger.warn(f'BG_MONITOR_LAST_COMPLETED for {queue_name} not found ')
app.logger.warning(f'BG_MONITOR_LAST_COMPLETED for {queue_name} not found ')

err_msgs = []
if limited_sec is not None and last_completed_date:
Expand Down
4 changes: 2 additions & 2 deletions portality/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ def initialise_index(app, conn, only_mappings=None):
:return:
"""
if not app.config['INITIALISE_INDEX']:
app.logger.warn('INITIALISE_INDEX config var is not True, initialise_index command cannot run')
app.logger.warning('INITIALISE_INDEX config var is not True, initialise_index command cannot run')
return

if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, initialise_index command cannot run")
app.logger.warning("System is in READ-ONLY mode, initialise_index command cannot run")
return

# get the app mappings
Expand Down
14 changes: 7 additions & 7 deletions portality/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def save(self, retries=0, back_off_factor=1, differentiate=False, blocking=False
:return:
"""
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, save command cannot run")
app.logger.warning("System is in READ-ONLY mode, save command cannot run")
return

if retries > app.config.get("ES_RETRY_HARD_LIMIT", 1000): # an arbitrary large number
Expand Down Expand Up @@ -220,7 +220,7 @@ def save(self, retries=0, back_off_factor=1, differentiate=False, blocking=False

def delete(self):
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, delete command cannot run")
app.logger.warning("System is in READ-ONLY mode, delete command cannot run")
return

# r = requests.delete(self.target() + self.id)
Expand Down Expand Up @@ -313,7 +313,7 @@ def bulk(cls, documents: List[dict], idkey='id', refresh=False, action='index',
"""
# ~~->ReadOnlyMode:Feature~~
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, bulk command cannot run")
app.logger.warning("System is in READ-ONLY mode, bulk command cannot run")
return

if action not in ['index', 'update', 'delete']:
Expand Down Expand Up @@ -363,7 +363,7 @@ def refresh(cls):
:return:
"""
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, refresh command cannot run")
app.logger.warning("System is in READ-ONLY mode, refresh command cannot run")
return

# r = requests.post(cls.target() + '_refresh', headers=CONTENT_TYPE_JSON)
Expand Down Expand Up @@ -449,7 +449,7 @@ def send_query(cls, qobj, retry=50, **kwargs):
@classmethod
def remove_by_id(cls, id):
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, delete_by_id command cannot run")
app.logger.warning("System is in READ-ONLY mode, delete_by_id command cannot run")
return

# r = requests.delete(cls.target() + id)
Expand All @@ -461,7 +461,7 @@ def remove_by_id(cls, id):
@classmethod
def delete_by_query(cls, query):
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, delete_by_query command cannot run")
app.logger.warning("System is in READ-ONLY mode, delete_by_query command cannot run")
return

#r = requests.delete(cls.target() + "_query", data=json.dumps(query))
Expand All @@ -472,7 +472,7 @@ def delete_by_query(cls, query):
@classmethod
def destroy_index(cls):
if app.config.get("READ_ONLY_MODE", False) and app.config.get("SCRIPTS_READ_ONLY_MODE", False):
app.logger.warn("System is in READ-ONLY mode, destroy_index command cannot run")
app.logger.warning("System is in READ-ONLY mode, destroy_index command cannot run")
return

# if app.config['ELASTIC_SEARCH_INDEX_PER_TYPE']:
Expand Down
Loading

0 comments on commit 271d0a3

Please sign in to comment.