diff options
author | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
commit | e61f3d2c4537a2670c40b33eb02231a71dfb028a (patch) | |
tree | 587120b5a497c9e70d46e3eae7d1a219b5d4858b /app/taxonomy | |
parent | 534fcd39b1e8d24556d3bf110245a7373ee0eeb6 (diff) |
added a photograpy section by tweaking Category model and then adding
some urls
Diffstat (limited to 'app/taxonomy')
-rw-r--r-- | app/taxonomy/admin.py | 3 | ||||
-rw-r--r-- | app/taxonomy/migrations/0005_category_description.py | 18 | ||||
-rw-r--r-- | app/taxonomy/migrations/0006_auto_20210107_1611.py | 33 | ||||
-rw-r--r-- | app/taxonomy/models.py | 13 |
4 files changed, 66 insertions, 1 deletions
diff --git a/app/taxonomy/admin.py b/app/taxonomy/admin.py index 783584e..45e4e26 100644 --- a/app/taxonomy/admin.py +++ b/app/taxonomy/admin.py @@ -14,6 +14,9 @@ class CategoryAdmin(admin.ModelAdmin): 'name', 'color_rgb', 'slug', + "pluralized_name", + "description", + "intro_markdown", ), 'classes': ( 'show', diff --git a/app/taxonomy/migrations/0005_category_description.py b/app/taxonomy/migrations/0005_category_description.py new file mode 100644 index 0000000..bd2ec0b --- /dev/null +++ b/app/taxonomy/migrations/0005_category_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1 on 2021-01-07 15:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taxonomy', '0004_auto_20201114_0757'), + ] + + operations = [ + migrations.AddField( + model_name='category', + name='description', + field=models.CharField(max_length=300, null=True), + ), + ] diff --git a/app/taxonomy/migrations/0006_auto_20210107_1611.py b/app/taxonomy/migrations/0006_auto_20210107_1611.py new file mode 100644 index 0000000..1a875f7 --- /dev/null +++ b/app/taxonomy/migrations/0006_auto_20210107_1611.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1 on 2021-01-07 16:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taxonomy', '0005_category_description'), + ] + + operations = [ + migrations.AddField( + model_name='category', + name='intro_html', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='category', + name='intro_markdown', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='category', + name='description', + field=models.CharField(blank=True, max_length=300, null=True), + ), + migrations.AlterField( + model_name='category', + name='pluralized_name', + field=models.CharField(blank=True, max_length=60, null=True), + ), + ] diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py index 4db3294..6cc1769 100644 --- a/app/taxonomy/models.py +++ b/app/taxonomy/models.py @@ -3,6 +3,8 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.functional import cached_property +from utils.util import markdown_to_html + from taggit.models import TagBase, GenericTaggedItemBase @@ -27,7 +29,10 @@ class TaggedItems(GenericTaggedItemBase): class Category(models.Model): """ Generic model for Categories """ name = models.CharField(max_length=250) - pluralized_name = models.CharField(max_length=60, null=True) + pluralized_name = models.CharField(max_length=60, null=True, blank=True) + description = models.CharField(max_length=300, null=True, blank=True) + intro_markdown = models.TextField(null=True, blank=True) + intro_html = models.TextField(null=True, blank=True) slug = models.SlugField(blank=True) color_rgb = models.CharField(max_length=20, blank=True) date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False) @@ -42,3 +47,9 @@ class Category(models.Model): def get_absolute_url(self): return reverse("taxonomy:cat-detail", kwargs={"slug": self.slug}) + + + def save(self, *args, **kwargs): + if self.intro_markdown: + self.intro_html = markdown_to_html(self.intro_markdown) + super(Category, self).save(*args, **kwargs) |