mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2025-12-23 05:21:57 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40a47ed36d | ||
|
|
129b331603 | ||
|
|
328abd1306 | ||
|
|
7ce124cdb9 | ||
|
|
75d78cf09a | ||
|
|
2e5fbcb4f9 | ||
|
|
4c4279965a | ||
|
|
0ee0df4ee1 | ||
|
|
8df08c09bf | ||
|
|
3a508ac3f0 | ||
|
|
087cafa3ae | ||
|
|
14e9e0557a | ||
|
|
8669f5dcda | ||
|
|
62256b346f |
21
.github/workflows/pypi-publish.yml
vendored
21
.github/workflows/pypi-publish.yml
vendored
@@ -5,22 +5,5 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-n-publish:
|
build-n-publish:
|
||||||
runs-on: ubuntu-latest
|
uses: tu-graz-library/.github/.github/workflows/pypi-publish.yml@main
|
||||||
steps:
|
secrets: inherit
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python 3.7
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.7
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install setuptools wheel "babel<=2.9.1"
|
|
||||||
- name: Build package
|
|
||||||
run: |
|
|
||||||
python setup.py compile_catalog sdist bdist_wheel
|
|
||||||
- name: pypi-publish
|
|
||||||
uses: pypa/gh-action-pypi-publish@v1.3.1
|
|
||||||
with:
|
|
||||||
user: __token__
|
|
||||||
password: ${{ secrets.pypi_password }}
|
|
||||||
|
|||||||
50
.github/workflows/tests.yml
vendored
50
.github/workflows/tests.yml
vendored
@@ -16,51 +16,5 @@ on:
|
|||||||
default: 'Manual trigger'
|
default: 'Manual trigger'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Tests:
|
tests:
|
||||||
runs-on: ubuntu-20.04
|
uses: tu-graz-library/.github/.github/workflows/tests.yml@main
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: [3.8, 3.9]
|
|
||||||
requirements-level: [pypi]
|
|
||||||
db-service: [postgresql13]
|
|
||||||
search-service: [elasticsearch7]
|
|
||||||
include:
|
|
||||||
- db-service: postgresql13
|
|
||||||
DB_EXTRAS: "postgresql"
|
|
||||||
|
|
||||||
- search-service: elasticsearch7
|
|
||||||
SEARCH_EXTRAS: "elasticsearch7"
|
|
||||||
|
|
||||||
env:
|
|
||||||
DB: ${{ matrix.db-service }}
|
|
||||||
SEARCH: ${{ matrix.search-service }}
|
|
||||||
EXTRAS: tests,${{ matrix.SEARCH_EXTRAS }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Generate dependencies
|
|
||||||
run: |
|
|
||||||
pip install wheel requirements-builder
|
|
||||||
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
|
|
||||||
- name: Cache pip
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
|
|
||||||
pip install ".[$EXTRAS]"
|
|
||||||
pip freeze
|
|
||||||
docker --version
|
|
||||||
docker-compose --version
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
./run-tests.sh
|
|
||||||
|
|||||||
25
CHANGES.rst
25
CHANGES.rst
@@ -7,6 +7,31 @@
|
|||||||
|
|
||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Version v0.11.0 (release 2023-04-20)
|
||||||
|
|
||||||
|
- global: make package compatible with v11
|
||||||
|
|
||||||
|
|
||||||
|
Version v0.10.4 (release 2023-02-10)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Version v0.10.2 (release 2023-02-02)
|
||||||
|
|
||||||
|
- change version name
|
||||||
|
- footer: update guid
|
||||||
|
|
||||||
|
|
||||||
|
Version v0.10.1 (release 2022-11-17)
|
||||||
|
|
||||||
|
- global: add function
|
||||||
|
|
||||||
|
Version 0.10.0 (released 2022-10-13)
|
||||||
|
|
||||||
|
- global: migrate to v10 (#101)
|
||||||
|
|
||||||
Version 0.9.1 (released 2022-05-30)
|
Version 0.9.1 (released 2022-05-30)
|
||||||
|
|
||||||
- ci(publish): ping babel version (#99)
|
- ci(publish): ping babel version (#99)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ encoding = utf-8
|
|||||||
|
|
||||||
[jinja2: **/templates/**.*]
|
[jinja2: **/templates/**.*]
|
||||||
encoding = utf-8
|
encoding = utf-8
|
||||||
extensions = jinja2.ext.autoescape, jinja2.ext.with_
|
|
||||||
|
|
||||||
# Extraction from JavaScript files
|
# Extraction from JavaScript files
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ release = __version__
|
|||||||
#
|
#
|
||||||
# This is also used if you do content translation via gettext catalogs.
|
# This is also used if you do content translation via gettext catalogs.
|
||||||
# Usually you set "language" from the command line for these cases.
|
# Usually you set "language" from the command line for these cases.
|
||||||
language = None
|
language = "en"
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
# non-false value, then it is used:
|
# non-false value, then it is used:
|
||||||
|
|||||||
@@ -10,7 +10,13 @@
|
|||||||
|
|
||||||
from .ext import InvenioConfigTugraz
|
from .ext import InvenioConfigTugraz
|
||||||
from .generators import RecordIp
|
from .generators import RecordIp
|
||||||
|
from .utils import get_identity_from_user_by_email
|
||||||
|
|
||||||
__version__ = "0.9.1"
|
__version__ = "0.11.0"
|
||||||
|
|
||||||
__all__ = ("__version__", "InvenioConfigTugraz", "RecordIp")
|
__all__ = (
|
||||||
|
"__version__",
|
||||||
|
"InvenioConfigTugraz",
|
||||||
|
"RecordIp",
|
||||||
|
"get_identity_from_user_by_email",
|
||||||
|
)
|
||||||
|
|||||||
@@ -151,10 +151,10 @@ The succinct encoding of the permissions for your instance gives you
|
|||||||
- great flexibility by defining your own actions, generators and policies
|
- great flexibility by defining your own actions, generators and policies
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from elasticsearch_dsl.query import Q
|
|
||||||
from flask import current_app, request
|
from flask import current_app, request
|
||||||
from invenio_access.permissions import any_user
|
from invenio_access.permissions import any_user
|
||||||
from invenio_records_permissions.generators import Generator
|
from invenio_records_permissions.generators import Generator
|
||||||
|
from invenio_search.engine import dsl
|
||||||
|
|
||||||
|
|
||||||
class RecordIp(Generator):
|
class RecordIp(Generator):
|
||||||
@@ -208,10 +208,10 @@ class RecordIp(Generator):
|
|||||||
|
|
||||||
if not visible:
|
if not visible:
|
||||||
# If user ip is not on the list, and If the record contains 'singleip' will not be seen
|
# If user ip is not on the list, and If the record contains 'singleip' will not be seen
|
||||||
return ~Q("match", **{"access.access_right": "singleip"})
|
return ~dsl.Q("match", **{"access.access_right": "singleip"})
|
||||||
|
|
||||||
# Lists all records
|
# Lists all records
|
||||||
return Q("match_all")
|
return dsl.Q("match_all")
|
||||||
|
|
||||||
def check_permission(self):
|
def check_permission(self):
|
||||||
"""Check for User IP address in config variable."""
|
"""Check for User IP address in config variable."""
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
32
invenio_config_tugraz/utils.py
Normal file
32
invenio_config_tugraz/utils.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 Graz University of Technology.
|
||||||
|
#
|
||||||
|
# invenio-config-tugraz is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
||||||
|
# details.
|
||||||
|
|
||||||
|
"""Utils file."""
|
||||||
|
|
||||||
|
from flask_principal import Identity
|
||||||
|
from invenio_access import any_user
|
||||||
|
from invenio_access.utils import get_identity
|
||||||
|
from invenio_accounts import current_accounts
|
||||||
|
|
||||||
|
|
||||||
|
def get_identity_from_user_by_email(email: str = None) -> Identity:
|
||||||
|
"""Get the user specified via email or ID."""
|
||||||
|
if email is None:
|
||||||
|
raise ValueError("the email has to be set to get a identity")
|
||||||
|
|
||||||
|
user = current_accounts.datastore.get_user(email)
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
raise LookupError(f"user with {email} not found")
|
||||||
|
|
||||||
|
identity = get_identity(user)
|
||||||
|
|
||||||
|
# TODO: this is a temporary solution. this should be done with data from the db
|
||||||
|
identity.provides.add(any_user)
|
||||||
|
|
||||||
|
return identity
|
||||||
@@ -51,7 +51,7 @@ def guide():
|
|||||||
return redirect(
|
return redirect(
|
||||||
url_for(
|
url_for(
|
||||||
"static",
|
"static",
|
||||||
filename=f"documents/TUGraz_Repository_Guide_02_{locale}.pdf",
|
filename=f"documents/TUGraz_Repository_Guide_02.1_{locale}.pdf",
|
||||||
_external=True,
|
_external=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function cleanup() {
|
|||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
python -m check_manifest --ignore ".*-requirements.txt"
|
python -m check_manifest
|
||||||
python -m sphinx.cmd.build -qnN docs docs/_build/html
|
python -m sphinx.cmd.build -qnN docs docs/_build/html
|
||||||
eval "$(docker-services-cli up --search ${SEARCH:-elasticsearch} --env)"
|
eval "$(docker-services-cli up --search ${SEARCH:-elasticsearch} --env)"
|
||||||
python -m pytest
|
python -m pytest
|
||||||
|
|||||||
20
setup.cfg
20
setup.cfg
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2020-2022 Graz University of Technology.
|
# Copyright (C) 2020-2023 Graz University of Technology.
|
||||||
#
|
#
|
||||||
# invenio-config-tugraz is free software; you can redistribute it and/or
|
# invenio-config-tugraz is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the MIT License; see LICENSE file for more
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
||||||
@@ -25,9 +25,9 @@ classifiers =
|
|||||||
Programming Language :: Python
|
Programming Language :: Python
|
||||||
Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||||
Topic :: Software Development :: Libraries :: Python Modules
|
Topic :: Software Development :: Libraries :: Python Modules
|
||||||
Programming Language :: Python :: 3.7
|
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
|
Programming Language :: Python :: 3.10
|
||||||
Development Status :: 3 - Alpha
|
Development Status :: 3 - Alpha
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
@@ -37,16 +37,16 @@ python_requires = >=3.8
|
|||||||
zip_safe = False
|
zip_safe = False
|
||||||
install_requires =
|
install_requires =
|
||||||
# keep this dependencies identical to invenio-app-rdm
|
# keep this dependencies identical to invenio-app-rdm
|
||||||
invenio-rdm-records>=0.35.16,<0.36.0
|
invenio-rdm-records>=1.1.0,<2.0.0
|
||||||
invenio-cache>=1.1.1,<1.2.0
|
invenio-cache>=1.1.1,<1.2.0
|
||||||
|
flask-babel>=2,<3
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
tests =
|
tests =
|
||||||
pytest-black>=0.3.0,<0.3.10
|
pytest-black>=0.3.0
|
||||||
sphinx>=4.2.0,<5
|
Sphinx>=4.5.0
|
||||||
pytest-invenio>=1.4.7
|
pytest-invenio>=2.1.0,<3.0.0
|
||||||
elasticsearch7 =
|
invenio-search[opensearch2]>=2.1.0,<3.0.0
|
||||||
invenio-search[elasticsearch7]>=1.4.2,<2.0
|
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
invenio_base.apps =
|
invenio_base.apps =
|
||||||
@@ -93,6 +93,10 @@ output-dir = invenio_config_tugraz/translations/
|
|||||||
[isort]
|
[isort]
|
||||||
profile=black
|
profile=black
|
||||||
|
|
||||||
|
[check-manifest]
|
||||||
|
ignore =
|
||||||
|
*-requirements.txt
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = --black --isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_config_tugraz --cov-report=term-missing tests invenio_config_tugraz
|
addopts = --black --isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=invenio_config_tugraz --cov-report=term-missing tests invenio_config_tugraz
|
||||||
testpaths = tests invenio_config_tugraz
|
testpaths = tests invenio_config_tugraz
|
||||||
|
|||||||
Reference in New Issue
Block a user