-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/3573 autocheck article uploaded #2377
base: develop
Are you sure you want to change the base?
Changes from 7 commits
b0dfc6b
edcd98a
c90cda0
dcd962a
969c687
3dcc38d
96ac2eb
d2f234d
f5c4c8e
9532667
e52ca45
628ecf4
f415303
b1daabf
ee1b642
56a56ea
f768d1b
5e9f946
c8f3e73
a05f6f6
ad0c19c
161a013
c12c2ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
|
||
from doajtest import helpers | ||
from doajtest.fixtures import JournalFixtureFactory | ||
from doajtest.fixtures.accounts import create_maned_a | ||
from doajtest.helpers import DoajTestCase | ||
from portality import models | ||
from portality.util import url_for | ||
|
||
|
||
class TestViewAdmin(DoajTestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.acc = create_maned_a(is_save=True) | ||
|
||
def test_journal_article_info(self): | ||
journal = models.Journal( | ||
**JournalFixtureFactory.make_journal_source() | ||
) | ||
journal.save(blocking=True) | ||
models.Journal.refresh() | ||
|
||
with self.app_test.test_client() as client: | ||
resp = helpers.login(client, self.acc.email, 'password') | ||
assert resp.status_code == 200 | ||
|
||
resp = client.get(url_for("admin.journal_article_info", journal_id=journal.id)) | ||
assert resp.status_code == 200 | ||
assert json.loads(resp.data) == {'n_articles': 0} | ||
|
||
def test_journal_article_info__not_found(self): | ||
with self.app_test.test_client() as client: | ||
helpers.login(client, self.acc.email, 'password') | ||
|
||
resp = client.get(url_for("admin.journal_article_info", journal_id='aksjdlaksjdlkajsdlkajsdlk')) | ||
assert resp.status_code == 404 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
| Short | Description | | ||
|---------|------------------------------| | ||
| bgjob | background job | | ||
| noti | notification | | ||
| noqa | NO-QA (NO Quality Assurance) | | ||
| inst | instance | | ||
| fmt | format | | ||
| exparam | extra parameter | | ||
| maned | Managing Editor | | ||
| gsheet | Google Sheet | | ||
| Short | Description | | ||
|----------|------------------------------| | ||
| bgjob | background job | | ||
| noti | notification | | ||
| noqa | NO-QA (NO Quality Assurance) | | ||
| inst | instance | | ||
| fmt | format | | ||
| exparam | extra parameter | | ||
| maned | Managing Editor | | ||
| gsheet | Google Sheet | | ||
| svc,serv | service | |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1603,7 +1603,7 @@ class FieldDefinitions: | |
# ~~->$ DOAJSeal:FormField~~ | ||
DOAJ_SEAL = { | ||
"name": "doaj_seal", | ||
"label": "The journal has fulfilled all the criteria for the Seal. Award the Seal?", | ||
"label": "Award the Seal?", | ||
"input": "checkbox", | ||
"validate": [ | ||
{ | ||
|
@@ -1626,7 +1626,10 @@ class FieldDefinitions: | |
"the journal must use a persistent identifier" | ||
} | ||
} | ||
] | ||
], | ||
"widgets": [ | ||
"article_info", | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth adding a comment here that the article_info back-end is only accessible to admins. The DOAJ_SEAL also only appears in the admin form context, so that's all good, but I suppose we could change that at some point and not notice. |
||
} | ||
|
||
# FIXME: this probably shouldn't be in the admin form fieldsets, rather its own separate form | ||
|
@@ -1881,7 +1884,7 @@ class FieldDefinitions: | |
"entry_template": "application_form/_entry_group.html", | ||
"widgets": [ | ||
{"infinite_repeat" : {"enable_on_repeat" : ["textarea"]}}, | ||
"note_modal" | ||
"note_modal", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extraneous comma added |
||
], | ||
"merge_disabled" : "merge_disabled_notes", | ||
} | ||
|
@@ -3042,7 +3045,8 @@ def wtforms(field, settings): | |
"trim_whitespace" : "formulaic.widgets.newTrimWhitespace", # ~~-> TrimWhitespace:FormWidget~~ | ||
"note_modal" : "formulaic.widgets.newNoteModal", # ~~-> NoteModal:FormWidget~~ | ||
"autocheck": "formulaic.widgets.newAutocheck", # ~~-> Autocheck:FormWidget~~ | ||
"issn_link" : "formulaic.widgets.newIssnLink" # ~~-> IssnLink:FormWidget~~, | ||
"issn_link" : "formulaic.widgets.newIssnLink", # ~~-> IssnLink:FormWidget~~, | ||
"article_info": "formulaic.widgets.newArticleInfo", # ~~-> ArticleInfo:FormWidget~~ | ||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1155,14 +1155,14 @@ var formulaic = { | |
|
||
this._renderAutocheck = function(autocheck) { | ||
let frag = "<li>"; | ||
|
||
if (autocheck.checked_by && doaj.autocheckers && | ||
doaj.autocheckers.registry.hasOwnProperty(autocheck.checked_by)) { | ||
frag += (new doaj.autocheckers.registry[autocheck.checked_by]()).draw(autocheck) | ||
} else { | ||
frag += this._defaultRender(autocheck); | ||
} | ||
|
||
frag += `</li>`; | ||
return frag; | ||
} | ||
|
@@ -2252,5 +2252,33 @@ var formulaic = { | |
|
||
this.init(); | ||
}, | ||
|
||
newArticleInfo : (params) => edges.instantiate(formulaic.widgets.ArticleInfo, params), | ||
ArticleInfo: function ({formulaic, fieldDef, args}) { | ||
const sealSelector = '.doaj_seal__container' | ||
|
||
const init = () => { | ||
const paths = window.location.pathname.split('/') | ||
const journalId = paths[paths.length - 1] | ||
fetch(`/admin/journal/${journalId}/article-info`) | ||
.then(response => response.json()) | ||
.then(data => { | ||
const $p = $(sealSelector).prev('p'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This paragraph should be added INSIDE the sealSelector div, not before it. |
||
const text = $p.text() | ||
$p.text(text + `This journal has ${data.n_articles} articles in DOAJ.`) | ||
}) | ||
}; | ||
|
||
|
||
if ($(sealSelector).length) { | ||
init(); | ||
} else { | ||
console.log('skip ArticleInfo, seal section not found') | ||
} | ||
}, | ||
|
||
|
||
|
||
|
||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably just call this arg
save