# HG changeset patch # User Brian Neal # Date 1448139209 21600 # Node ID 8386a8ebcbc7958a47fe60578bff679277e70962 # Parent e2c3d7ecfa306bde187aaec235351d85a8c546e9 WIP News v2.0 admin changes. diff -r e2c3d7ecfa30 -r 8386a8ebcbc7 news/admin.py --- 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) diff -r e2c3d7ecfa30 -r 8386a8ebcbc7 news/migrations/0005_auto_20151121_1445.py --- /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, + ), + ] diff -r e2c3d7ecfa30 -r 8386a8ebcbc7 news/models.py --- 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) diff -r e2c3d7ecfa30 -r 8386a8ebcbc7 news/static/js/news_admin.js --- 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'); });