0.5.0
ArticlesApp
This commit is contained in:
159
ArticlesApp/admin.py
Normal file
159
ArticlesApp/admin.py
Normal file
@@ -0,0 +1,159 @@
|
||||
## -*- coding: utf8 -*-
|
||||
|
||||
__author__ = 'SDE'
|
||||
from django.contrib import admin
|
||||
|
||||
from ArticlesApp.models import ArticleModel, UserPageModel
|
||||
from sets.admin import *
|
||||
|
||||
|
||||
# class Admin_ArticlesPageSets(Admin_BaseIconModel):
|
||||
#
|
||||
# fieldsets = (
|
||||
# (None, {
|
||||
# 'classes': ['wide'],
|
||||
# 'fields': (
|
||||
# 'name', 'url', 'description', 'picture'
|
||||
# )
|
||||
#
|
||||
#
|
||||
# }),
|
||||
# (u'Управление отображением страницы', {
|
||||
# 'classes': ['wide'],
|
||||
# 'fields': (
|
||||
# # ('serviceBlockStateShow'),
|
||||
# # ('articlesCountInBlock'),
|
||||
# # ('advicesCountInBlock'),
|
||||
# )
|
||||
# }),
|
||||
#
|
||||
# ('SEO', {
|
||||
# 'classes': ['wide', 'collapse'],
|
||||
# 'fields': ('seo_title', 'seo_description','seo_keywords', 'seo_text')
|
||||
# }),
|
||||
#
|
||||
# )
|
||||
#
|
||||
# prepopulated_fields = {"url": ("name",)}
|
||||
# list_display = ('name', 'url', 'seo_title', 'createDT')
|
||||
# # list_editable = ('dish_price', 'allowForDelivery', 'dish_maxDiscount','dish_rating',
|
||||
# # 'dish_enabled')
|
||||
# # filter_horizontal = ['service_works',]
|
||||
# # date_hierarchy = 'createDT'
|
||||
# # list_filter = ('device_name', 'vendor',)
|
||||
# list_display_links = ('name',)
|
||||
# save_on_top = True
|
||||
#
|
||||
# def has_add_permission(self, request):
|
||||
# return not ArticlesPageSets.objects.all().count() > 0
|
||||
#
|
||||
# def has_delete_permission(self, request, obj=None):
|
||||
# if not request.user.is_superuser:
|
||||
# return False
|
||||
# else:
|
||||
# return True
|
||||
#
|
||||
# admin.site.register(ArticlesPageSets,Admin_ArticlesPageSets)
|
||||
|
||||
|
||||
|
||||
|
||||
class Admin_Article(Admin_Trans_BaseModelViewPage):
|
||||
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': (('name'),
|
||||
('url'),
|
||||
# 'pub_DT',
|
||||
'picture',
|
||||
# ('devices'),
|
||||
)
|
||||
}),
|
||||
(u'Статья', {
|
||||
'classes': ['wide'],
|
||||
'fields': (
|
||||
'description', 'text',
|
||||
)
|
||||
}),
|
||||
|
||||
('SEO', {
|
||||
'classes': ['wide', 'collapse'],
|
||||
'fields': ('seo_title', 'seo_description','seo_keywords')
|
||||
}),
|
||||
|
||||
)
|
||||
|
||||
prepopulated_fields = {"url": ("name",)}
|
||||
list_display = (
|
||||
# 'image_thumb',
|
||||
'name', 'url', 'order', 'createDT')
|
||||
list_editable = ('order',) # 'allowForDelivery', 'dish_maxDiscount','dish_rating',
|
||||
# 'dish_enabled')
|
||||
# filter_horizontal = ['sites']
|
||||
date_hierarchy = 'createDT'
|
||||
list_filter = ('enable', 'createDT')
|
||||
list_display_links = (
|
||||
'name',
|
||||
# 'image_thumb',
|
||||
)
|
||||
save_on_top = True
|
||||
|
||||
admin.site.register(ArticleModel, Admin_Article)
|
||||
|
||||
# class Admin_ArticleSliders(admin.TabularInline):
|
||||
# model = ArticleModel.SliderSets.through
|
||||
|
||||
|
||||
class Admin_UserPage(Admin_Trans_BaseModelViewPage):
|
||||
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'classes': ['wide'],
|
||||
'fields': (('name'),
|
||||
('url'),
|
||||
# 'pub_DT',
|
||||
# ('devices'),
|
||||
)
|
||||
}),
|
||||
(u'Статья', {
|
||||
'classes': ['wide'],
|
||||
'fields': ('picture', 'description', 'text')
|
||||
}),
|
||||
|
||||
('SEO', {
|
||||
'classes': ['wide', 'collapse'],
|
||||
'fields': ('seo_title', 'seo_description','seo_keywords')
|
||||
}),
|
||||
|
||||
)
|
||||
|
||||
prepopulated_fields = {"url": ("name",)}
|
||||
list_display = (
|
||||
# 'image_thumb',
|
||||
'name', 'url', 'order', 'seo_title', 'createDT')
|
||||
list_editable = ('order', ) # 'allowForDelivery', 'dish_maxDiscount','dish_rating',
|
||||
# 'dish_enabled')
|
||||
# filter_horizontal = ['sites']
|
||||
date_hierarchy = 'createDT'
|
||||
list_filter = ('enable', 'createDT')
|
||||
list_display_links = (
|
||||
'name',
|
||||
# 'image_thumb',
|
||||
)
|
||||
save_on_top = True
|
||||
|
||||
actions = ['create_copy']
|
||||
|
||||
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
if request.user.is_superuser:
|
||||
return True
|
||||
|
||||
if obj and obj.url in ('for-partners', 'dealers', 'about-truenergy', 'contacts'):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
admin.site.register(UserPageModel,Admin_UserPage)
|
||||
Reference in New Issue
Block a user