dnscms: remove some wordpress import functionality, keep fields around but defer
This commit is contained in:
@@ -9,12 +9,16 @@ from grapple.models import (
|
||||
)
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import Page
|
||||
from wagtail.models import Page, PageManager
|
||||
from wagtail.search import index
|
||||
from wagtail_headless_preview.models import HeadlessMixin
|
||||
|
||||
from dnscms.fields import CommonStreamField
|
||||
from dnscms.wordpress.models import WPImportedPageMixin
|
||||
from dnscms.wordpress.models import DeferWPFieldsManagerMixin, WPImportedPageMixin
|
||||
|
||||
|
||||
class AssociationPageManager(DeferWPFieldsManagerMixin, PageManager):
|
||||
pass
|
||||
|
||||
|
||||
@register_singular_query_field("associationIndex")
|
||||
@@ -48,6 +52,8 @@ class AssociationPage(HeadlessMixin, WPImportedPageMixin, Page):
|
||||
parent_page_types = ["associations.AssociationIndex"]
|
||||
show_in_menus = False
|
||||
|
||||
objects = AssociationPageManager()
|
||||
|
||||
class AssociationType(models.TextChoices):
|
||||
FORENING = "forening", _("Association")
|
||||
UTVALG = "utvalg", _("Committee")
|
||||
@@ -97,33 +103,3 @@ class AssociationPage(HeadlessMixin, WPImportedPageMixin, Page):
|
||||
class Meta:
|
||||
verbose_name = _("association")
|
||||
verbose_name_plural = _("associations")
|
||||
|
||||
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.association_type = meta.get("neuf_associations_type").lower()
|
||||
self.website_url = meta.get("neuf_associations_homepage") or ""
|
||||
|
||||
self.excerpt = meta.get("excerpt_encoded") or "TODO"
|
||||
|
||||
Reference in New Issue
Block a user