From 3ca2af74bbca76a66ec4164513822e774ad98211 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 20 Nov 2017 11:09:30 +1100 Subject: [PATCH] Rename tags to 'cats', a silly catgirl pun on 'categories' --- entries/migrations/0011_auto_20171120_1108.py | 24 +++++++++++++++++++ entries/models.py | 14 +++++------ entries/templates/entries/h-entry.html | 8 +++---- entries/urls.py | 4 ++-- entries/views.py | 10 ++++---- 5 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 entries/migrations/0011_auto_20171120_1108.py diff --git a/entries/migrations/0011_auto_20171120_1108.py b/entries/migrations/0011_auto_20171120_1108.py new file mode 100644 index 0000000..6e0020f --- /dev/null +++ b/entries/migrations/0011_auto_20171120_1108.py @@ -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', + ), + ] diff --git a/entries/models.py b/entries/models.py index 51ed872..d7c8143 100644 --- a/entries/models.py +++ b/entries/models.py @@ -17,20 +17,20 @@ from lemoncurry import requests ENTRY_KINDS = [(k.id, k.id) for k in kinds.all] -class TagManager(models.Manager): +class CatManager(models.Manager): def from_name(self, name): - tag, created = self.get_or_create(name=name, slug=slugify(name)) - return tag + cat, created = self.get_or_create(name=name, slug=slugify(name)) + return cat -class Tag(models.Model): - objects = TagManager() +class Cat(models.Model): + objects = CatManager() name = models.CharField(max_length=255, unique=True) slug = models.CharField(max_length=255, unique=True) @property def url(self): - return reverse('entries:tagged', args=(self.slug,)) + return reverse('entries:cat', args=(self.slug,)) class Meta: ordering = ('name',) @@ -55,7 +55,7 @@ class Entry(ModelMeta, TimeStampedModel): photo = models.ImageField(blank=True) 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) like_of = models.CharField(max_length=255, blank=True) diff --git a/entries/templates/entries/h-entry.html b/entries/templates/entries/h-entry.html index c4c8b40..99b31da 100644 --- a/entries/templates/entries/h-entry.html +++ b/entries/templates/entries/h-entry.html @@ -41,12 +41,12 @@ {% endif %} - {% if entry.tags.exists %} + {% if entry.cats.exists %} diff --git a/entries/urls.py b/entries/urls.py index 8e481c0..4821c1c 100644 --- a/entries/urls.py +++ b/entries/urls.py @@ -15,9 +15,9 @@ app_name = 'entries' urlpatterns = [ url('^atom$', feeds.AtomHomeEntries(), name='atom'), url('^rss$', feeds.RssHomeEntries(), name='rss'), - url('^tags/(?P.+)$', views.tagged, name='tagged'), + url('^cats/(?P.+)$', views.cat, name='cat'), ] -crumbs.add(prefix('tagged'), parent='home:index') +crumbs.add(prefix('cat'), parent='home:index') for k in kinds.all: kind = k.plural diff --git a/entries/views.py b/entries/views.py index 912839b..89fcc04 100644 --- a/entries/views.py +++ b/entries/views.py @@ -1,6 +1,6 @@ from annoying.decorators import render_to from django.shortcuts import get_object_or_404, redirect -from .models import Entry, Tag +from .models import Entry, Cat @render_to('entries/index.html') @@ -15,11 +15,11 @@ def index(request, kind): @render_to('entries/index.html') -def tagged(request, slug): - tag = get_object_or_404(Tag, slug=slug) +def cat(request, slug): + cat = get_object_or_404(Cat, slug=slug) return { - 'entries': tag.entries.all(), - 'title': '#' + tag.name, + 'entries': cat.entries.all(), + 'title': '#' + cat.name, }