From: Radek Czajka Date: Fri, 7 Oct 2022 13:35:07 +0000 (+0200) Subject: Allow author creation by api. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/c65314d0db1d45ec00001b207e633072cb17c156?ds=sidebyside Allow author creation by api. --- diff --git a/src/catalogue/__init__.py b/src/catalogue/__init__.py index e87986255..f8c87fb47 100644 --- a/src/catalogue/__init__.py +++ b/src/catalogue/__init__.py @@ -7,9 +7,6 @@ from django.utils.module_loading import import_string from catalogue.utils import AppSettings -default_app_config = 'catalogue.apps.CatalogueConfig' - - class Settings(AppSettings): """Default settings for catalogue app.""" DEFAULT_LANGUAGE = 'pol' diff --git a/src/catalogue/api/views.py b/src/catalogue/api/views.py index 1af1577e7..b45ad4656 100644 --- a/src/catalogue/api/views.py +++ b/src/catalogue/api/views.py @@ -313,11 +313,20 @@ class TagView(RetrieveAPIView): queryset = Tag.objects.all() def get_object(self): - return get_object_or_404( - Tag, - category=self.kwargs['category'], - slug=self.kwargs['slug'] - ) + try: + return get_object_or_404( + Tag, + category=self.kwargs['category'], + slug=self.kwargs['slug'] + ) + except Http404: + if self.method == 'PUT': + return Tag( + category=self.kwargs['category'], + slug=self.kwargs['slug'] + ) + else: + raise def post(self, request, **kwargs): data = json.loads(request.POST.get('data')) diff --git a/src/club/__init__.py b/src/club/__init__.py index 87e8208aa..e69de29bb 100644 --- a/src/club/__init__.py +++ b/src/club/__init__.py @@ -1,2 +0,0 @@ -default_app_config = 'club.apps.ClubConfig' - diff --git a/src/wolnelektury/__init__.py b/src/wolnelektury/__init__.py index 523661701..62cefd325 100644 --- a/src/wolnelektury/__init__.py +++ b/src/wolnelektury/__init__.py @@ -1,8 +1,4 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.utils.translation import gettext - from .celery import app as celery_app - -default_app_config = 'wolnelektury.apps.WLCoreConfig'