-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into etna-rosetta
- Loading branch information
Showing
22 changed files
with
489 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: Deploy feature branch | ||
|
||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
# push: | ||
# branches: | ||
# - feature/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,6 @@ config/settings/local.py | |
.npm | ||
.nvm | ||
|
||
media | ||
media/images | ||
media/original_images | ||
coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
# from wagtail.api import APIField | ||
from wagtail.api.v2.router import WagtailAPIRouter | ||
from wagtail.api.v2.views import PagesAPIViewSet | ||
|
||
# from wagtail.documents.api.v2.views import DocumentsAPIViewSet | ||
from wagtail.images.api.v2.views import ImagesAPIViewSet | ||
|
||
from rest_framework.response import Response | ||
from wagtail_headless_preview.models import PagePreview | ||
from wagtailmedia.api.views import MediaAPIViewSet | ||
|
||
# from wagtail.images.api.fields import ImageRenditionField | ||
|
||
|
||
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) | ||
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 | ||
|
||
|
||
class CustomImagesAPIViewSet(ImagesAPIViewSet): | ||
body_fields = ImagesAPIViewSet.body_fields + [ | ||
# "collection", | ||
"title", | ||
"file", | ||
"copyright", | ||
"is_sensitive", | ||
"custom_sensitive_image_warning", | ||
"tags", | ||
# "focal_point_x", | ||
# "focal_point_y", | ||
# "focal_point_width", | ||
# "focal_point_height", | ||
"transcription_heading", | ||
"transcription", | ||
"translation_heading", | ||
"translation", | ||
"record", | ||
"record_dates", | ||
"description", | ||
# APIField( | ||
# "image_small_jpg", | ||
# serializer=ImageRenditionField("fill-128x128", source="file"), | ||
# ), | ||
] | ||
|
||
|
||
api_router = WagtailAPIRouter("wagtailapi") | ||
|
||
api_router.register_endpoint("pages", PagesAPIViewSet) | ||
api_router.register_endpoint("images", CustomImagesAPIViewSet) | ||
api_router.register_endpoint("media", MediaAPIViewSet) | ||
# api_router.register_endpoint("documents", DocumentsAPIViewSet) | ||
api_router.register_endpoint("page_preview", PagePreviewAPIViewSet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.