def get_content(self, obj): # Create a dummy request request = self.create_request('/?format=json&fields=*') request.site = Site.objects.get(is_default_site=True) request.wagtailapi_router = WagtailAPIRouter('') response = self.endpoint_class.as_view({'get': 'detail_view'})(request, pk=obj.pk) if response.status_code == 200: return response.render().content handle_api_error(response)
def fetch_page_listing(self, page_num, model=None): if model: url = '/?format=json&fields=*&limit={}&offset={}&type={}.{}'.format(self.results_per_page, self.results_per_page * page_num, model._meta.app_label, model.__name__) else: url = '/?format=json&fields=*&limit={}&offset={}'.format(self.results_per_page, self.results_per_page * page_num) request = self.create_request(url) request.site = Site.objects.get(is_default_site=True) request.wagtailapi_router = WagtailAPIRouter('') response = PagesAPIEndpoint.as_view({'get': 'listing_view'})(request) if response.status_code == 200: content = response.render().content has_next_page = json.loads(content.decode('UTF-8'))['meta']['total_count'] > self.results_per_page * (page_num + 1) return content, has_next_page handle_api_error(response)
from django.conf.urls import url from djangorestframework_camel_case.render import CamelCaseJSONRenderer from oauth2_provider.ext.rest_framework import (OAuth2Authentication, TokenHasScope) from rest_framework.generics import get_object_or_404 from rest_framework.response import Response from wagtail.api.v2.endpoints import PagesAPIEndpoint as WagtailPagesAPIEndpoint from wagtail.api.v2.endpoints import BaseAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from home.models import HomePage from .serializers import PageSerializer api_router = WagtailAPIRouter('wagtailapi') class BasePagesAPIEndpoint(WagtailPagesAPIEndpoint): authentication_classes = [OAuth2Authentication] permission_classes = [TokenHasScope] required_scopes = ['read'] base_serializer_class = PageSerializer renderer_classes = [CamelCaseJSONRenderer] body_fields = WagtailPagesAPIEndpoint.body_fields + [ 'guide', 'content', 'description' ] meta_fields = BaseAPIEndpoint.meta_fields + [ 'html_url',
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)
from django.utils.timezone import make_aware from wagtail.images import get_image_model from wagtail.images.api.v2.serializers import ImageSerializer from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.serializers import BaseSerializer from wagtail.api.v2.views import BaseAPIViewSet from wagtail.api.v2.filters import FieldsFilter, OrderingFilter, SearchFilter from wagtail.api.v2.utils import get_full_url from rest_framework.fields import Field from home.models.snippets import CalendarItem # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter('wagtailapi') class ImageDownloadURLField(Field): def get_attribute(self, instance): return instance def to_representation(self, image): return image.file.url class CustomImageSerializer(ImageSerializer): download_url = ImageDownloadURLField(read_only=True) class CustomImagesAPIEndpoint(BaseAPIViewSet):
from django.conf import settings from django.conf.urls import url from django.shortcuts import get_object_or_404 from rest_framework.response import Response from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.serializers import PageSerializer from wagtail.api.v2.views import PagesAPIViewSet as WagtailPagesAPIViewSet from home.models import HomePage api_router = WagtailAPIRouter("wagtailapi") class BasePagesAPIViewSet(WagtailPagesAPIViewSet): required_scopes = ['read'] base_serializer_class = PageSerializer meta_fields = WagtailPagesAPIViewSet.meta_fields + [ 'html_url', 'url_path', 'slug', ] class PagesAPIViewSet(BasePagesAPIViewSet): """ Gets live content. """ def detail_view_by_path(self, _r, path):
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)
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.api.v2.router import WagtailAPIRouter from hra.glossary.endpoints import GlossaryTermsAPIEndpoint api_router = WagtailAPIRouter('wagtailapi') api_router.register_endpoint('glossary_terms', GlossaryTermsAPIEndpoint)
import student_profiles.urls, student_profiles.now_urls from taxonomy import views as taxonomy_views admin.autodiscover() # Signal handlers from wagtail.wagtailsearch.signal_handlers import register_signal_handlers as wagtailsearch_register_signal_handlers wagtailsearch_register_signal_handlers() from rca_ldap.signal_handlers import register_signal_handlers as rca_ldap_register_signal_handlers rca_ldap_register_signal_handlers() # Wagtail API api_router = WagtailAPIRouter('wagtailapi_v2') api_router.register_endpoint('pages', RCAPagesAPIEndpoint) api_router.register_endpoint('images', RCAImagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint) urlpatterns = patterns('', url(r'^django-admin/', include(admin.site.urls)), url(r'^admin/', include(wagtailadmin_urls)), url(r'^documents/', include(wagtaildocs_urls)), url(r'^images/', include(wagtailimages_urls)), url(r'^admin/donations/', include(donations_urls)), url(r'^admin/', include(rca_admin_urls)), url(r'^twitter/', include(twitter_urls)), url(r'^taxonomy/api/v1/$', never_cache(taxonomy_views.api), name='taxonomy_api_v0'), url(r'^api/v2/', include(decorate_urlpatterns(api_router.get_urlpatterns(), never_cache), namespace=api_router.url_namespace)),
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.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.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 # 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)
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 django.core.urlresolvers import reverse from rest_framework import serializers from wagtail.api.v2.endpoints import PagesAPIEndpoint as WagtailPagesAPIEndpoint from wagtail.api.v2.router import WagtailAPIRouter from wagtail.wagtailimages.api.v2.endpoints import ImagesAPIEndpoint as WagtailImagesAPIEndpoint from wagtail.wagtailimages.api.v2.serializers import ImageSerializer as WagtailImageSerializer from wagtail.wagtailimages.utils import generate_signature from wagtail.wagtaildocs.api.v2.endpoints import DocumentsAPIEndpoint api_router = WagtailAPIRouter('wagtailapi') class PagesAPIEndpoint(WagtailPagesAPIEndpoint): meta_fields = WagtailPagesAPIEndpoint.meta_fields + ['url_path'] listing_default_fields = WagtailPagesAPIEndpoint.listing_default_fields + [ 'url_path' ] def generate_image_url(image, filter_spec): signature = generate_signature(image.id, filter_spec) url = reverse('wagtailimages_serve', args=(signature, image.id, filter_spec)) # Append image's original filename to the URL (optional) url += image.file.name[len('original_images/'):] return url
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), ]
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.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)
# api.py 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 Projects.api import ProjectViewSet # 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)
from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.views import BaseAPIViewSet, ChildOfFilter, FieldsFilter, OrderingFilter from wagtail.images.api.v2.views import ImagesAPIViewSet from .models import ContentPage api_router = WagtailAPIRouter("wagtailapi") # Not 100% sure why I did it like this, but I guess it was to additional fields to the meta_fields / listing_default_fields. class ContentPagesAPIViewSet(BaseAPIViewSet): model = ContentPage def __init__(self): BaseAPIViewSet.__init__(self) self.filter_backends = [ ChildOfFilter, FieldsFilter, OrderingFilter ] self.known_query_parameters = self.known_query_parameters.union( [ "type", "child_of", "descendant_of", "translation_of", "locale", "live" ], )
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 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)
#!/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)
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 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 django.utils import translation from django.utils.module_loading import import_string from django.views import View from rest_framework import serializers, status from rest_framework.exceptions import ValidationError from rest_framework.response import Response from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.views import PagesAPIViewSet, BaseAPIViewSet from wagtail.core.forms import PasswordViewRestrictionForm from wagtail.core.models import Page, Site, PageViewRestriction from wagtail.core.wagtail_hooks import require_wagtail_login from wagtail.contrib.redirects.models import Redirect from wagtail.contrib.redirects.middleware import get_redirect from wagtail_headless_preview.models import PagePreview api_router = WagtailAPIRouter("nextjs") class PageRelativeUrlListSerializer(serializers.Serializer): def to_representation(self, obj): return { "title": obj.title, "relative_url": obj.get_url(None), } class PageRelativeUrlListAPIViewSet(PagesAPIViewSet): """Return all pages and their relative url""" def get_serializer(self, qs, many=True): return PageRelativeUrlListSerializer(qs, many=many)
from wagtail.admin import urls as wagtailadmin_urls 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-]+)/$',
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 django.contrib.contenttypes.models import ContentType from wagtail.api.v2.router import WagtailAPIRouter from wagtail.api.v2.views import PagesAPIViewSet from rest_framework.response import Response from wagtail_headless_preview.models import PagePreview # Create the router. "wagtailapi" is the URL namespace api_router = WagtailAPIRouter("wagtailapi_v2") class PagePreviewAPIEndpoint(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) return Response(serializer.data) def get_object(self): app_label, model = self.request.GET["content_type"].split(".")
# -*- coding: utf-8 -*- """ API ENDPOINT CONFIGURATION This file defines the API endpoints exposed by this application. """ 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.api import HomeAPIEndpoint api_router = WagtailAPIRouter("api") api_router.register_endpoint(r'home', HomeAPIEndpoint) api_router.register_endpoint('pages', PagesAPIEndpoint) api_router.register_endpoint('documents', DocumentsAPIEndpoint) api_router.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),
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"