0.5.2 documentation
This commit is contained in:
130
DocsApp/admin.py
130
DocsApp/admin.py
@@ -1,3 +1,131 @@
|
||||
from django.contrib import admin
|
||||
from sets.admin import *
|
||||
from .models import *
|
||||
from BaseModels.admin_utils import Admin_BaseIconModel
|
||||
from super_inlines.admin import SuperInlineModelAdmin, SuperModelAdmin
|
||||
from django.utils.translation import gettext as _
|
||||
from django import forms
|
||||
from django.utils.text import slugify
|
||||
|
||||
# Register your models here.
|
||||
|
||||
|
||||
class DocArtForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = DocArt
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DocArtForm, self).__init__(*args, **kwargs)
|
||||
self.fields['parent'].queryset = DocArt.objects.exclude(id__exact=self.instance.id)
|
||||
|
||||
|
||||
class Admin_DocArt(SuperModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||
form = DocArtForm
|
||||
|
||||
def show_versions(self, obj):
|
||||
versions = obj.versions.filter(enable=True).values_list('name', flat=True)
|
||||
if versions:
|
||||
return ' - '.join(versions)
|
||||
return '-'
|
||||
show_versions.short_description = _('Версии')
|
||||
|
||||
|
||||
fieldsets = [
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': (
|
||||
'name', 'url',
|
||||
'enable',
|
||||
'parent',
|
||||
'versions',
|
||||
'order',
|
||||
# 'title',
|
||||
# 'description',
|
||||
'text',
|
||||
# 'picture',
|
||||
|
||||
)
|
||||
}),
|
||||
# ('SEO', {
|
||||
# 'classes': ['wide', 'collapse'],
|
||||
# 'fields': (
|
||||
# 'seo_title', 'seo_description', 'seo_keywords', 'seo_text',
|
||||
# )
|
||||
# }),
|
||||
]
|
||||
|
||||
|
||||
list_display = [
|
||||
'id', 'enable',
|
||||
'name', 'url',
|
||||
'show_versions',
|
||||
'order', 'modifiedDT', 'createDT'
|
||||
]
|
||||
|
||||
# ordering = ['section', 'parent_service', 'order']
|
||||
|
||||
prepopulated_fields = {"url": ("name_en",)}
|
||||
|
||||
list_display_links = ['id', 'name']
|
||||
list_editable = ['enable', 'order']
|
||||
|
||||
filter_horizontal = ['versions']
|
||||
|
||||
list_filter = [
|
||||
# 'section', 'parent_service',
|
||||
'modifiedDT', 'createDT',
|
||||
]
|
||||
search_fields = ['name', 'title']
|
||||
# filter_horizontal = ['options']
|
||||
|
||||
# inlines = [Admin_StackedInline_Block]
|
||||
|
||||
|
||||
admin.site.register(DocArt, Admin_DocArt)
|
||||
|
||||
|
||||
class Admin_DocVersion(Admin_BaseIconModel):
|
||||
|
||||
fieldsets = [
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': (
|
||||
'name', 'url', 'enable', 'order',
|
||||
)
|
||||
}),
|
||||
# ('SEO', {
|
||||
# 'classes': ['wide', 'collapse'],
|
||||
# 'fields': (
|
||||
# 'seo_title', 'seo_description', 'seo_keywords', 'seo_text',
|
||||
# )
|
||||
# }),
|
||||
]
|
||||
|
||||
|
||||
list_display = [
|
||||
'id', 'enable',
|
||||
'name', 'url',
|
||||
# 'title',
|
||||
'order', 'modifiedDT', 'createDT'
|
||||
]
|
||||
|
||||
|
||||
|
||||
# ordering = ['section', 'parent_service', 'order']
|
||||
|
||||
# prepopulated_fields = {"url": ("name",)}
|
||||
|
||||
list_display_links = ['id', 'name']
|
||||
list_editable = ['enable', 'order']
|
||||
|
||||
list_filter = [
|
||||
# 'section', 'parent_service',
|
||||
'modifiedDT', 'createDT',
|
||||
]
|
||||
search_fields = ['name']
|
||||
# filter_horizontal = ['options']
|
||||
|
||||
# inlines = [Admin_StackedInline_Block]
|
||||
|
||||
|
||||
admin.site.register(DocVersion, Admin_DocVersion)
|
||||
Reference in New Issue
Block a user