add venues

This commit is contained in:
2024-05-10 18:26:07 +02:00
parent fc301a164b
commit 511715b75b
19 changed files with 697 additions and 27 deletions

View File

6
dnscms/venues/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class VenuesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'venues'

View File

@ -0,0 +1,42 @@
# Generated by Django 5.0.6 on 2024-05-10 15:31
import django.db.models.deletion
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0093_uploadedfile'),
('wagtailimages', '0026_delete_uploadedimage'),
]
operations = [
migrations.CreateModel(
name='VenuePage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('body', wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock())])),
('show_as_bookable', models.BooleanField(default=True, help_text='Skal lokalet dukke i oversikten over lokaler som leies ut?')),
('floor', models.CharField(blank=True, max_length=255)),
('preposition', models.CharField(blank=True, help_text='Er man i eller på lokalet?', 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)),
('capability_lighting', models.CharField(blank=True, max_length=255)),
('capacity_legal', models.CharField(blank=True, max_length=255)),
('capacity_standing', models.CharField(blank=True, max_length=255)),
('capacity_sitting', models.CharField(blank=True, max_length=255)),
('featured_image', models.ForeignKey(blank=True, help_text='Bilde av lokalet', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

View File

@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-05-10 15:32
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('venues', '0001_initial'),
('wagtailcore', '0093_uploadedfile'),
]
operations = [
migrations.CreateModel(
name='VenueIndex',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

View File

109
dnscms/venues/models.py Normal file
View File

@ -0,0 +1,109 @@
from django.db import models
from grapple.models import GraphQLBoolean, GraphQLImage, GraphQLStreamfield, GraphQLString
from wagtail import blocks
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel
from wagtail.fields import StreamField
from wagtail.images.blocks import ImageChooserBlock
from wagtail.models import Page
class VenueIndex(Page):
# there can only be one venue index page
max_count = 1
subpage_types = ["venues.VenuePage"]
graphql_fields = []
class VenuePage(Page):
# no children
subpage_types = []
# should not be able to be shown in menus
show_in_menus = False
featured_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
help_text=("Bilde av lokalet"),
)
body = StreamField(
[
("paragraph", blocks.RichTextBlock()),
("image", ImageChooserBlock()),
]
)
show_as_bookable = models.BooleanField(
default=True, help_text="Skal lokalet dukke i oversikten over lokaler som leies ut?"
)
floor = models.CharField(
blank=True,
max_length=255,
)
preposition = models.CharField(
blank=True, max_length=255, help_text="Er man i eller på lokalet?"
)
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)
capability_lighting = models.CharField(blank=True, max_length=255)
capacity_legal = models.CharField(blank=True, max_length=255)
capacity_standing = models.CharField(blank=True, max_length=255)
capacity_sitting = models.CharField(blank=True, max_length=255)
# "used_for": "Konsert, foredrag, fest, debatt, teater",
capability_panels = [
FieldRowPanel(
children=[
FieldPanel("capability_bar", heading="Bar"),
FieldPanel("capability_audio", heading="Lyd"),
FieldPanel("capability_lighting", heading="Lys"),
FieldPanel("capability_audio_video", heading="A/V"),
],
),
]
capacity_panels = [
FieldRowPanel(
children=[
FieldPanel("capacity_legal", heading="Branntillatelse for"),
FieldPanel("capacity_sitting", heading="Stående"),
FieldPanel("capacity_standing", heading="Sittende"),
],
),
]
content_panels = Page.content_panels + [
FieldPanel("featured_image"),
FieldPanel("body"),
FieldPanel("floor", heading="Etasje"),
FieldPanel("preposition", heading="Preposisjon"),
FieldPanel("show_as_bookable", heading="Vis på utleieside"),
MultiFieldPanel(
heading="Kapabiliteter",
children=capability_panels,
),
MultiFieldPanel(
heading="Kapasitet",
children=capacity_panels,
),
]
graphql_fields = [
GraphQLImage("featured_image"),
GraphQLStreamfield("body"),
GraphQLString("floor"),
GraphQLString("preposition"),
GraphQLBoolean("show_as_bookable"),
GraphQLString("capability_audio"),
GraphQLString("capability_audio_video"),
GraphQLString("capability_bar"),
GraphQLString("capability_lighting"),
GraphQLString("capacity_legal"),
GraphQLString("capacity_standing"),
GraphQLString("capacity_sitting"),
]