Scott Nixon avatar Scott Nixon committed 9903c64

Updated added wymeditor to admin forms. updated model with selling field.

Comments (0)

Files changed (3)

 from django.contrib.sites.models import Site
 from django.contrib.sites.managers import CurrentSiteManager
 from models import Courses, Lessons, Media
+from forms import CoursesAdminModelForm, LessonsAdminModelForm
 
 class MediaInline(admin.TabularInline):
 	model = Media
 	extra = 2
 
 class CoursesAdmin(admin.ModelAdmin):		
-	fields = ['title', 'discussion', 'summary', 'is_published', 'sites']
+	fields = ['title', 'discussion', 'summary', 'selling', 'is_published', 'sites']
 	list_display = ['title', 'is_published',]
 	list_filter = ['createdate']
 	date_hierarchy = 'createdate'
 	search_fields = ['title']
+	form = CoursesAdminModelForm
 
 class LessonsAdmin(admin.ModelAdmin):		
 	fields = ['course', 'title', 'summary', 'content', 'is_published']
 	date_hierarchy = 'createdate'
 	search_fields = ['title']
         inlines = [MediaInline]
+	form = LessonsAdminModelForm
         
 class MediaAdmin(admin.ModelAdmin):		
 	fields = ['lesson', 'title', 'media', 'type']
+from django import forms
+from django.db.models import get_model
+from widgets import WYMEditor
+
+
+class LessonsAdminModelForm(forms.ModelForm):
+    summary = forms.CharField(widget=WYMEditor())
+    content = forms.CharField(widget=WYMEditor())
+
+    class Meta:
+        model = get_model('courses', 'lessons')
+
+class CoursesAdminModelForm(forms.ModelForm):
+    summary = forms.CharField(widget=WYMEditor())
+    selling = forms.CharField(widget=WYMEditor())
+    
+    class Meta:
+        model = get_model('courses', 'courses')
+        

migrations/0004_auto__add_field_courses_selling.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'Courses.selling'
+        db.add_column('courses_courses', 'selling', self.gf('django.db.models.fields.TextField')(default=datetime.date(2010, 8, 24)), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Courses.selling'
+        db.delete_column('courses_courses', 'selling')
+
+
+    models = {
+        'courses.courses': {
+            'Meta': {'object_name': 'Courses'},
+            'createdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+            'discussion': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'selling': ('django.db.models.fields.TextField', [], {}),
+            'sites': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sites.Site']", 'symmetrical': 'False'}),
+            'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': 'None', 'unique_with': '()', 'db_index': 'True'}),
+            'summary': ('django.db.models.fields.TextField', [], {}),
+            'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'updatedate': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+        },
+        'courses.lessons': {
+            'Meta': {'object_name': 'Lessons'},
+            'content': ('django.db.models.fields.TextField', [], {}),
+            'course': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['courses.Courses']"}),
+            'createdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'slug': ('autoslug.fields.AutoSlugField', [], {'unique': 'True', 'max_length': '50', 'populate_from': 'None', 'unique_with': '()', 'db_index': 'True'}),
+            'summary': ('django.db.models.fields.TextField', [], {}),
+            'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '150'}),
+            'updatedate': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+        },
+        'courses.media': {
+            'Meta': {'object_name': 'Media'},
+            'createdate': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'lesson': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['courses.Lessons']"}),
+            'media': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'type': ('django.db.models.fields.CharField', [], {'default': '1', 'max_length': '2'}),
+            'updatedate': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+        },
+        'sites.site': {
+            'Meta': {'object_name': 'Site', 'db_table': "'django_site'"},
+            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['courses']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.