Skip to content

Commit

Permalink
URN: redirect to the right URL
Browse files Browse the repository at this point in the history
- Register a new URN with the server name organisation as base URL.
- Fixes URN creation.
- Adds the patch DNB method to already registered URN.
- Adds the get DNB method to get URN information.
- Marks an URN pid when a document is deleted.
- Fixes the query to retrieve all the unregistered URNs.
- Adds a new optional parameter to specify the data when a test document
  is created.
- Closes: #849.
- Closes: #811.
- Avoids npm server crash in development.
- Adds options to the script server.
- Adds files permissions.
- Fixes unit tests with a .env file.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma authored and PascalRepond committed Aug 22, 2023
1 parent 291079d commit 97b78ad
Show file tree
Hide file tree
Showing 31 changed files with 915 additions and 615 deletions.
96 changes: 95 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ python-levenshtein = "<0.20.0"
jsonschema = "<4.0.0"
pydocstyle = ">=6.1.1,<6.2"
requests-mock = "^1.11.0"
pysftp = "^0.2.9"

[tool.poetry.dev-dependencies]
Flask-Debugtoolbar = ">=0.10.1"
Expand Down
29 changes: 22 additions & 7 deletions scripts/server
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ source $(dirname "$0")/functions

set -e
PORT=5000
CELERY_LOG_LEVEL="DEBUG"
worker=true

# Poetry is a mandatory condition to launch this program!
if [[ -z "${VIRTUAL_ENV}" ]]; then
message "Launch this script via poetry command: poetry run ${PROGRAM}" "error"
exit 1
fi

if ! options=$(getopt -o p: port: -- "$@")
if ! options=$(getopt -o nlp: -l no-worker,loglevel,port: -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
Expand All @@ -37,8 +39,13 @@ while [ $# -gt 0 ]
do
case $1 in
-p|--port) PORT=$2; shift;;
-l|--loglevel)
CELERY_LOG_LEVEL=$2
shift ;;
-n|--no-worker)
worker=false ;;
(--) shift; break;;
(-*) error_msg+exit "$0: Unrecognized option $1";;
(-*) message "$0: Unrecognized option $1" "error"; exit 1;;
esac
shift
done
Expand All @@ -48,12 +55,20 @@ title "Start web server and celery"

script_path=$(dirname "$0")

export FLASK_ENV=development
if [[ -z "${FLASK_DEBUG}" ]]; then
export FLASK_DEBUG=True
fi
if [[ -z "${FLASK_ENV}" ]]; then
export FLASK_ENV="development"
fi

# Start Worker and Beat
if $worker; then
section "Start celery worker" "info"
celery --app sonar.celery worker --loglevel ${CELERY_LOG_LEVEL} --beat & PID_CELERY=$!
message "Done" "success"
fi

# Start Worker and Server
section "Start celery worker" "info"
celery --app sonar.celery worker --loglevel INFO --beat & pid_celery=$!
message "Done" "success"

# Start web server
section "Start web server" "info"
Expand Down
1 change: 0 additions & 1 deletion sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _(x):
"""Identity function used to trigger string extraction."""
return x


# Application default theme, used in several modules (previewer, admin, ...)
APP_THEME = ['bootstrap3']

Expand Down
6 changes: 1 addition & 5 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

"""Specific configuration SONAR."""

SONAR_APP_SERVER_NAME = 'sonar.rero.ch'

SONAR_APP_BASE_URL = 'https://localhost:5000'

SONAR_APP_API_URL = 'https://localhost:5000/api/'
SONAR_APP_SERVER_NAME = 'localhost:5000'

SONAR_APP_ANGULAR_URL = 'https://localhost:5000/manage/'
"""Link to angular integrated app root."""
Expand Down
10 changes: 3 additions & 7 deletions sonar/modules/documents/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,17 @@ def guess_controlled_affiliations(cls, data):
'controlledAffiliation'] = controlled_affiliations

@classmethod
def get_record_by_identifier(cls, identifiers, types=None):
def get_record_by_identifier(cls, identifiers):
"""Get a record by its identifier.
:param list identifiers: List of identifiers
:param list types: List of types
"""
if types is None:
types = ['bf:Local', 'bf:Doi']

search = DocumentSearch()

# Search identifiers.
# Search only for DOI or local indentifiers.
search_identifiers = [
identifier for identifier in identifiers
if identifier['type'] in types
if identifier['type'] in ['bf:Local', 'bf:Doi']
]

# No identifiers to analyze
Expand Down
Loading

0 comments on commit 97b78ad

Please sign in to comment.