68 lines
2.4 KiB
Python
Executable File
68 lines
2.4 KiB
Python
Executable File
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
from .models import CustomUser, LottoDraw, LottoRecommendation, NewsArticle, UserProfile, Diary
|
|
|
|
# ✅ 사용자 정의 관리자
|
|
class CustomUserAdmin(UserAdmin):
|
|
model = CustomUser
|
|
|
|
# 사용자 수정 페이지 필드
|
|
fieldsets = UserAdmin.fieldsets + (
|
|
('추가 정보', {
|
|
'fields': ('nickname', 'birthdate', 'email_verified', 'character_image', 'skin_image'),
|
|
}),
|
|
)
|
|
|
|
# 사용자 추가 페이지 필드
|
|
add_fieldsets = (
|
|
(None, {
|
|
'classes': ('wide',),
|
|
'fields': ('username', 'nickname', 'email', 'birthdate', 'password1', 'password2'),
|
|
}),
|
|
)
|
|
|
|
# 사용자 리스트 컬럼
|
|
list_display = ['username', 'nickname', 'email', 'is_staff', 'is_superuser']
|
|
|
|
admin.site.register(CustomUser, CustomUserAdmin)
|
|
|
|
# ✅ 로또 당첨 정보 관리자
|
|
@admin.register(LottoDraw)
|
|
class LottoDrawAdmin(admin.ModelAdmin):
|
|
list_display = ("draw_no", "number_1", "number_2", "number_3", "number_4", "number_5", "number_6", "bonus", "first_winners", "first_prize")
|
|
search_fields = ("draw_no",)
|
|
ordering = ("-draw_no",)
|
|
|
|
# ✅ 추천 번호 관리자
|
|
@admin.register(LottoRecommendation)
|
|
class LottoRecommendationAdmin(admin.ModelAdmin):
|
|
list_display = ("id", "method", "numbers", "created_at")
|
|
list_filter = ("method", "created_at")
|
|
ordering = ("-created_at",)
|
|
|
|
# ✅ 뉴스 기사 관리자
|
|
@admin.register(NewsArticle)
|
|
class NewsArticleAdmin(admin.ModelAdmin):
|
|
list_display = ("title", "link", "pub_date")
|
|
search_fields = ("title", "link")
|
|
ordering = ("-pub_date",)
|
|
|
|
@admin.register(UserProfile)
|
|
class UserProfileAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'mbti', 'nickname', 'mood_baseline', 'preferred_time')
|
|
search_fields = ('user__username', 'mbti', 'nickname')
|
|
list_filter = ('mbti', 'preferred_time')
|
|
ordering = ('user__username',)
|
|
|
|
@admin.register(Diary)
|
|
class DiaryAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'date', 'mood', 'weather', 'created_at')
|
|
search_fields = ('user__username', 'keywords', 'diary_text')
|
|
list_filter = ('mood', 'weather', 'date')
|
|
ordering = ('-date',)
|
|
|
|
# ✅ 관리자 사이트 커스터마이징
|
|
admin.site.site_header = "MyWorld 관리자"
|
|
admin.site.site_title = "MyWorld Admin"
|
|
admin.site.index_title = "관리자 패널"
|