Skip to content
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

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
6 changes: 5 additions & 1 deletion doajtest/fixtures/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ def create_publisher_a():
return publisher


def create_maned_a():
def create_maned_a(is_save=False):
Copy link
Contributor

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

from portality import models
maned = models.Account(**AccountFixtureFactory.make_managing_editor_source())
maned.set_password("password")
if is_save:
maned.save(blocking=True)
return maned

4 changes: 2 additions & 2 deletions doajtest/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ def assert_expected_dict(test_case: TestCase, target, expected: dict):
test_case.assertDictEqual(actual, expected)


def login(app_client, username, password, follow_redirects=True):
def login(app_client, email, password, follow_redirects=True):
return app_client.post(url_for('account.login'),
data=dict(user=username, password=password),
data=dict(user=email, password=password),
follow_redirects=follow_redirects)


Expand Down
5 changes: 2 additions & 3 deletions doajtest/unit/api_tests/test_api_crud_returnvalues.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from doajtest import helpers
from doajtest.helpers import DoajTestCase, with_es
from portality import models
from doajtest.fixtures import ApplicationFixtureFactory, ArticleFixtureFactory, JournalFixtureFactory
Expand Down Expand Up @@ -205,9 +206,7 @@ def test_04_article_structure_exceptions(self):

@staticmethod
def login(app, username, password):
return app.post('/account/login',
data=dict(username=username, password=password),
follow_redirects=True)
return helpers.login(app, username, password)

@staticmethod
def logout(app):
Expand Down
37 changes: 37 additions & 0 deletions doajtest/unit/test_view_admin.py
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
21 changes: 11 additions & 10 deletions docs/dictionary.md
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 |
12 changes: 8 additions & 4 deletions portality/forms/application_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -1626,7 +1626,10 @@ class FieldDefinitions:
"the journal must use a persistent identifier"
}
}
]
],
"widgets": [
"article_info",
],
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -1881,7 +1884,7 @@ class FieldDefinitions:
"entry_template": "application_form/_entry_group.html",
"widgets": [
{"infinite_repeat" : {"enable_on_repeat" : ["textarea"]}},
"note_modal"
"note_modal",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraneous comma added

],
"merge_disabled" : "merge_disabled_notes",
}
Expand Down Expand Up @@ -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~~
}


Expand Down
32 changes: 30 additions & 2 deletions portality/static/js/formulaic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The 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')
}
},




}
};
18 changes: 14 additions & 4 deletions portality/view/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from flask_login import current_user, login_required
from werkzeug.datastructures import MultiDict

from portality import dao
import portality.models as models
from portality import constants
from portality import dao
from portality import lock
from portality.background import BackgroundSummary
from portality.bll import DOAJ, exceptions
from portality.bll.exceptions import ArticleMergeConflict, DuplicateArticleException
from portality.bll.services.query import Query
from portality.core import app
from portality.crosswalks.application_form import ApplicationFormXWalk
from portality.decorators import ssl_required, restrict_to_role, write_required
Expand All @@ -28,8 +29,6 @@
from portality.ui.messages import Messages
from portality.util import flash_with_url, jsonp, make_json_resp, get_web_json_payload, validate_json
from portality.view.forms import EditorGroupForm, MakeContinuation

from portality.bll.services.query import Query
from portality.view.view_helper import exparam_editing_user

# ~~Admin:Blueprint~~
Expand Down Expand Up @@ -322,6 +321,16 @@ def journals_bulk_reinstate():
#
#####################################################################

@blueprint.route("/journal/<journal_id>/article-info/", methods=["GET"])
@login_required
def journal_article_info(journal_id):
j = models.Journal.pull(journal_id)
if j is None:
abort(404)

return {'n_articles': models.Article.count_by_issns(j.bibjson().issns())}


@blueprint.route("/journal/<journal_id>/continue", methods=["GET", "POST"])
@login_required
@ssl_required
Expand Down Expand Up @@ -432,7 +441,8 @@ def application(application_id):
flash(str(e))
return redirect(url_for("admin.application", application_id=ap.id, _anchor='cannot_edit'))
else:
return fc.render_template(obj=ap, lock=lockinfo, form_diff=form_diff, current_journal=current_journal, lcc_tree=lcc_jstree, autochecks=autochecks)
return fc.render_template(obj=ap, lock=lockinfo, form_diff=form_diff, current_journal=current_journal,
lcc_tree=lcc_jstree, autochecks=autochecks)


@blueprint.route("/application_quick_reject/<application_id>", methods=["POST"])
Expand Down
Loading