Feedler APIv2 integrated
This commit is contained in:
parent
341ccb35c5
commit
aa5215d603
8 changed files with 53 additions and 24 deletions
|
@ -8,10 +8,12 @@ FEEDLER_APPS = (
|
|||
# Wagtail apps
|
||||
'wagtail.wagtailcore',
|
||||
'wagtail.wagtailadmin',
|
||||
'wagtail.contrib.wagtailroutablepage',
|
||||
'wagtail.contrib.modeladmin',
|
||||
'wagtail.contrib.wagtailroutablepage',
|
||||
'wagtail.api.v2',
|
||||
|
||||
# Third-party apps
|
||||
'rest_framework',
|
||||
|
||||
# My apps
|
||||
'feedler',
|
||||
|
|
7
feedler/api.py
Normal file
7
feedler/api.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from wagtail.api.v2.router import WagtailAPIRouter
|
||||
from .endpoints import EntriesAPIEndpoint
|
||||
|
||||
# Create the router. "wagtailapi" is the URL namespace
|
||||
api_router = WagtailAPIRouter('wagtailapi')
|
||||
|
||||
api_router.register_endpoint('entries', EntriesAPIEndpoint)
|
26
feedler/endpoints.py
Normal file
26
feedler/endpoints.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from wagtail.contrib.wagtailapi.endpoints import BaseAPIEndpoint
|
||||
from wagtail.contrib.wagtailapi.serializers import BaseSerializer
|
||||
from wagtail.contrib.wagtailapi.filters import FieldsFilter, OrderingFilter, SearchFilter
|
||||
from wagtail.contrib.wagtailapi.pagination import WagtailPagination
|
||||
|
||||
from .models import Entry
|
||||
|
||||
class EntrySerializer(BaseSerializer):
|
||||
pass
|
||||
|
||||
class EntriesAPIEndpoint(BaseAPIEndpoint):
|
||||
base_serializer_class = EntrySerializer
|
||||
filter_backends = [FieldsFilter, OrderingFilter, SearchFilter]
|
||||
extra_api_fields = [
|
||||
'title',
|
||||
'author',
|
||||
'link',
|
||||
'visual',
|
||||
'content',
|
||||
'tags',
|
||||
'published',
|
||||
]
|
||||
name = 'entries'
|
||||
model = Entry
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import date
|
||||
|
||||
from django.utils.dateformat import DateFormat
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.contrib.wagtailroutablepage.models import RoutablePageMixin, route
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailsearch.models import Query
|
||||
|
||||
class FeedlerRoutes(RoutablePageMixin):
|
||||
|
||||
@route(r'^$')
|
||||
def entries_list(self, request, *args, **kwargs):
|
||||
self.entries = self.get_entries()
|
||||
return Page.serve(self, request, *args, **kwargs)
|
10
feedler/urls.py
Normal file
10
feedler/urls.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from django.conf.urls import include, url
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
|
||||
from .api import api_router
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^api/v2/', api_router.urls),
|
||||
]
|
|
@ -1,3 +0,0 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -42,6 +42,9 @@ INSTALLED_APPS = [
|
|||
'wagtail.wagtailadmin',
|
||||
'wagtail.wagtailcore',
|
||||
|
||||
'wagtail.api.v2',
|
||||
'rest_framework',
|
||||
|
||||
'modelcluster',
|
||||
'compressor',
|
||||
'taggit',
|
||||
|
|
|
@ -6,13 +6,16 @@ from django.conf.urls.i18n import i18n_patterns
|
|||
from wagtail.wagtailadmin import urls as wagtailadmin_urls
|
||||
from wagtail.wagtaildocs import urls as wagtaildocs_urls
|
||||
from wagtail.wagtailcore import urls as wagtail_urls
|
||||
|
||||
from puput import urls as puput_urls
|
||||
from feedler import urls as feedler_urls
|
||||
|
||||
from publichealth.search import views as search_views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'', include(puput_urls)),
|
||||
url(r'', include(feedler_urls)),
|
||||
|
||||
url(r'^django-admin/', include(admin.site.urls)),
|
||||
|
||||
url(r'^admin/', include(wagtailadmin_urls)),
|
||||
|
|
Loading…
Reference in a new issue