Skip to content

Commit

Permalink
support admin_site_search redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
philipkcl committed Jul 8, 2024
1 parent 5e9f946 commit c8f3e73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion portality/static/js/formulaic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,12 @@ var formulaic = {
fetch(`/admin/journal/${journalId}/article-info`)
.then(response => response.json())
.then(data => {
$sealEle.text($sealEle.text() + ` (This journal has ${data.n_articles} articles in DOAJ)`)
let articleText = `(This journal has ${data.n_articles} articles in DOAJ)`
if (data.n_articles > 0) {
const articlesUrl = `/admin/journal/${journalId}/article-info/admin-site-search`
articleText = `<a href="${articlesUrl}">${articleText}</a>`
}
$sealEle.html($sealEle.text() + ` ${articleText}`)
})
},

Expand Down
15 changes: 15 additions & 0 deletions portality/view/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ def journal_article_info(journal_id):
return {'n_articles': models.Article.count_by_issns(j.bibjson().issns(), in_doaj=True)}


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

issns = j.bibjson().issns()
if not issns:
abort(404)

target_url = '/admin/admin_site_search?source={"query":{"bool":{"must":[{"term":{"admin.in_doaj":true}},{"term":{"es_type.exact":"article"}},{"query_string":{"query":"%s","default_operator":"AND","default_field":"index.issn.exact"}}]}},"track_total_hits":true}'
return redirect(target_url % issns[0].replace('-', r'\\-'))


@blueprint.route("/journal/<journal_id>/continue", methods=["GET", "POST"])
@login_required
@ssl_required
Expand Down

0 comments on commit c8f3e73

Please sign in to comment.