summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/admin.py42
-rw-r--r--app/posts/migrations/0013_auto_20201111_2231.py23
-rw-r--r--app/posts/models.py8
3 files changed, 47 insertions, 26 deletions
diff --git a/app/posts/admin.py b/app/posts/admin.py
index eaf1a1c..1e2e845 100644
--- a/app/posts/admin.py
+++ b/app/posts/admin.py
@@ -12,18 +12,18 @@ from utils.util import get_latlon
@admin.register(Post)
-class EntryAdmin(OSMGeoAdmin):
+class PostAdmin(OSMGeoAdmin):
form = LGEntryForm
def get_queryset(self, request):
- test_model_qs = super(EntryAdmin, self).get_queryset(request)
+ test_model_qs = super(PostAdmin, self).get_queryset(request)
test_model_qs = test_model_qs.prefetch_related('related').prefetch_related('books')
return test_model_qs
def render_change_form(self, request, context, *args, **kwargs):
#context['adminform'].form.fields['featured_image'].queryset = LuxImage.objects.all()[:200]
- return super(EntryAdmin, self).render_change_form(request, context, *args, **kwargs)
+ return super(PostAdmin, self).render_change_form(request, context, *args, **kwargs)
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'thumbnail' or db_field.name == 'image':
@@ -32,22 +32,27 @@ class EntryAdmin(OSMGeoAdmin):
field = forms.CharField(widget=forms.Textarea(attrs={'rows': 4, 'cols': 75}))
field.required = False
else:
- field = super(EntryAdmin, self).formfield_for_dbfield(db_field, **kwargs)
+ field = super(PostAdmin, self).formfield_for_dbfield(db_field, **kwargs)
return field
list_display = ('title', 'post_type', 'pub_date', 'template_name', 'status',)
search_fields = ['title', 'body_markdown']
prepopulated_fields = {"slug": ('title',)}
list_filter = ('post_type', 'pub_date', 'enable_comments', 'status')
- filter_horizontal = ('related',)
+ filter_horizontal = ('related', 'books', 'field_notes')
fieldsets = (
('Entry', {
'fields': (
('title', 'short_title'),
'subtitle',
'body_markdown',
- ('pub_date', 'status', 'post_type', 'old_id',),
- 'slug',
+ ('pub_date', 'status', 'post_type'),
+ ('slug', 'enable_comments',),
+ 'point',
+ 'dek',
+ 'meta_description',
+ 'template_name',
+ ('featured_image','related'),
),
'classes': (
'show',
@@ -56,29 +61,22 @@ class EntryAdmin(OSMGeoAdmin):
)
}
),
- ('Metadata', {
- 'fields': (
- 'point',
- 'dek',
- 'meta_description',
- 'topics',
- 'template_name',
- 'enable_comments',
- 'featured_image',
- 'related',
- ('has_video', 'disclaimer',),
- ),
- }),
('Extras', {
'fields': (
'books',
- 'field_notes',
- 'jrnl',
+ 'field_notes',
+ ('has_video', 'disclaimer',),
+ 'topics',
'prologue_markdown',
'epilogue_markdown',
'originally_published_by',
'originally_published_by_url',
),
+ 'classes': (
+ 'collapse',
+ 'extrapretty',
+ 'wide'
+ )
}),
)
# options for OSM map Using custom ESRI topo map
diff --git a/app/posts/migrations/0013_auto_20201111_2231.py b/app/posts/migrations/0013_auto_20201111_2231.py
new file mode 100644
index 0000000..99de3fe
--- /dev/null
+++ b/app/posts/migrations/0013_auto_20201111_2231.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.1 on 2020-11-11 22:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('posts', '0012_remove_post_field_notes'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='post',
+ name='field_notes',
+ field=models.ManyToManyField(blank=True, limit_choices_to={'post_type': 5}, to='posts.Post'),
+ ),
+ migrations.AlterField(
+ model_name='post',
+ name='disclaimer',
+ field=models.BooleanField(blank=True, default=False),
+ ),
+ ]
diff --git a/app/posts/models.py b/app/posts/models.py
index 898dc49..5829fe9 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -27,7 +27,7 @@ from normalize.models import RelatedPost
from photos.models import LuxImage, LuxImageSize
from locations.models import Location
from books.models import Book
-from fieldnotes.models import FieldNote
+#from fieldnotes.models import FieldNote
from taxonomy.models import TaggedItems, Category
from utils.util import render_images, render_products, parse_video, markdown_to_html, extract_main_image
@@ -71,16 +71,16 @@ class Post(models.Model):
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)
+ disclaimer = models.BooleanField(blank=True, default=False)
books = models.ManyToManyField(Book, blank=True)
- field_notes = models.ManyToManyField(FieldNote, blank=True)
+ #field_notes = models.ManyToManyField(FieldNote, blank=True)
related = models.ManyToManyField(RelatedPost, blank=True)
point = models.PointField(null=True, blank=True)
location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True)
topics = models.ManyToManyField(Category, blank=True)
originally_published_by = models.CharField(max_length=400, null=True, blank=True)
originally_published_by_url = models.CharField(max_length=400, null=True, blank=True)
- field_notes = models.ManyToManyField(FieldNote, blank=True)
+ field_notes = models.ManyToManyField('self', blank=True, symmetrical=False, limit_choices_to = {'post_type': PostType.FIELD_NOTE})
books = models.ManyToManyField(Book, blank=True)
class Meta: