side by side media

This commit is contained in:
j 2021-11-12 16:58:31 +00:00
parent fc1a929428
commit 1351febef1
4 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-12 16:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('event', '0004_alter_event_options'),
]
operations = [
migrations.AddField(
model_name='event',
name='media',
field=models.TextField(blank=True, null=True),
),
]

View file

@ -16,6 +16,7 @@ class Event(models.Model):
type = models.CharField(blank=True, default='', max_length=1024) type = models.CharField(blank=True, default='', max_length=1024)
date = models.CharField(blank=True, null=True, max_length=1024) date = models.CharField(blank=True, null=True, max_length=1024)
body = models.TextField(blank=True, null=True) body = models.TextField(blank=True, null=True)
media = models.TextField(blank=True, null=True)
data = models.JSONField(default=dict, blank=True, editable=False) data = models.JSONField(default=dict, blank=True, editable=False)

View file

@ -1,5 +1,5 @@
from django.shortcuts import render from django.shortcuts import render
from django.conf import settings
from .models import Event from .models import Event
from ..page.models import Page from ..page.models import Page
@ -7,6 +7,7 @@ from ..page.models import Page
def index(request, slug=''): def index(request, slug=''):
context = {} context = {}
context['settings'] = settings
context['events'] = Event.objects.all().order_by('position') context['events'] = Event.objects.all().order_by('position')
context['postscript'] = Page.objects.get(slug='postscript') context['postscript'] = Page.objects.get(slug='postscript')
context['intro'] = Page.objects.get(slug='intro') context['intro'] = Page.objects.get(slug='intro')

View file

@ -1,6 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}{{ settings.title }}{% endblock title %}
{% endblock title %}
{% block main %} {% block main %}
<div class="index"> <div class="index">
<div class="intro"> <div class="intro">
@ -9,13 +8,26 @@
<div class="events"> <div class="events">
{% for event in events %} {% for event in events %}
<div class="event" {% if event.date %}data-date="{{ event.date }}"{% endif %} id="{{ event.slug }}"> <div class="event" {% if event.date %}data-date="{{ event.date }}"{% endif %} id="{{ event.slug }}">
{% if request.user.is_staff %}
[<a href="admin/event/event/{{ event.id }}/change/">edit</a>]
{% endif %}
<h2 class="{{ event.type }}">{{ event.title | safe }}</h2> <h2 class="{{ event.type }}">{{ event.title | safe }}</h2>
<div class="date">{{ event.date }}</div> <div class="date">{{ event.date }}</div>
{% if event.media %}
<div class="side-by-side">
<div class="media">
{{ event.media | safe }}
</div>
<div class="text">
{{ event.body | safe }} {{ event.body | safe }}
</div> </div>
</div>
{% else %}
{{ event.body | safe }}
{% endif %}
{% if request.user.is_staff %}
<div class="menu">
[<a href="admin/event/event/{{ event.id }}/change/">edit</a>]
</div>
{% endif %}
</div>
{% endfor %} {% endfor %}
</div> </div>
<div class="postscript"> <div class="postscript">