side by side media
This commit is contained in:
parent
fc1a929428
commit
1351febef1
4 changed files with 39 additions and 7 deletions
18
app/event/migrations/0005_event_media.py
Normal file
18
app/event/migrations/0005_event_media.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -16,6 +16,7 @@ class Event(models.Model):
|
|||
type = models.CharField(blank=True, default='', max_length=1024)
|
||||
date = models.CharField(blank=True, null=True, max_length=1024)
|
||||
body = models.TextField(blank=True, null=True)
|
||||
media = models.TextField(blank=True, null=True)
|
||||
|
||||
data = models.JSONField(default=dict, blank=True, editable=False)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from .models import Event
|
||||
from ..page.models import Page
|
||||
|
@ -7,6 +7,7 @@ from ..page.models import Page
|
|||
|
||||
def index(request, slug=''):
|
||||
context = {}
|
||||
context['settings'] = settings
|
||||
context['events'] = Event.objects.all().order_by('position')
|
||||
context['postscript'] = Page.objects.get(slug='postscript')
|
||||
context['intro'] = Page.objects.get(slug='intro')
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
{% endblock title %}
|
||||
{% block title %}{{ settings.title }}{% endblock title %}
|
||||
{% block main %}
|
||||
<div class="index">
|
||||
<div class="intro">
|
||||
|
@ -9,12 +8,25 @@
|
|||
<div class="events">
|
||||
{% for event in events %}
|
||||
<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>
|
||||
<div class="date">{{ event.date }}</div>
|
||||
{{ event.body | safe }}
|
||||
{% if event.media %}
|
||||
<div class="side-by-side">
|
||||
<div class="media">
|
||||
{{ event.media | safe }}
|
||||
</div>
|
||||
<div class="text">
|
||||
{{ event.body | safe }}
|
||||
</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 %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue