diff options
author | luxagraf <sng@luxagraf.net> | 2020-04-12 15:50:39 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-04-12 15:50:39 -0400 |
commit | dbe6b6221e980a0fd45aaccd268532ab6500c9df (patch) | |
tree | 8dbca75a620d0663d498d18f76630dc0985740d5 /app/posts | |
parent | 8024ee33de61150b8dad3c0b15952bf54ff45e1a (diff) |
added new category model
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/admin.py | 2 | ||||
-rw-r--r-- | app/posts/migrations/0009_auto_20200407_1347.py | 28 | ||||
-rw-r--r-- | app/posts/models.py | 23 |
3 files changed, 51 insertions, 2 deletions
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) +""" |