Added basic tagging to blog posts
parent
28a32d2f12
commit
5832137a34
@ -0,0 +1,33 @@
|
||||
# Generated by Django 2.1.2 on 2018-11-19 19:50
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import modelcluster.contrib.taggit
|
||||
import modelcluster.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('taggit', '0002_auto_20150616_2121'),
|
||||
('blog', '0003_blogpagegalleryimage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='BlogPageTag',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content_object', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='tagged_items', to='blog.BlogPage')),
|
||||
('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_blogpagetag_items', to='taggit.Tag')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='blogpage',
|
||||
name='tags',
|
||||
field=modelcluster.contrib.taggit.ClusterTaggableManager(blank=True, help_text='A comma-separated list of tags.', through='blog.BlogPageTag', to='taggit.Tag', verbose_name='Tags'),
|
||||
),
|
||||
]
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 2.1.2 on 2018-11-19 20:04
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0040_page_draft_title'),
|
||||
('blog', '0004_auto_20181119_1950'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='BlogTagIndexPage',
|
||||
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',),
|
||||
),
|
||||
]
|
@ -0,0 +1,38 @@
|
||||
{% extends "base.html" %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}helvetica{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<section class="mw7 center">
|
||||
{% if request.GET.tag|length %}
|
||||
<h1 class="ph3 ph0-l">Showing pages tagged "{{ request.GET.tag }}"</h1>
|
||||
{% endif %}
|
||||
|
||||
{% for post in blogpages %}
|
||||
{% with post=post.specific %}
|
||||
<article class="pv4 bt bb b--black-10 ph3 ph0-l">
|
||||
<a class="db pv4 ph3 ph0-l no-underline black dim" href="{% pageurl post %}">
|
||||
<div class="flex flex-column flex-row-ns">
|
||||
<div class="w-100 w-60-ns pr3-ns order-2 order-1-ns">
|
||||
<h1 class="f3 mt0 lh-title">{{ post.title }}</h1>
|
||||
<p class="f5 f4-l lh-copy">{{ post.intro }}</p>
|
||||
</div>
|
||||
<div class="pl3-ns order-1 order-2-ns mb4 mb0-ns w-100 w-40-ns">
|
||||
{% with post.main_image as main_image %}
|
||||
{% if main_image %}{% image main_image fill-320x240 class="db" %}{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
<p class="f6 lh-copy gray mv0">By <span class="ttu">{{ post.owner }}</span></p>
|
||||
<time class="f6 db gray">{{ post.date|date }}</time>
|
||||
</a>
|
||||
</article>
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
No pages found with that tag.
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
@ -1,13 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Internal server error</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Internal server error</h1>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Internal server error</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Internal server error</h1>
|
||||
|
||||
<h2>Sorry, there seems to be an error. Please try again soon.</h2>
|
||||
</body>
|
||||
<h2>Sorry, there seems to be an error. Please try again soon.</h2>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue