Skip to content

Commit

Permalink
feat: new webpath and page APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed May 11, 2021
1 parent 62676d1 commit 56c1db4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_requirements(fname='requirements.txt'):

setup(
name="unicms",
version='0.14.2',
version='0.15.0',
description="uniCMS is a Django Web Content Management System",
author='Giuseppe De Marco, Francesco Filicetti',
author_email='giuseppe.demarco@unical.it, francesco.filicetti@unical.it',
Expand Down
2 changes: 2 additions & 0 deletions src/cms/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
urlpatterns += path(f'{w_prefix}/<int:pk>/', webpath.WebpathView.as_view(), name='editorial-board-site-webpath'),
urlpatterns += path(f'{w_prefix}/<int:pk>/logs/', webpath.WebpathLogsView.as_view(), name='editorial-board-site-webpath-logs'),
urlpatterns += path(f'{w_prefix}/form/', webpath.WebpathFormView.as_view(), name='editorial-board-site-webpath-form'),
urlpatterns += path(f'{eb_prefix}/sites/webpaths/', webpath.WebpathAllList.as_view(), name='webpath-all'),
urlpatterns += path(f'{eb_prefix}/sites/webpaths/options/', webpath.WebpathAllOptionList.as_view(), name='webpath-all-options'),
urlpatterns += path(f'{w_prefix}/options/', webpath.WebpathOptionList.as_view(), name='webpath-options'),
urlpatterns += path(f'{w_prefix}/options/<int:pk>/', webpath.WebpathOptionView.as_view(), name='webpath-option'),
Expand All @@ -134,6 +135,7 @@
urlpatterns += path(f'{w_prefix}/pages/form/', page.PageGenericFormView.as_view(), name='editorial-board-site-webpath-page-form-generic'),
urlpatterns += path(f'{pa_prefix}/<int:pk>/copy-as-draft/', page.PageCopyAsDraftView.as_view(),
name='editorial-board-site-webpath-page-copy-as-draft'),
urlpatterns += path(f'{eb_prefix}/sites/webpaths/pages/', page.PageAllList.as_view(), name='all-pages'),

# page blocks
pab_prefix = f'{pa_prefix}/<int:page_id>/blocks'
Expand Down
24 changes: 24 additions & 0 deletions src/cms/api/views/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from django.http import Http404
from django.shortcuts import get_object_or_404

from django_filters.rest_framework import DjangoFilterBackend

from rest_framework import filters, generics
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from rest_framework.schemas.openapi import AutoSchema
Expand All @@ -17,6 +20,7 @@
from . generics import UniCMSCachedRetrieveUpdateDestroyAPIView, UniCMSListCreateAPIView, check_locks
from . logs import ObjectLogEntriesList
from .. exceptions import LoggedPermissionDenied
from .. pagination import UniCmsApiPagination
from .. serializers import UniCMSFormSerializer


Expand Down Expand Up @@ -422,3 +426,23 @@ def get_data(self):

def get_queryset(self, object_id, content_type_id):
return super().get_queryset(object_id, content_type_id)


class EditorialBoardPageAllListSchema(AutoSchema):
def get_operation_id(self, path, method):# pragma: no cover
return 'listPageAll'


class PageAllList(generics.ListAPIView):
"""
"""
description = ""
serializer_class = PageSerializer
queryset = Page.objects.all()
schema = EditorialBoardPageAllListSchema()
permission_classes = [IsAdminUser]
filter_backends = [filters.SearchFilter,
DjangoFilterBackend,
filters.OrderingFilter]
filterset_fields = ['is_active', 'created', 'modified', 'created_by']
pagination_class = UniCmsApiPagination
25 changes: 24 additions & 1 deletion src/cms/api/views/webpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from django.shortcuts import get_object_or_404
from django.urls import reverse

from rest_framework import generics
from django_filters.rest_framework import DjangoFilterBackend

from rest_framework import filters, generics
from rest_framework.permissions import IsAdminUser
from rest_framework.schemas.openapi import AutoSchema

Expand All @@ -20,6 +22,7 @@
from . generics import UniCMSCachedRetrieveUpdateDestroyAPIView, UniCMSListCreateAPIView, UniCMSListSelectOptionsAPIView
from . logs import ObjectLogEntriesList
from .. exceptions import LoggedPermissionDenied, LoggedValidationException
from .. pagination import UniCmsApiPagination
from .. serializers import UniCMSFormSerializer


Expand Down Expand Up @@ -258,3 +261,23 @@ def get_queryset(self, **kwargs):
site=site)
content_type_id = ContentType.objects.get_for_model(item).pk
return super().get_queryset(object_id, content_type_id)


class EditorialBoardWebpathAllListSchema(AutoSchema):
def get_operation_id(self, path, method):# pragma: no cover
return 'listWebPathAll'


class WebpathAllList(generics.ListAPIView):
"""
"""
description = ""
serializer_class = WebPathSerializer
queryset = WebPath.objects.all()
schema = EditorialBoardWebpathAllListSchema()
permission_classes = [IsAdminUser]
filter_backends = [filters.SearchFilter,
DjangoFilterBackend,
filters.OrderingFilter]
filterset_fields = ['is_active', 'created', 'modified', 'created_by']
pagination_class = UniCmsApiPagination

0 comments on commit 56c1db4

Please sign in to comment.