Rename tags to 'cats', a silly catgirl pun on 'categories'

This commit is contained in:
Danielle McLean 2017-11-20 11:09:30 +11:00
parent 2413a8aa96
commit 3ca2af74bb
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
5 changed files with 42 additions and 18 deletions

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-11-20 00:08
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('entries', '0010_entry_tags'),
]
operations = [
migrations.RenameModel(
old_name='Tag',
new_name='Cat',
),
migrations.RenameField(
model_name='entry',
old_name='tags',
new_name='cats',
),
]

View file

@ -17,20 +17,20 @@ from lemoncurry import requests
ENTRY_KINDS = [(k.id, k.id) for k in kinds.all] ENTRY_KINDS = [(k.id, k.id) for k in kinds.all]
class TagManager(models.Manager): class CatManager(models.Manager):
def from_name(self, name): def from_name(self, name):
tag, created = self.get_or_create(name=name, slug=slugify(name)) cat, created = self.get_or_create(name=name, slug=slugify(name))
return tag return cat
class Tag(models.Model): class Cat(models.Model):
objects = TagManager() objects = CatManager()
name = models.CharField(max_length=255, unique=True) name = models.CharField(max_length=255, unique=True)
slug = models.CharField(max_length=255, unique=True) slug = models.CharField(max_length=255, unique=True)
@property @property
def url(self): def url(self):
return reverse('entries:tagged', args=(self.slug,)) return reverse('entries:cat', args=(self.slug,))
class Meta: class Meta:
ordering = ('name',) ordering = ('name',)
@ -55,7 +55,7 @@ class Entry(ModelMeta, TimeStampedModel):
photo = models.ImageField(blank=True) photo = models.ImageField(blank=True)
content = models.TextField() content = models.TextField()
tags = models.ManyToManyField(Tag, related_name='entries') cats = models.ManyToManyField(Cat, related_name='entries')
in_reply_to = models.CharField(max_length=255, blank=True) in_reply_to = models.CharField(max_length=255, blank=True)
like_of = models.CharField(max_length=255, blank=True) like_of = models.CharField(max_length=255, blank=True)

View file

@ -41,12 +41,12 @@
{% endif %} {% endif %}
</div> </div>
{% if entry.tags.exists %} {% if entry.cats.exists %}
<div class="card-footer"> <div class="card-footer">
{% for t in entry.tags.all %} {% for c in entry.cats.all %}
<a class="p-category" href="{{ t.url }}"> <a class="p-category" href="{{ c.url }}">
<i class="fa fa-hashtag"></i> <i class="fa fa-hashtag"></i>
{{ t.name }} {{ c.name }}
</a> </a>
{% endfor %} {% endfor %}
</div> </div>

View file

@ -15,9 +15,9 @@ app_name = 'entries'
urlpatterns = [ urlpatterns = [
url('^atom$', feeds.AtomHomeEntries(), name='atom'), url('^atom$', feeds.AtomHomeEntries(), name='atom'),
url('^rss$', feeds.RssHomeEntries(), name='rss'), url('^rss$', feeds.RssHomeEntries(), name='rss'),
url('^tags/(?P<slug>.+)$', views.tagged, name='tagged'), url('^cats/(?P<slug>.+)$', views.cat, name='cat'),
] ]
crumbs.add(prefix('tagged'), parent='home:index') crumbs.add(prefix('cat'), parent='home:index')
for k in kinds.all: for k in kinds.all:
kind = k.plural kind = k.plural

View file

@ -1,6 +1,6 @@
from annoying.decorators import render_to from annoying.decorators import render_to
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from .models import Entry, Tag from .models import Entry, Cat
@render_to('entries/index.html') @render_to('entries/index.html')
@ -15,11 +15,11 @@ def index(request, kind):
@render_to('entries/index.html') @render_to('entries/index.html')
def tagged(request, slug): def cat(request, slug):
tag = get_object_or_404(Tag, slug=slug) cat = get_object_or_404(Cat, slug=slug)
return { return {
'entries': tag.entries.all(), 'entries': cat.entries.all(),
'title': '#' + tag.name, 'title': '#' + cat.name,
} }