3
from django.contrib import admin
4
from django.utils.html import format_html
6
from mainapp.models import News, Courses, Lesson, CourseTeachers
16
class NewsAdmin(admin.ModelAdmin):
17
list_display = ('pk', 'preambule', 'created_at', 'slug', 'deleted')
18
list_filter = ('created_at', 'updated_at', 'deleted')
19
search_fields = ('title', 'body', 'preambule')
21
actions = ['mark_deleted']
23
def mark_deleted(self, request, queryset):
24
queryset.update(deleted=True)
26
mark_deleted.short_description = 'Пометить как удалённые'
30
'<a href="http://127.0.0.1:8088/admin/mainapp/news/ {}/change/">{}</a>',
35
slug.short_description = 'Заголовок'
38
@admin.register(Courses)
39
class CoursesAdmin(admin.ModelAdmin):
40
list_display = ('pk', 'created_at', 'updated_at', 'slug', 'deleted',)
42
list_filter = ('created_at', 'updated_at', 'deleted')
43
search_fields = ('name', 'description', 'cost')
44
show_full_result_count = False
48
'<a href="http://127.0.0.1:8088/admin/mainapp/courses/ {}/change/">{}</a>',
53
slug.short_description = 'Название курса'
56
@admin.register(Lesson)
57
class LessonAdmin(admin.ModelAdmin):
58
list_display = ('title', 'course', 'num', 'created_at', 'updated_at', 'deleted')
60
list_filter = ('created_at', 'updated_at', 'deleted')
61
search_fields = ('title', 'description')
62
show_full_result_count = False
65
@admin.register(CourseTeachers)
66
class CourseTeachersAdmin(admin.ModelAdmin):
67
list_display = ('__str__', 'day_birth', 'deleted')
69
list_filter = ('name_first', 'name_second')
70
search_fields = ('name_first', 'name_second')
71
show_full_result_count = False