Skip to content

Commit

Permalink
Merge pull request #406 from digitalfabrik/develop
Browse files Browse the repository at this point in the history
Release `2022.10.0`
  • Loading branch information
timobrembeck committed Nov 4, 2022
2 parents 0bff191 + f6d6c4f commit 9c20709
Show file tree
Hide file tree
Showing 8 changed files with 10,395 additions and 27 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
ignore:
- dependency-name: "django"
versions: [">=4.0"]
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
UNRELEASED
----------

* [ [#404](https://github.com/digitalfabrik/lunes-cms/issues/404) ] Deliver protected vocabulary words in API
* [ [#412](https://github.com/digitalfabrik/lunes-cms/issues/412) ] Use different logo on login form


2022.8.0
--------
Expand Down
32 changes: 23 additions & 9 deletions lunes_cms/api/v1/views/word_viewset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.db.models import Q

from rest_framework import viewsets
from rest_framework.authentication import SessionAuthentication, BasicAuthentication

from ....cms.models import Document
from ....cms.models import Document, GroupAPIKey
from ...utils import get_key
from ..serializers import DocumentSerializer


Expand All @@ -23,15 +26,26 @@ def get_queryset(self):
"""
if getattr(self, "swagger_fake_view", False):
return Document.objects.none()
return (
Document.objects.filter(
creator_is_admin=True,
document_image__confirmed=True,
training_sets__released=True,
training_sets__discipline__released=True,
# Get base queryset
queryset = Document.objects.filter(
document_image__confirmed=True,
training_sets__released=True,
training_sets__discipline__released=True,
)
# Get API key of current request
key = get_key(self.request)
if key:
# If the key is given, get the corresponding group
api_key_object = GroupAPIKey.get_from_token(key)
# Return all public words as well as those of the group with the given key
queryset = queryset.filter(
Q(creator_is_admin=True) | Q(created_by=api_key_object.group)
)
.select_related()
.distinct()
else:
# If no key is given, return all public words
queryset = queryset.filter(creator_is_admin=True)
return (
queryset.select_related().distinct()
# Sort queryset to make output order deterministic for testing
.order_by("id")
)
2 changes: 2 additions & 0 deletions lunes_cms/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@
"site_header": _("Lunes Administration"),
"site_logo": "images/logo.svg",
"site_icon": "images/logo.svg",
"login_logo": "images/logo-lunes.svg",
"login_logo_dark": "images/logo-lunes-dark.svg",
"site_logo_classes": "",
"changeform_format": "collapsible",
"language_chooser": True,
Expand Down
30 changes: 15 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,40 @@ keywords =
packages =
lunes_cms
install_requires =
django==3.2.15
django-jazzmin==2.5.0
django-mptt==0.13.4
django==3.2.16
django-jazzmin==2.6.0
django-mptt==0.14.0
django-qr-code==3.1.1
djangorestframework==3.13.1
drf-spectacular==0.23.1
ipython==8.4.0
djangorestframework==3.14.0
drf-spectacular==0.24.2
ipython==8.6.0
pillow==9.2.0
psycopg2==2.9.3
psycopg2==2.9.5
pydub==0.25.1
python_requires = >=3.8
include_package_data = True
scripts = lunes_cms/lunes-cms-cli

[options.extras_require]
dev =
black==22.6.0
bumpver==2022.1118
black==22.10.0
bumpver==2022.1119
pre-commit==2.20.0
pyjwt==2.4.0
pyjwt==2.6.0
pylint-django==2.5.3
pylint-runner==0.6.0
shellcheck-py==0.8.0.4
twine==4.0.1
doc =
sphinx==5.1.1
sphinx==5.3.0
sphinx-rtd-theme==1.0.0
sphinx-last-updated-by-git==0.3.2
sphinx-last-updated-by-git==0.3.4
sphinxcontrib-django2==1.5
test =
pytest-circleci-parallelized==0.0.4
pytest-cov==3.0.0
pytest-circleci-parallelized==0.1.0
pytest-cov==4.0.0
pytest-django==4.5.2
pytest-xdist==2.5.0
pytest-xdist==3.0.2

[bumpver]
current_version = 2022.8.0
Expand Down
24 changes: 21 additions & 3 deletions tests/api/api_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,13 @@
{
"endpoint": "/api/words/",
"api_key": "VALIDTOKEN",
"expected_result": "tests/api/expected-results/words.json",
"expected_result": "tests/api/expected-results/words_by_key.json",
},
{
"endpoint": "/api/words/",
"api_key": "INVALIDTOKEN",
"expected_result": "tests/api/expected-results/words.json",
"expected_result": "tests/api/expected-results/permission_denied.json",
"expected_status_code": 403,
},
{
"endpoint": "/api/words/2/",
Expand All @@ -262,7 +263,24 @@
{
"endpoint": "/api/words/2/",
"api_key": "INVALIDTOKEN",
"expected_result": "tests/api/expected-results/words_2.json",
"expected_result": "tests/api/expected-results/permission_denied.json",
"expected_status_code": 403,
},
{
"endpoint": "/api/words/170/",
"expected_result": "tests/api/expected-results/not_found.json",
"expected_status_code": 404,
},
{
"endpoint": "/api/words/170/",
"api_key": "VALIDTOKEN",
"expected_result": "tests/api/expected-results/words_170.json",
},
{
"endpoint": "/api/words/170/",
"api_key": "INVALIDTOKEN",
"expected_result": "tests/api/expected-results/permission_denied.json",
"expected_status_code": 403,
},
]

Expand Down
14 changes: 14 additions & 0 deletions tests/api/expected-results/words_170.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": 170,
"word": "Auto",
"article": 3,
"audio": "http://testserver/media/audio/auto.mp3",
"word_type": "Nomen",
"alternatives": [],
"document_image": [
{
"id": 178,
"image": "http://testserver/media/images/auto.jpg"
}
]
}
Loading

0 comments on commit 9c20709

Please sign in to comment.