diff options
Diffstat (limited to 'app/taxonomy')
-rw-r--r-- | app/taxonomy/admin.py | 3 | ||||
-rw-r--r-- | app/taxonomy/migrations/0001_initial.py | 19 | ||||
-rw-r--r-- | app/taxonomy/models.py | 15 | ||||
-rw-r--r-- | app/taxonomy/views.py | 6 |
4 files changed, 29 insertions, 14 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/0001_initial.py b/app/taxonomy/migrations/0001_initial.py index bde5e44..58e7cdb 100644 --- a/app/taxonomy/migrations/0001_initial.py +++ b/app/taxonomy/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.3 on 2020-11-30 22:45 +# Generated by Django 4.1.3 on 2022-12-02 20:08 from django.db import migrations, models import django.db.models.deletion @@ -16,9 +16,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Category', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=250)), - ('pluralized_name', models.CharField(max_length=60, null=True)), + ('pluralized_name', models.CharField(blank=True, max_length=60, null=True)), + ('description', models.CharField(blank=True, max_length=300, null=True)), + ('intro_markdown', models.TextField(blank=True, null=True)), + ('intro_html', models.TextField(blank=True, null=True)), ('slug', models.SlugField(blank=True)), ('color_rgb', models.CharField(blank=True, max_length=20)), ('date_created', models.DateTimeField(auto_now_add=True)), @@ -32,9 +35,9 @@ class Migration(migrations.Migration): migrations.CreateModel( name='LuxTag', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100, unique=True, verbose_name='name')), - ('slug', models.SlugField(max_length=100, unique=True, verbose_name='slug')), + ('slug', models.SlugField(allow_unicode=True, max_length=100, unique=True, verbose_name='slug')), ('color_rgb', models.CharField(blank=True, max_length=20)), ], options={ @@ -45,10 +48,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='TaggedItems', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('object_id', models.IntegerField(db_index=True, verbose_name='object ID')), - ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_taggeditems_tagged_items', to='contenttypes.contenttype', verbose_name='content type')), - ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_taggeditems_items', to='taxonomy.luxtag')), + ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_tagged_items', to='contenttypes.contenttype', verbose_name='content type')), + ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_items', to='taxonomy.luxtag')), ], options={ 'abstract': False, diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py index 4db3294..736fe15 100644 --- a/app/taxonomy/models.py +++ b/app/taxonomy/models.py @@ -1,8 +1,10 @@ from django.contrib.gis.db import models from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_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) diff --git a/app/taxonomy/views.py b/app/taxonomy/views.py index 2d749ab..354234c 100644 --- a/app/taxonomy/views.py +++ b/app/taxonomy/views.py @@ -1,14 +1,12 @@ from django.views.generic import ListView -from django.views.generic.detail import DetailView from django.contrib.syndication.views import Feed from django.urls import reverse from django.conf import settings -#from paypal.standard.forms import PayPalPaymentsForm - from .models import Category +from utils.views import LuxDetailView -class CategoryDetailView(DetailView): +class CategoryDetailView(LuxDetailView): model = Category slug_field = "slug" |