Compare commits

..

12 Commits

Author SHA1 Message Date
Christoph Ladurner
328abd1306 release v0.10.4 2023-02-10 10:41:27 +01:00
Christoph Ladurner
7ce124cdb9 setup: invenio-search is not optional 2023-02-10 10:36:44 +01:00
Christoph Ladurner
75d78cf09a setup: change to reusable github workflows
* move check_manifest configuration to setup.cfg

* remove upper constraint for pytest-black
2023-02-10 10:36:44 +01:00
Christoph Ladurner
2e5fbcb4f9 setup: remove 3.7 and add 3.10 support 2023-02-10 10:36:44 +01:00
Christoph Ladurner
4c4279965a guide: update 2023-02-10 10:36:44 +01:00
Christoph Ladurner
0ee0df4ee1 release v0.10.2 2023-02-02 09:03:42 +01:00
mojib
8df08c09bf change version name 2023-02-01 15:36:57 +01:00
mojib
3a508ac3f0 footer: update guid 2023-02-01 15:36:57 +01:00
Christoph Ladurner
087cafa3ae release v0.10.1 2022-11-17 10:00:20 +01:00
Christoph Ladurner
14e9e0557a global: add function
* this function was moved from invenio-alma
2022-11-17 09:55:56 +01:00
Mojib Wali
8669f5dcda release: v0.10.0 2022-10-13 11:23:15 +02:00
Mojib Wali
62256b346f global: migrate to v10 2022-10-13 11:12:14 +02:00
13 changed files with 80 additions and 83 deletions

View File

@@ -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 }}

View File

@@ -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

View File

@@ -7,6 +7,26 @@
Changes Changes
======= =======
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)

View File

@@ -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

View File

@@ -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:

View File

@@ -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.10.4"
__all__ = ("__version__", "InvenioConfigTugraz", "RecordIp") __all__ = (
"__version__",
"InvenioConfigTugraz",
"RecordIp",
"get_identity_from_user_by_email",
)

View File

@@ -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."""

View 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

View File

@@ -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,
) )
) )

View File

@@ -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

View File

@@ -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,15 @@ 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>=0.39.0,<0.40.0
invenio-cache>=1.1.1,<1.2.0 invenio-cache>=1.1.1,<1.2.0
[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>=1.4.7
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 +92,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