Админка
This commit is contained in:
1 parent
7439a51d6c
commit
14ff702b4d
9 files changed
+84
-52
No files matched your search
+16
-9
@@ -4,6 +4,7 @@ from django.utils.safestring import mark_safe
|
||||
from .models import *
|
||||
|
||||
class GalleryInline(admin.TabularInline):
|
||||
save_on_top = True
|
||||
model = Gallery
|
||||
fields = ( 'img', 'get_html_photo')
|
||||
readonly_fields=('get_html_photo',)
|
||||
@@ -17,11 +18,14 @@ class GalleryInline(admin.TabularInline):
|
||||
get_html_photo.short_description="Превью изображения"
|
||||
|
||||
class NewsAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'author', 'text', 'cdate', 'link', 'get_html_photo')
|
||||
save_on_top = True
|
||||
list_display = ('title', 'get_html_photo', 'link', 'names', 'cdate')
|
||||
readonly_fields=('get_html_photo',)
|
||||
fields=('title', 'text', 'cdate', ('get_html_photo', 'link',))
|
||||
list_editable = ('link', 'cdate')
|
||||
list_filter = ('cdate',)
|
||||
ordering=('-cdate',)
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
if (request.user.username != 'admin') :
|
||||
obj.author = request.user
|
||||
@@ -33,8 +37,6 @@ class NewsAdmin(admin.ModelAdmin):
|
||||
if object.link:
|
||||
return mark_safe(f"<img src='{object.link.url}' width=50>")
|
||||
|
||||
|
||||
|
||||
get_html_photo.short_description="Превью изображения"
|
||||
|
||||
inlines = [GalleryInline]
|
||||
@@ -42,7 +44,7 @@ class NewsAdmin(admin.ModelAdmin):
|
||||
|
||||
|
||||
class CarouselsAdmin(admin.ModelAdmin):
|
||||
list_display=('title', 'cdate', 'enddate', 'get_html_photo', 'link','published', 'sender', 'order')
|
||||
list_display=('title', 'get_html_photo', 'link', 'cdate', 'enddate', 'published', 'sender', 'order')
|
||||
readonly_fields=('get_html_photo',)
|
||||
list_editable=('link','published', 'cdate', 'enddate', 'sender', 'order')
|
||||
list_filter=('cdate', 'enddate','published')
|
||||
@@ -75,21 +77,25 @@ class BaseSenderAdmin(admin.ModelAdmin):
|
||||
get_html_photo.short_description="Изображение"
|
||||
|
||||
class ScoreNewsAdmin(admin.ModelAdmin):
|
||||
list_display = ('author', 'news', 'cdate', 'score')
|
||||
list_display = ('names', 'news', 'cdate', 'score')
|
||||
readonly_fields=('names', 'news', 'cdate', 'score')
|
||||
list_filter = ('author', 'cdate', 'score')
|
||||
|
||||
|
||||
class CommentNewsAdmin(admin.ModelAdmin):
|
||||
list_display = ('author', 'news', 'text', 'cdate')
|
||||
list_filter = ('author', 'cdate')
|
||||
list_display = ('names','author', 'news', 'text', 'cdate')
|
||||
readonly_fields=('names','author', 'news', 'cdate')
|
||||
list_filter = ('author','cdate',)
|
||||
|
||||
class LinksAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'link')
|
||||
list_display_links = ('link',)
|
||||
|
||||
class BirthdayImageAdmin(admin.ModelAdmin):
|
||||
list_display = ('get_html_photo',)
|
||||
readonly_fields=('get_html_photo',)
|
||||
list_display = ('get_html_photo', 'img')
|
||||
readonly_fields=('get_html_photo',)
|
||||
list_editable=('img',)
|
||||
fields=(('get_html_photo', 'img'),)
|
||||
|
||||
def get_html_photo(self, object):
|
||||
if object.img:
|
||||
@@ -103,6 +109,7 @@ class BirthdayTextAdmin(admin.ModelAdmin):
|
||||
class ScreensaverAdmin(admin.ModelAdmin):
|
||||
list_display = ('get_html_photo', 'img', 'cdate', 'enddate')
|
||||
list_editable=('img', 'cdate', 'enddate')
|
||||
fields=(('get_html_photo', 'img'), ('cdate', 'enddate'))
|
||||
readonly_fields=('get_html_photo',)
|
||||
|
||||
def get_html_photo(self, object):
|
||||
|
||||
Reference in new issue
Block a user