157 lines
4.3 KiB
Python
157 lines
4.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from django.contrib import admin
|
|
from django.utils.translation import gettext_lazy as _
|
|
from ArticlesApp.models import ArticleModel, UserPageModel
|
|
from sets.admin import *
|
|
|
|
|
|
# class Admin_ArticlesPageSets(Admin_BaseIconModel):
|
|
#
|
|
# fieldsets = (
|
|
# (None, {
|
|
# 'classes': ['wide'],
|
|
# 'fields': (
|
|
# 'name', 'url', 'description', 'picture'
|
|
# )
|
|
#
|
|
#
|
|
# }),
|
|
# ('Управление отображением страницы', {
|
|
# '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'),
|
|
)
|
|
}),
|
|
(_('Статья'), {
|
|
'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'),
|
|
)
|
|
}),
|
|
(_('Статья'), {
|
|
'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', 'contacts'):
|
|
return False
|
|
|
|
return True
|
|
|
|
admin.site.register(UserPageModel,Admin_UserPage) |