Commit a701735c authored by Audrey Hamelers's avatar Audrey Hamelers
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request !179
parents 66399717 a3281807
Pipeline #12832 passed with stages
in 48 seconds
......@@ -39,9 +39,18 @@ const Footer = () => (
</LeftSide>
<RightSide>
<div>
<A href="https://europepmc.org/">Europe PMC</A>
<A href="https://europepmc.org/PrivacyNotice">Privacy Notice</A>
<A href="https://europepmc.org/Accessibility">Accessibility</A>
<A href="https://europepmc.org/" target="_blank">
Europe PMC
</A>
<A
href="https://www.ebi.ac.uk/data-protection/privacy-notice/europe-pmc-plus"
target="_blank"
>
Privacy Notice
</A>
<A href="https://europepmc.org/Accessibility" target="_blank">
Accessibility
</A>
</div>
</RightSide>
</Foot>
......
......@@ -151,7 +151,7 @@ class GrantSearch extends React.Component {
availableGrants: [],
hitcount: 0,
}
if (query.trim().length > 0) {
if (query.trim().length > 2) {
const url = `/grist/rest/api/search?query=gid:%22${query}%22%7Cpi:%22${query}%22&page=1`
const response = await fetch(url, {
headers: new Headers({
......
......@@ -406,7 +406,12 @@ const EventDescription = ({ audit, manuscript }) => {
return list.map(k => {
switch (k) {
case 'claimed_by':
return 'Removed admin claim'
return (
<React.Fragment key={k}>
Removed admin claim
<br />
</React.Fragment>
)
case 'form_state':
return changes[k] ? (
<React.Fragment key={k}>
......
......@@ -73,7 +73,11 @@ class MetaSec extends React.Component {
articleIds &&
articleIds.find(aid => aid.pubIdType === 'pmcid') &&
articleIds.find(aid => aid.pubIdType === 'pmcid').id
if (linkDelete && linkDelete === pmcid) {
if (
linkDelete &&
linkDelete === pmcid &&
manuscript.status !== 'xml-complete'
) {
const { data } = await linkDeleteManuscript({
variables: { id: manuscript.id },
})
......
......@@ -329,6 +329,7 @@ class PubMedSearch extends React.Component {
<Links>
<A
href={`https://europepmc.org/articles/${inPMC.pmcid}`}
target="_blank"
>
<Icon color="currentColor">arrow-right-circle</Icon>
View this article on Europe PMC
......
......@@ -112,7 +112,10 @@ class AccountDetails extends React.Component {
<div>
<Field component={PublisherName} name="publisher" />
<p>
<A href="https://www.nihms.nih.gov/db/report_publs.cgi?system=ukmss&auth=publisher">
<A
href="https://www.nihms.nih.gov/db/report_publs.cgi?system=ukmss&auth=publisher"
target="_blank"
>
Check the list
</A>{' '}
for expected ukmss publisher usernames
......
......@@ -169,6 +169,7 @@ module.exports = {
sender: process.env.PUBSWEET_SENDER || 'helpdesk@europepmc.org',
system: process.env.PUBSWEET_SYSTEM_EMAIL || 'plusadmin@ebi.ac.uk',
dev: process.env.PUBSWEET_DEV_EMAIL || 'plusdev@ebi.ac.uk',
listName: 'Europe PMC plus',
},
'pubsweet-component-ink-backend': {
inkEndpoint:
......
......@@ -18,7 +18,7 @@
0 18 * * * APP_NAME=published-check node server/ncbi-integration/publishedCheck
# check incomplete citations
# 0 1 * * * APP_NAME=check-incomplete-citations node server/ncbi-integration/incomplete-citations-check
0 1 * * * APP_NAME=check-incomplete-citations node server/ncbi-integration/incomplete-citations-check
# check the ftp bulk upload monitor is running
......
{
"name": "xpub-epmc",
"version": "1.3.0",
"version": "1.3.1",
"private": true,
"description": "xpub configured for Europe PMC Plus manuscript submission system",
"license": "MIT",
......
......@@ -22,7 +22,7 @@ const {
} = require('./templates')
const tagger = config.ftp_tagger.email
const { sender, url, testAddress, system, dev } = config['epmc-email']
const { sender, url, testAddress, system, dev, listName } = config['epmc-email']
const parsed = string => lodash.unescape(string)
......@@ -30,7 +30,7 @@ const sendMail = (to, subject, message, from = null, cc = null, bcc = null) => {
const mailData = {
from: from || sender,
to: testAddress || to,
subject: `[Europe PMC plus] ${subject}`,
subject: `[${listName}] ${subject}`,
html: htmlEmailBase(message, url),
}
logger.info(`Email recipient: ${to}`)
......
......@@ -147,11 +147,7 @@ function getUser(rootPath, filename) {
const fileNameParts = filename.split('/')
const userName = fileNameParts[rootParts.length - 1]
// We will need the userId from the database for further relating the manuscript to this user.
Identity.findByFieldEager(
'meta',
`{"ftpUserName": "${userName}"}`,
'[user]',
)
Identity.findByFtpUsername(userName, '[user]')
.then(identityDb => {
const user = ftpUsers.find(user =>
user.identities
......
......@@ -16,8 +16,11 @@ const NCBI_RESPONSE_EXT = new RegExp(/\S+.ld.response.xml$/i)
let c = new Client()
;(async () => {
logger.info('running from NCBI check')
const beforeUpdate = Date.now()
const updatedManuscripts = await fromNcbi()
close(c)
logger.info(`from NCBI check was finished in ${Date.now() - beforeUpdate} ms`)
const successManuscripts = updatedManuscripts.filter(
m => m.ncbiState === 'success',
)
......@@ -25,16 +28,13 @@ let c = new Client()
logger.info('Sending grant data')
await createGrantLinks(successManuscripts)
}
close(c)
logger.info(`from ncbi check was finished in ${Date.now() - beforeUpdate} ms`)
process.exit()
})()
function close(c) {
c.end()
ManuscriptAccess.knex().destroy()
c = null
logger.info('connection terminated')
process.exit()
}
function fromNcbi() {
......@@ -147,7 +147,6 @@ async function updateManuscriptNcbiStatus(fileName, response) {
const manuscriptId = fileName.split('.')[0].toUpperCase()
const manuscript = await ManuscriptAccess.selectById(manuscriptId)
if (!manuscript) {
// throw new Error(`manuscript ${manuscriptId} not found in db`)
logger.info(`manuscript ${manuscriptId} not found in db`)
return null
}
......@@ -171,6 +170,7 @@ async function updateManuscriptNcbiStatus(fileName, response) {
? newIds
: manuscript['meta,articleIds']
const newManuscript = await updateManuscript(manInput)
logger.info(`manuscript ${manuscriptId} updated`)
return newManuscript
}
......
......@@ -11,8 +11,8 @@ module.exports.createGrantLinks = async function createGrantLinks(
) {
try {
const filename = `grants${
manuscripts.length === 1 ? `-${manuscripts[0].id}` : ''
}.${moment().format('YYYY_MM_DD-HH-mm-SS')}.xml`
manuscripts.length === 1 ? `${manuscripts[0].id}` : ''
}.${moment().format('YYYY_MM_DD-HH_mm_SS')}.xml`
const sendManuscripts = manuscripts.reduce((list, manuscript) => {
const articleIds =
manuscript.meta.articleIds &&
......@@ -43,16 +43,18 @@ module.exports.createGrantLinks = async function createGrantLinks(
if (sendManuscripts.length > 0) {
let contents = `<?xml version="1.0" encoding="UTF-8"?>
<grants file="${filename}">`
await Promise.all(
const grantsLists = await Promise.all(
sendManuscripts.map(async each => {
contents += await createGrantXML(
const grantList = await createGrantXML(
each.articleIds,
each.fundingGroup,
each.removeFundingGroup,
)
logger.info(`${each.id} Grant list created`)
return grantList
}),
)
contents += grantsLists.join('\n')
contents += '</grants>'
await sendXML(contents, filename)
logger.info(`Grant list sent to NCBI`)
......
......@@ -193,7 +193,17 @@
</xsl:template>
<xsl:template match="back">
<xsl:apply-templates/>
<xsl:apply-templates select="ack"/>
<xsl:if test="not(ack)">
<xsl:apply-templates select="//author-notes"/>
<xsl:if test="not(fn-group/fn[@fn-type = 'con']) and not(//author-notes)">
<xsl:apply-templates select="//contrib[@equal-contrib = 'yes'][1]" mode="equal"/>
</xsl:if>
<xsl:if test="//contrib/email and not(//author-notes)">
<xsl:call-template name="list-emails"/>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="*[not(self::ack)]"/>
</xsl:template>
<xsl:template match="front">
......@@ -1885,6 +1895,9 @@
<xsl:if test="not(following-sibling::fn-group/fn[@fn-type = 'con']) and not(//author-notes)">
<xsl:apply-templates select="//contrib[@equal-contrib = 'yes'][1]" mode="equal"/>
</xsl:if>
<xsl:if test="//contrib/email and not(//author-notes)">
<xsl:call-template name="list-emails"/>
</xsl:if>
</xsl:template>
<xsl:template match="back/fn-group">
......@@ -1923,12 +1936,31 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="list-emails">
<xsl:if test="//contrib/email">
<p>
<xsl:text>Author emails: </xsl:text>
<xsl:for-each select="//contrib[email]">
<xsl:value-of select="name/given-names"/>
<xsl:text> </xsl:text>
<xsl:value-of select="name/surname"/>
<xsl:text>, </xsl:text>
<xsl:apply-templates select="email"/>
<xsl:if test="position() != last()">
<xsl:text>; </xsl:text>
</xsl:if>
</xsl:for-each>
</p>
</xsl:if>
</xsl:template>
<!-- author-notes -->
<xsl:template match="author-notes">
<xsl:if test="fn[not(@fn-type)] | fn[(@fn-type != 'con' and @fn-type != 'equal' and @fn-type != 'present-address')] | p | corresp">
<xsl:if test="fn[(@fn-type != 'con' and @fn-type != 'equal' and @fn-type != 'present-address')] | p | corresp">
<h2 id="author-notes">Author Information</h2>
<xsl:apply-templates select="p | corresp"/>
<xsl:call-template name="list-emails"/>
</xsl:if>
<xsl:if test="not(//back/fn-group/fn[@fn-type = 'con']) and (fn[@fn-type = 'con'] | fn[@fn-type = 'equal'] | //contrib[@equal-contrib = 'yes'])">
<h3>Author Contributions</h3>
......@@ -2058,6 +2090,8 @@
<xsl:template match="author-notes/corresp">
<p class="corresp" id="{@id}">
<sup>&#9993;</sup>
<xsl:text> </xsl:text>
<xsl:if test="count(*) &lt; 2">
<xsl:text>Correspondence: </xsl:text>
</xsl:if>
......@@ -2065,7 +2099,7 @@
</p>
</xsl:template>
<xsl:template match="email[ancestor::corresp or ancestor::author-notes]">
<xsl:template match="email[ancestor::corresp or ancestor::author-notes or ancestor::contrib]">
<xsl:variable name="email">
<xsl:call-template name="reverse">
<xsl:with-param name="rest" select="."/>
......
......@@ -4,6 +4,7 @@ const bcrypt = require('bcrypt')
// const config = require('config')
const EpmcBaseModel = require('../epmc-base-model')
const User = require('../user/data-access')
const logger = require('@pubsweet/logger')
const BCRYPT_COST = 12
......@@ -38,6 +39,7 @@ class Identity extends EpmcBaseModel {
meta: {
type: ['object', 'null'],
properties: {
ftpUserName: { type: ['string', 'null'] },
publisher: { type: ['string', 'null'] },
},
},
......@@ -47,6 +49,20 @@ class Identity extends EpmcBaseModel {
}
}
static async findByFtpUsername(value, eagerExpr) {
logger.debug('Finding', 'identity.meta', value)
try {
const results = await Identity.query()
.whereJsonSupersetOf('meta', { ftpUserName: value })
.eager(eagerExpr)
return results
} catch (e) {
logger.error(e)
}
}
/*
static get idColumn() {
return 'email'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment