summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-04-12 15:50:39 -0400
committerluxagraf <sng@luxagraf.net>2020-04-12 15:50:39 -0400
commitdbe6b6221e980a0fd45aaccd268532ab6500c9df (patch)
tree8dbca75a620d0663d498d18f76630dc0985740d5 /app
parent8024ee33de61150b8dad3c0b15952bf54ff45e1a (diff)
added new category model
Diffstat (limited to 'app')
-rw-r--r--app/jrnl/models.py8
-rw-r--r--app/posts/admin.py2
-rw-r--r--app/posts/migrations/0009_auto_20200407_1347.py28
-rw-r--r--app/posts/models.py23
-rw-r--r--app/taxonomy/migrations/0003_category_pluralized_name.py18
-rw-r--r--app/taxonomy/models.py3
6 files changed, 76 insertions, 6 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py
index a1ab9a7..a10c5a6 100644
--- a/app/jrnl/models.py
+++ b/app/jrnl/models.py
@@ -278,9 +278,11 @@ def post_save_events(sender, update_fields, created, instance, **kwargs):
"""
Creates a generic related entry when a new post is added
"""
- if created or 'title' in update_fields or 'slug' in update_fields:
- related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pubdate)
- if not c:
+ if created:
+ related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug)
+ if update_fields:
+ if 'title' in update_fields or 'slug' in update_fields:
+ related, c = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pubdate)
related.title = instance.title
related.slug = instance.slug
related.save()
diff --git a/app/posts/admin.py b/app/posts/admin.py
index 3c93411..eaf1a1c 100644
--- a/app/posts/admin.py
+++ b/app/posts/admin.py
@@ -38,7 +38,7 @@ class EntryAdmin(OSMGeoAdmin):
list_display = ('title', 'post_type', 'pub_date', 'template_name', 'status',)
search_fields = ['title', 'body_markdown']
prepopulated_fields = {"slug": ('title',)}
- list_filter = ('pub_date', 'enable_comments', 'status')
+ list_filter = ('post_type', 'pub_date', 'enable_comments', 'status')
filter_horizontal = ('related',)
fieldsets = (
('Entry', {
diff --git a/app/posts/migrations/0009_auto_20200407_1347.py b/app/posts/migrations/0009_auto_20200407_1347.py
new file mode 100644
index 0000000..0f736b9
--- /dev/null
+++ b/app/posts/migrations/0009_auto_20200407_1347.py
@@ -0,0 +1,28 @@
+# Generated by Django 2.1.2 on 2020-04-07 13:47
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('posts', '0008_post_topics'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='post',
+ name='has_code',
+ field=models.BooleanField(blank=True, default=False),
+ ),
+ migrations.AlterField(
+ model_name='post',
+ name='post_type',
+ field=models.IntegerField(choices=[(0, 'field test'), (1, 'review'), (2, 'essay'), (3, 'src')], default=0),
+ ),
+ migrations.AlterField(
+ model_name='post',
+ name='short_title',
+ field=models.CharField(blank=True, max_length=200, null=True),
+ ),
+ ]
diff --git a/app/posts/models.py b/app/posts/models.py
index d4000d9..7e05ebb 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -36,7 +36,7 @@ from utils.util import render_images, render_products, parse_video, markdown_to_
class Post(models.Model):
old_id = models.IntegerField(blank=True, null=True)
title = models.CharField(max_length=200)
- short_title = models.CharField(max_length=200)
+ short_title = models.CharField(max_length=200, blank=True, null=True)
subtitle = models.CharField(max_length=200, blank=True)
slug = models.SlugField(unique_for_date='pub_date')
prologue_markdown = models.TextField(blank=True, null=True)
@@ -63,10 +63,12 @@ class Post(models.Model):
(0, 'field test'),
(1, 'review'),
(2, 'essay'),
+ (3, 'src'),
)
post_type = models.IntegerField(choices=POST_TYPE, default=0)
template_name = models.IntegerField(choices=TEMPLATES, default=0)
has_video = models.BooleanField(blank=True, default=False)
+ has_code = models.BooleanField(blank=True, default=False)
disclaimer = models.BooleanField(blank=True, default=True)
books = models.ManyToManyField(Book, blank=True)
field_notes = models.ManyToManyField(FieldNote, blank=True)
@@ -209,3 +211,22 @@ class PostSitemap(Sitemap):
def lastmod(self, obj):
return obj.pub_date
+
+"""
+for p in src:
+ s, created = Post.objects.get_or_create(
+ title=p.title,
+ slug=p.slug,
+ body_markdown=p.body_markdown,
+ pub_date=p.pub_date,
+ enable_comments=p.enable_comments,
+ has_code=p.has_code,
+ status=p.status,
+ meta_description=p.meta_description,
+ post_type=3,
+ )
+ print(p)
+ for t in p.topics.all():
+ c = Category.objects.get(slug=t.slug)
+ s.topics.add(c)
+"""
diff --git a/app/taxonomy/migrations/0003_category_pluralized_name.py b/app/taxonomy/migrations/0003_category_pluralized_name.py
new file mode 100644
index 0000000..a8c9586
--- /dev/null
+++ b/app/taxonomy/migrations/0003_category_pluralized_name.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.1.2 on 2020-04-07 13:35
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('taxonomy', '0002_auto_20191007_0913'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='category',
+ name='pluralized_name',
+ field=models.CharField(max_length=60, null=True),
+ ),
+ ]
diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py
index 9479a7f..4db3294 100644
--- a/app/taxonomy/models.py
+++ b/app/taxonomy/models.py
@@ -27,8 +27,9 @@ class TaggedItems(GenericTaggedItemBase):
class Category(models.Model):
""" Generic model for Categories """
name = models.CharField(max_length=250)
- color_rgb = models.CharField(max_length=20, blank=True)
+ pluralized_name = models.CharField(max_length=60, null=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)
date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False)