add wordpress migration
This commit is contained in:
@ -11,6 +11,7 @@ from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
from wagtail_wordpress_import.models import WPImportedPageMixin
|
||||
|
||||
from dnscms.fields import CommonStreamField
|
||||
|
||||
@ -49,7 +50,7 @@ class VenueRentalIndex(Page):
|
||||
graphql_fields = [GraphQLRichText("lead"), GraphQLStreamfield("body")]
|
||||
|
||||
|
||||
class VenuePage(Page):
|
||||
class VenuePage(WPImportedPageMixin, Page):
|
||||
# no children
|
||||
subpage_types = []
|
||||
parent_page_types = ["venues.VenueIndex"]
|
||||
@ -77,6 +78,12 @@ class VenuePage(Page):
|
||||
preposition = models.CharField(
|
||||
blank=True, max_length=255, help_text="Er man i eller på lokalet?"
|
||||
)
|
||||
tech_specs_url = models.URLField(
|
||||
blank=True,
|
||||
max_length=512,
|
||||
help_text="Lenke til tekniske spesifikasjoner for lokalet",
|
||||
)
|
||||
used_for = models.CharField(blank=True, max_length=255)
|
||||
capability_audio = models.CharField(blank=True, max_length=255)
|
||||
capability_audio_video = models.CharField(blank=True, max_length=255)
|
||||
capability_bar = models.CharField(blank=True, max_length=255)
|
||||
@ -114,6 +121,7 @@ class VenuePage(Page):
|
||||
FieldPanel("floor", heading="Etasje"),
|
||||
FieldPanel("preposition", heading="Preposisjon"),
|
||||
FieldPanel("show_as_bookable", heading="Vis på utleieside"),
|
||||
FieldPanel("used_for", heading="Egnet for"),
|
||||
MultiFieldPanel(
|
||||
heading="Kapabiliteter",
|
||||
children=capability_panels,
|
||||
@ -122,6 +130,7 @@ class VenuePage(Page):
|
||||
heading="Kapasitet",
|
||||
children=capacity_panels,
|
||||
),
|
||||
FieldPanel("tech_specs_url", heading="Tekniske spesifikasjoner"),
|
||||
]
|
||||
|
||||
graphql_fields = [
|
||||
@ -129,6 +138,8 @@ class VenuePage(Page):
|
||||
GraphQLStreamfield("body"),
|
||||
GraphQLString("floor"),
|
||||
GraphQLString("preposition"),
|
||||
GraphQLString("used_for"),
|
||||
GraphQLString("tech_specs_url"),
|
||||
GraphQLBoolean("show_as_bookable"),
|
||||
GraphQLString("capability_audio"),
|
||||
GraphQLString("capability_audio_video"),
|
||||
@ -142,3 +153,44 @@ class VenuePage(Page):
|
||||
search_fields = Page.search_fields + [
|
||||
index.SearchField("body"),
|
||||
]
|
||||
|
||||
settings_panels = Page.settings_panels + WPImportedPageMixin.wordpress_panels
|
||||
|
||||
def import_wordpress_data(self, data):
|
||||
import html
|
||||
|
||||
# Wagtail page model fields
|
||||
self.title = html.unescape(data["title"])
|
||||
self.slug = data["slug"]
|
||||
self.first_published_at = data["first_published_at"]
|
||||
self.last_published_at = data["last_published_at"]
|
||||
self.latest_revision_created_at = data["latest_revision_created_at"]
|
||||
self.search_description = data["search_description"]
|
||||
|
||||
# debug fields
|
||||
self.wp_post_id = data["wp_post_id"]
|
||||
self.wp_post_type = data["wp_post_type"]
|
||||
self.wp_link = data["wp_link"]
|
||||
self.wp_raw_content = data["wp_raw_content"]
|
||||
self.wp_block_json = data["wp_block_json"]
|
||||
self.wp_processed_content = data["wp_processed_content"]
|
||||
self.wp_normalized_styles = data["wp_normalized_styles"]
|
||||
self.wp_post_meta = data["wp_post_meta"]
|
||||
|
||||
# own model fields
|
||||
self.body = data["body"] or ""
|
||||
|
||||
meta = data["wp_post_meta"]
|
||||
self.show_as_bookable = meta.get("neuf_venues_show_on_booking_page", False)
|
||||
self.preposition = meta.get("neuf_venues_preposition") or ""
|
||||
self.floor = meta.get("neuf_venues_floor") or ""
|
||||
self.used_for = meta.get("neuf_venues_used_for") or ""
|
||||
|
||||
self.capability_bar = meta.get("neuf_venues_bar") or ""
|
||||
self.capability_audio = meta.get("neuf_venues_audio") or ""
|
||||
self.capability_lighting = meta.get("neuf_venues_lighting") or ""
|
||||
self.capability_audio_video = meta.get("neuf_venues_audio_video") or ""
|
||||
|
||||
self.capacity_legal = meta.get("neuf_venues_capacity_legal") or ""
|
||||
self.capacity_standing = meta.get("neuf_venues_capacity_standing") or ""
|
||||
self.capacity_sitting = meta.get("neuf_venues_capacity_sitting") or ""
|
||||
|
Reference in New Issue
Block a user