return generate_image_url(obj, 'width-{}'.format(width)) def get_url_400(self, obj): return self._get_url_x(obj, 400) def get_url_640(self, obj): return self._get_url_x(obj, 640) def get_url_800(self, obj): return self._get_url_x(obj, 800) def get_url_1280(self, obj): return self._get_url_x(obj, 1280) url_400 = serializers.SerializerMethodField() url_640 = serializers.SerializerMethodField() url_800 = serializers.SerializerMethodField() url_1280 = serializers.SerializerMethodField() class ImagesAPIEndpoint(WagtailImagesAPIEndpoint): base_serializer_class = ImageSerializer meta_fields = WagtailImagesAPIEndpoint.meta_fields + [ 'url_400', 'url_640', 'url_800', 'url_1280' ] api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('images', ImagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint)
known_query_parameters = PagesAPIViewSet.known_query_parameters.union( ["content_type", "token"] ) def listing_view(self, request): page = self.get_object() serializer = self.get_serializer(page) return Response(serializer.data) def detail_view(self, request, pk): page = self.get_object() serializer = self.get_serializer(page) return Response(serializer.data) def get_object(self): app_label, model = self.request.GET["content_type"].split(".") content_type = ContentType.objects.get(app_label=app_label, model=model) page_preview = PagePreview.objects.get( content_type=content_type, token=self.request.GET["token"] ) page = page_preview.as_page() if not page.pk: # fake primary key to stop API URL routing from complaining page.pk = 0 return page api_router.register_endpoint("page_preview", PagePreviewAPIEndpoint)
""" obj = super().get_object() revision_id = self.request.query_params.get('revision-id') if revision_id: revision = get_object_or_404(obj.revisions, id=revision_id) else: revision = obj.revisions.order_by('-created_at').first() # in case of no revisions, return the object (edge case) if not revision: return obj base = revision.as_page_object() return base.specific @classmethod def get_urlpatterns(cls): """ Only get page by id allowed. """ return [ url(r'^(?P<pk>\d+)/$', cls.as_view({'get': 'detail_view'}), name='detail'), ] api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('preview-pages', PreviewPagesAPIEndpoint)
#!/usr/bin/env python from wagtail.api.v2.views import PagesAPIViewSet from wagtail.api.v2.router import WagtailAPIRouter # from wagtail.exhibitions.api.v2.views import ImagesAPIViewSet from wagtail.documents.api.v2.views import DocumentsAPIViewSet # Create the router. "wagtailapi" is the URL namespace from home.views import MediaAPIViewSet, ImagesAPIViewSet api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, exhibitions). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet) api_router.register_endpoint('exhibitions', ImagesAPIViewSet) api_router.register_endpoint('media', MediaAPIViewSet) api_router.register_endpoint('images', ImagesAPIViewSet)
from wagtail.api.v2.router import WagtailAPIRouter from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from django.conf.urls import include, url from django.conf.urls.static import static from django.conf import settings from django.contrib.auth.decorators import login_required from django.views.decorators.csrf import csrf_exempt from django.views.generic import RedirectView import core.views import export_readiness.views api_router = WagtailAPIRouter('api') api_router.register_endpoint('pages', core.views.PagesOptionalDraftAPIEndpoint) api_urls = [ url(r'^', api_router.urls), url(r'^pages/lookup-by-slug/(?P<slug>[\w-]+)/', api_router.wrap_view( core.views.PageLookupBySlugAPIEndpoint.as_view( {'get': 'detail_view'})), name='lookup-by-slug'), url(r'^pages/lookup-by-full-path/$', api_router.wrap_view( core.views.PageLookupByFullPathAPIEndpoint.as_view( {'get': 'detail_view'})), name='lookup-by-full-path'), url(r'^pages/lookup-by-tag/(?P<slug>[\w-]+)/$', api_router.wrap_view(
from wagtail.api.v2.views import PagesAPIViewSet from wagtail.api.v2.router import WagtailAPIRouter # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIViewSet)
self.listing_default_fields += [ "article_image", "article_image_thumbnail", "article_teaser", "article_date", "title", "slug", "first_published_at", "live" ] self.nested_default_fields += [ "title", ] # https://github.com/wagtail/wagtail/blob/971bdc0799a800a373e7326d9e564813934c09c6/wagtail/api/v2/views.py def get_base_queryset(self): queryset = ContentPage.objects.all().public().live().order_by('-article_date') return queryset class CustomImagesAPIViewset(ImagesAPIViewSet): def __init__(self): ImagesAPIViewSet.__init__(self) self.meta_fields += ["caption"] api_router.register_endpoint("pages", ContentPagesAPIViewSet) api_router.register_endpoint("images", CustomImagesAPIViewset)
from wagtail.api.v2.router import WagtailAPIRouter from hra.glossary.endpoints import GlossaryTermsAPIEndpoint api_router = WagtailAPIRouter('wagtailapi') api_router.register_endpoint('glossary_terms', GlossaryTermsAPIEndpoint)
from django.urls import path from wagtail.api.v2.router import WagtailAPIRouter from wagtail.core import hooks from .views import PagesAdminAPIViewSet admin_api = WagtailAPIRouter('wagtailadmin_api') admin_api.register_endpoint('pages', PagesAdminAPIViewSet) for fn in hooks.get_hooks('construct_admin_api'): fn(admin_api) urlpatterns = [ path('main/', admin_api.urls), ]
from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from home.models import PersonAPIEndpoint # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('people', PersonAPIEndpoint)
from wagtail.api.v2.router import WagtailAPIRouter from wagtail_spa_integration.views import SPAExtendedPagesAPIEndpoint, RedirectViewSet from wagtail_spa_integration.headless_preview_api import PagePreviewAPIViewSet api_router = WagtailAPIRouter('wagtailapi') api_router.register_endpoint('pages', SPAExtendedPagesAPIEndpoint) api_router.register_endpoint('page_preview', PagePreviewAPIViewSet) api_router.register_endpoint('redirects', RedirectViewSet)
from wagtail.images.api.v2.views import ImagesAPIViewSet from wagtail.documents.api.v2.views import DocumentsAPIViewSet # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') from activity.endpoints import ActivitiesAPIEndpoint from assets.endpoints import AssetsAPIEndpoint from modules.endpoints import ModulesAPIEndpoint from taxonomy.endpoints import StandardAPIEndpoint, StandardsBodyAPIEndpoint, ProgramsAPIEndpoint, AudienceAPIEndpoint, TagAPIEndpoint, TopicAPIEndpoint, AssetTypeAPIEndpoint, ActivityTypeAPIEndpoint, TimeEstimateAPIEndpoint, LearningSpaceAPIEndpoint # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIViewSet) api_router.register_endpoint('images', ImagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet) # Custom API Endpoints api_router.register_endpoint('activities', ActivitiesAPIEndpoint) api_router.register_endpoint('assets', AssetsAPIEndpoint) api_router.register_endpoint('modules', ModulesAPIEndpoint) api_router.register_endpoint('standards', StandardAPIEndpoint) api_router.register_endpoint('standards-body', StandardsBodyAPIEndpoint) api_router.register_endpoint('programs', ProgramsAPIEndpoint) api_router.register_endpoint('audiences', AudienceAPIEndpoint) api_router.register_endpoint('tags', TagAPIEndpoint) api_router.register_endpoint('topics', TopicAPIEndpoint) api_router.register_endpoint('asset-type', AssetTypeAPIEndpoint) api_router.register_endpoint('activity-type', ActivityTypeAPIEndpoint)
from wagtail.api.v2.router import WagtailAPIRouter from .views import CustomPagesAPIEndpoint, CustomImagesAPIEndpoint, CustomDocumentsAPIEndpoint, PagePreviewAPIEndpoint # Init the Wagtail Router api_router = WagtailAPIRouter('wagtailapi') api_router.register_endpoint('page_preview', PagePreviewAPIEndpoint) api_router.register_endpoint('pages', CustomPagesAPIEndpoint) api_router.register_endpoint('images', CustomImagesAPIEndpoint) api_router.register_endpoint('documents', CustomDocumentsAPIEndpoint)
from django.urls import path from wagtail.api.v2.router import WagtailAPIRouter from wagtail.core import hooks from .views import PagesAdminAPIViewSet admin_api = WagtailAPIRouter("wagtailadmin_api") admin_api.register_endpoint("pages", PagesAdminAPIViewSet) for fn in hooks.get_hooks("construct_admin_api"): fn(admin_api) urlpatterns = [ path("main/", admin_api.urls), ]
from __future__ import absolute_import, unicode_literals from django.conf.urls import url from wagtail.api.v2.router import WagtailAPIRouter from wagtail.wagtailcore import hooks from .endpoints import PagesAdminAPIEndpoint admin_api = WagtailAPIRouter('wagtailadmin_api_v1') admin_api.register_endpoint('pages', PagesAdminAPIEndpoint) for fn in hooks.get_hooks('construct_admin_api'): fn(admin_api) urlpatterns = [ url(r'^v2beta/', admin_api.urls), ]
@method_decorator(cache_page(60 * 60 * 2)) def list(self, request, *args, **kwargs): super(ContentPagesViewSet, self).list(self, request, *args, **kwargs) def get_queryset(self): queryset = super(ContentPagesViewSet, self).get_queryset() tag = self.request.query_params.get("tag") if tag is not None: ids = [] for t in ContentPageTag.objects.all(): if t.tag.name == tag: ids.append(t.content_object_id) queryset = queryset.filter(id__in=ids) return queryset class ContentPageIndexViewSet(PagesAPIViewSet): pagination_class = PageNumberPagination def get_queryset(self): return ContentPageIndex.objects.live() api_router = WagtailAPIRouter("wagtailapi") api_router.register_endpoint("pages", ContentPagesViewSet) api_router.register_endpoint("indexes", ContentPageIndexViewSet) api_router.register_endpoint("images", ImagesAPIViewSet) api_router.register_endpoint("documents", DocumentsAPIViewSet)
return self.get_paginated_response(serializer.data) def detail_view(self, request, pk): if not self.include_draft(): return super(DraftPagesAPIViewSet, self).detail_view(request, pk) instance = self.get_object().get_latest_revision_as_page() serializer = self.get_serializer(instance) return Response(serializer.data) class DraftBlogPagesAPIViewSet(DraftPagesAPIViewSet): listing_default_fields = ['id', 'type', 'detail_url', 'body'] def get_queryset(self): from backend_site.blog.models import BlogPage return BlogPage.objects.filter( id__in=self.get_base_queryset().values_list('id', flat=True)) # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', DraftPagesAPIViewSet) api_router.register_endpoint('images', ImagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet) api_router.register_endpoint('blogs', DraftBlogPagesAPIViewSet)
from wagtail.images.api.v2.views import ImagesAPIViewSet from wagtail.documents.api.v2.views import DocumentsAPIViewSet from django.contrib.contenttypes.models import ContentType from wagtail_headless_preview.models import PagePreview from rest_framework.response import Response # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIViewSet) api_router.register_endpoint('images', ImagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet) class PagePreviewAPIViewSet(PagesAPIViewSet): known_query_parameters = PagesAPIViewSet.known_query_parameters.union(['content_type', 'token']) def listing_view(self, request): page = self.get_object() serializer = self.get_serializer(page) return Response(serializer.data) def detail_view(self, request, pk): page = self.get_object() serializer = self.get_serializer(page)
from wagtail.api.v2.router import WagtailAPIRouter from wagtail.wagtailcore.models import Page from reactail.serializers import ReactPageSerializer class ReactPagesAPIEndpoint(PagesAPIEndpoint): """Expose Pages as API endpoint.""" base_serializer_class = ReactPageSerializer model = Page meta_fields = PagesAPIEndpoint.meta_fields + [ 'excerpt', 'image', 'published_at', 'show_in_menus', 'url_path', ] listing_default_fields = PagesAPIEndpoint.listing_default_fields + [ 'excerpt', 'image', 'parent', 'published_at', 'show_in_menus', 'url_path', ] detail_only_fields = [] # hide parent field api_router = WagtailAPIRouter('wagtailapi') api_router.register_endpoint(settings.API_PAGES_PATH, ReactPagesAPIEndpoint)
if self.action == 'listing_view': show_details = False model = getattr(self, 'queryset', self.get_queryset()).model else: # Allow "detail_only" (eg parent) fields on detail view show_details = True model = type(self.get_object()) # Fields try: fields_config = parse_fields_parameter( self.request.GET.get('fields', [])) except ValueError as e: raise BadRequestError("fields error: %s" % str(e)) return self._get_serializer_class(self.request.wagtailapi_router, model, fields_config, show_details=show_details) admin_api = WagtailAPIRouter('gem_wagtailadmin_api_v1') admin_api.register_endpoint('pages', GemPagesAdminApi) for fn in hooks.get_hooks('construct_admin_api'): fn(admin_api) urlpatterns = [ url(r'^v2beta/', admin_api.urls), ]
from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.core.models import Page from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint class AltPagesEndpoint(PagesAPIEndpoint): def get_object(self): lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field page_id = self.kwargs[lookup_url_kwarg] base = Page.objects.get(id=page_id) return base.specific # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the four endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests # This is for internal use only api_router.register_endpoint('release_pages', AltPagesEndpoint) api_router.register_endpoint('images', ImagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint)
# api.py from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint from home.app_view import AppPagesAPIEndpoint, TagsAPIEndpoint # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('images', ImagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint) api_router.register_endpoint('app', AppPagesAPIEndpoint) api_router.register_endpoint('tags', TagsAPIEndpoint)
meta_fields = BaseAPIViewSet.meta_fields + ['title'] known_query_parameters = BaseAPIViewSet.known_query_parameters.union([ 'current_month', ]) def get_queryset(self): current_month = self.request.query_params.get('current_month', None) if (current_month): try: reference = datetime.strptime(current_month, '%Y-%m-%d') except: reference = datetime.now() else: reference = datetime.now() reference = make_aware(reference) start = reference - relativedelta(months=3) end = reference + relativedelta(months=3) return self.model.objects.filter(date__gte=start, date__lte=end) api_router.register_endpoint('images', CustomImagesAPIEndpoint) api_router.register_endpoint('events', CalendarItemAPIEndpoint)
from django.urls import path class MyNavMenuViewSet(NavMenuViewSet): """ Our custom Pages API endpoint that allows finding pages by pk or slug """ @classmethod def get_urlpatterns(cls): """ This returns a list of URL patterns for the endpoint """ return [ path('', cls.as_view({'get': 'list'}), name='listing'), path('<int:pk>/', cls.as_view({'get': 'retrieve'}), name='detail'), ] # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', PagesAPIViewSet) api_router.register_endpoint('images', ImagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet) api_router.register_endpoint('users', UsersAPIViewSet) api_router.register_endpoint('menus', MyNavMenuViewSet)
from wagtail.api.v2.views import PagesAPIViewSet from wagtail.api.v2.router import WagtailAPIRouter from wagtail.images.api.v2.views import ImagesAPIViewSet from wagtail.documents.api.v2.views import DocumentsAPIViewSet from rest_framework.routers import DefaultRouter # from jobs.api import JobsViewSet # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter("wagtailapi") # DRF router used for menu items drf_router = DefaultRouter() # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint("pages", PagesAPIViewSet) api_router.register_endpoint("images", ImagesAPIViewSet) api_router.register_endpoint("documents", DocumentsAPIViewSet) # Add DRF content here # drf_router.register(r"jobs", JobsViewSet)
} class PageRelativeUrlListAPIViewSet(PagesAPIViewSet): """Return all pages and their relative url""" def get_serializer(self, qs, many=True): return PageRelativeUrlListSerializer(qs, many=many) @classmethod def get_urlpatterns(cls): return [ path("", cls.as_view({"get": "listing_view"}), name="listing"), ] api_router.register_endpoint("page_relative_urls", PageRelativeUrlListAPIViewSet) class PagePreviewAPIViewSet(BaseAPIViewSet): known_query_parameters = PagesAPIViewSet.known_query_parameters.union( ["content_type", "token"]) def listing_view(self, request): page = self.get_object() return page.serve(request) def get_object(self): content_type = self.request.GET.get("content_type") if not content_type: raise ValidationError({"content_type": "Missing value"})
return redirect( reverse('wagtailapi:pages:listing') + f'?{self.lookup_field}={param}') @classmethod def get_urlpatterns(cls): """ This returns a list of URL patterns for the endpoint """ return [ path('', cls.as_view({'get': 'listing_view'}), name='listing'), path('<int:pk>/', cls.as_view({'get': 'detail_view'}), name='detail'), path('<slug:slug>/', cls.as_view({'get': 'detail_view'}), name='detail'), path('find/', cls.as_view({'get': 'find_view'}), name='find'), ] # Create the router. “wagtailapi” is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # Add the three endpoints using the "register_endpoint" method. # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('pages', OpenstaxPagesAPIEndpoint) api_router.register_endpoint('images', ImagesAPIViewSet) api_router.register_endpoint('documents', DocumentsAPIViewSet)
from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.wagtailimages.api.v2.endpoints import ImagesAPIEndpoint v2 = WagtailAPIRouter('wagtailapi_v2') v2.register_endpoint('pages', PagesAPIEndpoint) v2.register_endpoint('images', ImagesAPIEndpoint)
from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.contrib.sitemaps import views as sitemaps_views from wagtail.contrib.sitemaps import Sitemap from wagtail.tests.testapp import urls as testapp_urls from wagtail.admin import urls as wagtailadmin_urls from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint from wagtail.images import urls as wagtailimages_urls from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint from wagtail.images.tests import urls as wagtailimages_test_urls from wagtail.search import urls as wagtailsearch_urls api_router = WagtailAPIRouter('wagtailapi_v2') api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('images', ImagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint) urlpatterns = [ url(r'^admin/', include(wagtailadmin_urls)), url(r'^search/', include(wagtailsearch_urls)), url(r'^documents/', include(wagtaildocs_urls)), url(r'^testimages/', include(wagtailimages_test_urls)), url(r'^images/', include(wagtailimages_urls)), url(r'^api/v2beta/', api_router.urls), url(r'^sitemap\.xml$', sitemaps_views.sitemap), url(r'^sitemap-index\.xml$', sitemaps_views.index, {
from bot.api import BotCommandAPIEndpoint from wagtail.api.v2.endpoints import BaseAPIEndpoint from wagtail.api.v2.endpoints import PagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') # The first parameter is the name of the endpoint (eg. pages, images). This # is used in the URL of the endpoint # The second parameter is the endpoint class that handles the requests api_router.register_endpoint('commands', BotCommandAPIEndpoint)
# coding=utf-8 #!/usr/bin/env python from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.endpoints import PagesAPIEndpoint api_router = WagtailAPIRouter('ofertasapi') api_router.register_endpoint('pages', PagesAPIEndpoint)
from wagtail.api.v2.router import WagtailAPIRouter from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint from molo.core.api import admin_views from molo.core.api.endpoints import ( MoloImagesAPIEndpoint, MoloPagesEndpoint, LanguagesAPIEndpoint, ) # Adding extended images endpoint to new router. # For consistency, the "pages" and "documents" # endpoints have also been added even though they were # not modified. api_router = WagtailAPIRouter("wagtailapi_v2") api_router.register_endpoint("images", MoloImagesAPIEndpoint) api_router.register_endpoint("pages", MoloPagesEndpoint) api_router.register_endpoint("documents", DocumentsAPIEndpoint) api_router.register_endpoint("languages", LanguagesAPIEndpoint) urlpatterns = [ url( r"^import-site/$", admin_views.SiteImportView.as_view(), name="site-import" ), url( r"^import-content/$", admin_views.MainImportView.as_view(), name="main-import" ),