Mercurial > public > sg101
changeset 999:8386a8ebcbc7
WIP News v2.0 admin changes.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 21 Nov 2015 14:53:29 -0600 |
parents | e2c3d7ecfa30 |
children | abd4c02aefdb |
files | news/admin.py news/migrations/0005_auto_20151121_1445.py news/models.py news/static/js/news_admin.js |
diffstat | 4 files changed, 61 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/news/admin.py Fri Nov 20 23:07:37 2015 -0600 +++ b/news/admin.py Sat Nov 21 14:53:29 2015 -0600 @@ -22,9 +22,32 @@ search_fields = ['title', 'short_text', 'long_text'] date_hierarchy = 'date_submitted' actions = ['approve_story'] - readonly_fields = ['update_date'] + readonly_fields = ['update_date', 'version'] raw_id_fields = ['submitter'] + fieldsets = [ + (None, { + 'fields': ['title', 'submitter', 'category'], + }), + ('New Markdown Fields', { + 'fields': ['short_markup', 'long_markup'], + }), + ('HTML Fields', { + 'fields': ['short_text', 'long_text', 'admin_content'], + 'classes': ['collapse'], + }), + ('Meta Fields', { + 'fields': [ + 'date_submitted', 'allow_comments', 'tags', + 'front_page_expiration', 'priority', 'meta_description', + ] + }), + ('Read-Only Fields', { + 'fields': ['update_date', 'version'], + 'classes': ['collapse'], + }), + ] + def approve_story(self, request, qs): for pending_story in qs: story = Story( @@ -38,7 +61,10 @@ tags=pending_story.tags, front_page_expiration=pending_story.front_page_expiration, priority=pending_story.priority, - meta_description=pending_story.meta_description) + meta_description=pending_story.meta_description, + short_markup=pending_story.short_markup, + long_markup=pending_story.long_markup, + admin_content=pending_story.admin_content) story.save() pending_story.delete() @@ -57,10 +83,12 @@ list_filter = ['date_submitted', 'category'] search_fields = ['title', 'short_text', 'long_text'] date_hierarchy = 'date_submitted' - readonly_fields = ['update_date'] + readonly_fields = ['update_date', 'version'] raw_id_fields = ['submitter'] actions = ['fix_text'] + fieldsets = PendingStoryAdmin.fieldsets + def fix_text(self, request, qs): for story in qs: story.title = ftfy.fix_text(story.title)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/news/migrations/0005_auto_20151121_1445.py Sat Nov 21 14:53:29 2015 -0600 @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('news', '0004_auto_20151120_2228'), + ] + + operations = [ + migrations.AlterField( + model_name='pendingstory', + name='short_text', + field=models.TextField(default=b'', blank=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='story', + name='short_text', + field=models.TextField(default=b'', blank=True), + preserve_default=True, + ), + ]
--- a/news/models.py Fri Nov 20 23:07:37 2015 -0600 +++ b/news/models.py Sat Nov 21 14:53:29 2015 -0600 @@ -36,7 +36,7 @@ title = models.CharField(max_length=255) submitter = models.ForeignKey(User) category = models.ForeignKey(Category) - short_text = models.TextField() + short_text = models.TextField(default='', blank=True) long_text = models.TextField(default='', blank=True) date_submitted = models.DateTimeField(db_index=True) allow_comments = models.BooleanField(default=True)
--- a/news/static/js/news_admin.js Fri Nov 20 23:07:37 2015 -0600 +++ b/news/static/js/news_admin.js Sat Nov 21 14:53:29 2015 -0600 @@ -1,3 +1,5 @@ django.jQuery(document).ready(function() { - django.jQuery('#id_meta_description').addClass('mceNoEditor'); + django.jQuery('#id_meta_description').addClass('mceNoEditor'); + django.jQuery('#id_short_markup').addClass('mceNoEditor'); + django.jQuery('#id_long_markup').addClass('mceNoEditor'); });