0.0.5 init, rm db
This commit is contained in:
@@ -1,3 +1,66 @@
|
||||
from sets.admin import *
|
||||
from .models import *
|
||||
from django.contrib import admin
|
||||
from django.forms import widgets
|
||||
# from nested_inline.admin import NestedStackedInline, NestedTabularInline, NestedModelAdmin, NestedInline
|
||||
from super_inlines.admin import SuperInlineModelAdmin, SuperModelAdmin
|
||||
from GeneralApp.admin import Admin_StackedInline_Block
|
||||
|
||||
def sets_for_formfield_for_dbfield(field, db_field):
|
||||
if db_field.name == 'url' or db_field.name == 'name' or db_field.name == 'title' or db_field.name == 'name_plural':
|
||||
field.widget = widgets.TextInput(attrs={'style': 'width: 30%; height: 20px;'})
|
||||
if db_field.name == 'description':
|
||||
field.widget = widgets.Textarea(attrs={'style': 'width: 30%; height: 100px;'})
|
||||
return field
|
||||
|
||||
|
||||
|
||||
# class Admin_StaticPage(NestedModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||
class Admin_Section(SuperModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||
|
||||
|
||||
fieldsets = [
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': ('name',
|
||||
'url',
|
||||
'title', 'description', 'text',
|
||||
'picture',
|
||||
'order',
|
||||
)
|
||||
}),
|
||||
('SEO', {
|
||||
'classes': ['wide', 'collapse'],
|
||||
'fields': (
|
||||
'seo_title', 'seo_description', 'seo_keywords', 'seo_text',
|
||||
)
|
||||
}),
|
||||
]
|
||||
|
||||
|
||||
list_display = [
|
||||
'id',
|
||||
'name', 'url', 'title',
|
||||
'order', 'modifiedDT', 'createDT'
|
||||
]
|
||||
|
||||
list_display_links = ['id']
|
||||
list_editable = ['order']
|
||||
|
||||
list_filter = ['modifiedDT', 'createDT']
|
||||
search_fields = ['name', 'title']
|
||||
# filter_horizontal = ['options']
|
||||
|
||||
inlines = [Admin_StackedInline_Block]
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
if request.user.is_superuser:
|
||||
return True
|
||||
|
||||
if obj.url in ('main', 'spec_technics', 'works'):
|
||||
return False
|
||||
|
||||
admin.site.register(Section,Admin_Section)
|
||||
|
||||
|
||||
|
||||
# Register your models here.
|
||||
|
||||
Reference in New Issue
Block a user