Photo posts

master
Pete Ley 7 months ago
parent 172ae3c7b5
commit 9be98c2162

@ -0,0 +1,38 @@
# Generated by Django 4.2.6 on 2023-10-26 05:58
import blog.models
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0089_log_entry_data_json_null_to_object'),
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
('blog', '0002_tagline'),
]
operations = [
migrations.CreateModel(
name='PhotoIndexPage',
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=(blog.models.PostIndexMixin, 'wagtailcore.page'),
),
migrations.CreateModel(
name='PhotoPage',
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')),
('photo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wagtailimages.image')),
],
options={
'abstract': False,
},
bases=(blog.models.PostMixin, 'wagtailcore.page'),
),
]

@ -113,10 +113,18 @@ class ArticlePage(PostMixin, Page):
parent_page_types = ['ArticleIndexPage']
post_types = [
'NoteIndexPage',
'ArticleIndexPage',
]
class PhotoPage(PostMixin, Page):
photo = models.ForeignKey(
'wagtailimages.Image',
on_delete=models.CASCADE,
)
content_panels = Page.content_panels + [
FieldPanel('photo'),
]
parent_page_types = ['PhotoIndexPage']
class PostIndexMixin:
show_in_menus_default = True
@ -146,7 +154,12 @@ class PostIndexMixin:
class RootIndexPage(PostIndexMixin, Page):
subpage_types = post_types
subpage_types = [
'NoteIndexPage',
'ArticleIndexPage',
'PhotoIndexPage',
]
def get_template(self, *args, **kwargs):
return 'blog/root_index_page.html'
@ -160,6 +173,10 @@ class RootIndexPage(PostIndexMixin, Page):
.live() \
.authorized(request) \
.count()
context['photo_count'] = PhotoPage.objects \
.live() \
.authorized(request) \
.count()
return context
@ -173,6 +190,11 @@ class ArticleIndexPage(PostIndexMixin, Page):
subpage_types = ['ArticlePage']
class PhotoIndexPage(PostIndexMixin, Page):
parent_page_types = ['RootIndexPage']
subpage_types = ['PhotoPage']
@register_snippet
class Tagline(models.Model):
text = models.CharField(max_length=255)

@ -0,0 +1,7 @@
{% load wagtailcore_tags wagtailimages_tags %}
<div class="fs-4">{{ post.title }}</div>
<a href="{% pageurl post %}"
class="fs-4 mb-auto link-underline link-underline-opacity-0 link-offset-3 link-underline-opacity-75-hover">
{% image post.specific.photo width-800 class="img-fluid" %}
</a>

@ -0,0 +1,10 @@
{% extends 'blog/_base_page.html' %}
{% load wagtailcore_tags wagtailimages_tags %}
{% block content %}
<h2 class="">{{ page.title }}</h2>
<div>
{% image page.photo original class="img-fluid" %}
</div>
{% endblock %}

@ -0,0 +1,5 @@
{% extends 'icons/_base.svg' %}
{% block body %}
viewBox="0 0 512 512">
<path d="M448 80c8.8 0 16 7.2 16 16V415.8l-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3V96c0-8.8 7.2-16 16-16H448zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/>
{% endblock %}

@ -0,0 +1 @@
[{"model": "blog.tagline", "pk": 1, "fields": {"text": "think. think again. think some more."}}, {"model": "blog.tagline", "pk": 2, "fields": {"text": "think, thank, thunk!"}}, {"model": "blog.tagline", "pk": 3, "fields": {"text": "thoughts so good you think them thrice"}}]
Loading…
Cancel
Save