From d5b3076645c9d52e2ca7ca83dd02cabcaf7360af Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Oct 2021 13:26:51 +0100 Subject: [PATCH] cleanups --- app/static/css/partials/_film.scss | 9 +-------- app/templates/about.html | 5 ----- app/templates/base.html | 11 +---------- app/templates/films.html | 14 ++------------ app/text/models.py | 20 +++++++++++++++----- app/text/views.py | 12 ++++++++++-- app/urls.py | 4 ++-- 7 files changed, 31 insertions(+), 44 deletions(-) delete mode 100644 app/templates/about.html diff --git a/app/static/css/partials/_film.scss b/app/static/css/partials/_film.scss index 016dd41..e37f536 100644 --- a/app/static/css/partials/_film.scss +++ b/app/static/css/partials/_film.scss @@ -1,15 +1,14 @@ .films { - width: 100vw; margin: 8px; + box-sizing: border-box; a { color: #ee0; text-decoration: none; } .film { - width: 100vw; margin-bottom: 16px; display: flex; flex-direction: row; @@ -28,12 +27,6 @@ .film { margin-bottom: 16px; flex-direction: column; - .left, .right { - width: 100%; - img { - max-width: 100%; - } - } h2 { margin-bottom: 8px; } diff --git a/app/templates/about.html b/app/templates/about.html deleted file mode 100644 index e65d078..0000000 --- a/app/templates/about.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "base.html" %} -{% block main %} -about page -{% endblock %} - diff --git a/app/templates/base.html b/app/templates/base.html index f28e4d3..53651a4 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -31,15 +31,6 @@ {% block main %}{% endblock main %} {% block end %}{% endblock end %} - + diff --git a/app/templates/films.html b/app/templates/films.html index 1807c81..0be24ab 100644 --- a/app/templates/films.html +++ b/app/templates/films.html @@ -3,18 +3,8 @@
{% for film in films %}
-
-

{{ film.data.title | safe }}

-

{{ film.data.director|join:", "|safe }}

-
- {% comment %} -
- - - - -
- {% endcomment %} +

{{ film.data.title | safe }}

+

{{ film.data.director|join:", "|safe }}

{% endfor %}
diff --git a/app/text/models.py b/app/text/models.py index 0ef0c35..897d92b 100644 --- a/app/text/models.py +++ b/app/text/models.py @@ -12,14 +12,24 @@ class Page(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) - slug = models.SlugField() + slug = models.SlugField(blank=True) public = models.BooleanField(default=False) - data = models.JSONField(default=dict) - title = models.TextField() - teaser = models.TextField() - body = models.TextField() + title = models.TextField(blank=True) + #teaser = models.TextField(blank=True) + body = models.TextField(blank=True) + data = models.JSONField(default=dict, blank=True) + + def __str__(self): + return '%s (%s)' % (self.title, self.slug) + + def get_absolute_url(self): + if self.slug: + return '/' + settings.URL_PREFIX + '' + self.slug + else: + return '/' + settings.URL_PREFIX[:-1] + class Text(models.Model): created = models.DateTimeField(auto_now_add=True) diff --git a/app/text/views.py b/app/text/views.py index 6fdfc24..e5d1b19 100644 --- a/app/text/views.py +++ b/app/text/views.py @@ -10,9 +10,17 @@ def index(request): context = {} return render(request, 'index.html', context) -def about(request): +def page(request, slug=''): context = {} - return render(request, 'about.html', context) + page = models.Page.objects.filter(slug=slug, public=True).first() + if page: + context['page'] = page + return render(request, 'page.html', context) + else: + return render(request, 'fallback.html', context) + +def about(request): + return page(request, 'about') def texts(request): context = {} diff --git a/app/urls.py b/app/urls.py index 4497acc..2fa3949 100644 --- a/app/urls.py +++ b/app/urls.py @@ -33,7 +33,7 @@ urlpatterns = [ path(settings.URL_PREFIX + 'assemblies/', text.texts, name='texts'), path(settings.URL_PREFIX + 'assemblies/', text.text, name='text'), path(settings.URL_PREFIX + 'about/', text.about, name='about'), - - path(settings.URL_PREFIX[:-1], text.index, name='index'), + path(settings.URL_PREFIX + '/', text.page, name='page'), + path(settings.URL_PREFIX[:-1], text.page, name='index'), path('', text.fallback, name='fallback'), ]