dnscms: add some simple fields to events
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from django.db import models
|
||||
from grapple.models import GraphQLStreamfield, GraphQLString
|
||||
from grapple.models import GraphQLImage, GraphQLInt, GraphQLStreamfield, GraphQLString
|
||||
from wagtail import blocks
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.admin.panels import FieldPanel, FieldRowPanel, HelpPanel, MultiFieldPanel
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
from wagtail.models import Page
|
||||
@ -17,28 +17,92 @@ class EventIndex(Page):
|
||||
class EventPage(Page):
|
||||
# no children
|
||||
subpage_types = []
|
||||
# should not be able to be shown in menus
|
||||
show_in_menus = False
|
||||
|
||||
# inherited from Page:
|
||||
# title = text
|
||||
# slug = text (in promote panel)
|
||||
# content_type = points to this model
|
||||
# live = bool
|
||||
# owner = page creator
|
||||
# first_published_at = datetime
|
||||
# last_published_at = datetime
|
||||
# seo_title: text (in promote panel)
|
||||
# search_description: text (in promote panel)
|
||||
|
||||
featured_image = models.ForeignKey(
|
||||
"wagtailimages.Image",
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="+",
|
||||
help_text=(
|
||||
"Velg et bilde til bruk i programmet og andre visningsflater. "
|
||||
"Bør være et bilde eller en illustrasjon uten tekst "
|
||||
"– ikke gjenbruk et Facebook-cover ukritisk!"
|
||||
),
|
||||
)
|
||||
|
||||
# author = models.CharField(max_length=255)
|
||||
# date = models.DateField("Post date")
|
||||
body = StreamField(
|
||||
[
|
||||
("heading", blocks.CharBlock(form_classname="title")),
|
||||
("paragraph", blocks.RichTextBlock()),
|
||||
("image", ImageChooserBlock()),
|
||||
]
|
||||
)
|
||||
|
||||
ticket_url = models.URLField(
|
||||
blank=True,
|
||||
max_length=512,
|
||||
help_text="Lenke direkte til billettkjøp, f.eks. TicketCo eller Ticketmaster",
|
||||
)
|
||||
facebook_url = models.URLField(
|
||||
blank=True,
|
||||
max_length=512,
|
||||
help_text="Lenke direkte til arrangementet på Facebook",
|
||||
)
|
||||
|
||||
# "event_types": [13],
|
||||
# "event_organizers": [390, 322],
|
||||
# "start_time": "2024-05-07T17:00:00+00:00",
|
||||
# "end_time": "2024-05-07T20:00:00+00:00",
|
||||
# "venue": "Glassbaren",
|
||||
# "venue_id": "55063",
|
||||
|
||||
price_regular = models.IntegerField(null=True, blank=True)
|
||||
price_student = models.IntegerField(null=True, blank=True)
|
||||
price_member = models.IntegerField(null=True, blank=True)
|
||||
|
||||
ticket_panels = [
|
||||
FieldPanel("ticket_url", heading="Billettkjøpslenke"),
|
||||
FieldRowPanel(
|
||||
children=[
|
||||
FieldPanel("price_regular", heading="Ordinær pris"),
|
||||
FieldPanel("price_student", heading="Pris for studenter"),
|
||||
FieldPanel("price_member", heading="Pris for medlemmer av DNS"),
|
||||
],
|
||||
help_text="",
|
||||
),
|
||||
HelpPanel(content="La alle prisfeltene stå tomme om arrangementet er gratis."),
|
||||
]
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
# FieldPanel('author'),
|
||||
# FieldPanel('date'),
|
||||
FieldPanel("featured_image"),
|
||||
FieldPanel("body"),
|
||||
MultiFieldPanel(
|
||||
heading="Priser og billettkjøp",
|
||||
children=ticket_panels,
|
||||
),
|
||||
]
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLString("heading"),
|
||||
# GraphQLString("date"),
|
||||
# GraphQLString("author"),
|
||||
GraphQLImage("featured_image"),
|
||||
GraphQLStreamfield("body"),
|
||||
GraphQLString("ticket_url"),
|
||||
GraphQLString("facebook_url"),
|
||||
GraphQLInt("price_regular"),
|
||||
GraphQLInt("price_student"),
|
||||
GraphQLInt("price_member"),
|
||||
]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user