# -*- coding: utf-8 -*-
from django.contrib import admin
from django import forms

from opps.core.models import Post, PostImage

from redactor.widgets import RedactorEditor



class PostImageInline(admin.TabularInline):
    model = PostImage
    fk_name = 'post'
    raw_id_fields = ['image']
    actions = None
    extra = 1
    fieldsets = [(None, {'fields': ('image', 'order')})]


class PostAdminForm(forms.ModelForm):
    class Meta:
        model = Post
        widgets = {'content': RedactorEditor()}


class PostAdmin(admin.ModelAdmin):
    form = PostAdminForm
    prepopulated_fields = {"slug": ("title",)}
    inlines = [PostImageInline]

    fieldsets = (
            (None, {'fields': ('title', 'short_title', 'headline', 'channel',
                'content',)}),
            (None, {'fields': ('main_image', 'credit', 'slug',)})
    )

    def save_model(self, request, obj, form, change):
        if not obj.user:
            obj.user = request.user
        obj.save()
admin.site.register(Post, PostAdmin)

@@ -120,17 +120,29 @@
 ostImage
+, PostSource
 %0A
-
 %0Afrom re
@@ -389,16 +389,271 @@
 r')%7D)%5D%0A%0A
+class PostSourceInline(admin.TabularInline):%0A    model = PostSource%0A    fk_name = 'post'%0A    raw_id_fields = %5B'source'%5D%0A    actions = None%0A    extra = 1%0A    fieldsets = %5B(None, %7B%0A        'classes': ('collapse',),%0A        'fields': ('source', 'order')%7D)%5D%0A%0A
 %0Aclass P
@@ -907,16 +907,34 @@
 geInline
+, PostSourceInline
 %5D%0A%0A    f
@@ -1055,16 +1055,16 @@
 t',)%7D),%0A
+
         
@@ -1103,18 +1103,8 @@
 ge',
- 'credit',
  'sl

Create post source inline (admin Tabular Inline) on core post