73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
from django.contrib import admin
|
|
from .models import ContactUs, Composition, Campaign
|
|
|
|
|
|
@admin.register(ContactUs)
|
|
class ContactUsAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'email_or_phone', 'category', 'created_at']
|
|
list_filter = ['category', 'created_at']
|
|
search_fields = ['name', 'email_or_phone', 'description']
|
|
readonly_fields = ['created_at', 'updated_at']
|
|
date_hierarchy = 'created_at'
|
|
|
|
fieldsets = (
|
|
('اطلاعات تماس', {
|
|
'fields': ('name', 'email_or_phone', 'category')
|
|
}),
|
|
('پیام', {
|
|
'fields': ('description',)
|
|
}),
|
|
('اطلاعات زمانی', {
|
|
'fields': ('created_at', 'updated_at'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
)
|
|
|
|
|
|
@admin.register(Composition)
|
|
class CompositionAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'created_at']
|
|
search_fields = ['name', 'description']
|
|
readonly_fields = ['created_at', 'updated_at']
|
|
date_hierarchy = 'created_at'
|
|
|
|
fieldsets = (
|
|
('اطلاعات ترکیب', {
|
|
'fields': ('name', 'description', 'image')
|
|
}),
|
|
('اطلاعات زمانی', {
|
|
'fields': ('created_at', 'updated_at'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
)
|
|
|
|
|
|
@admin.register(Campaign)
|
|
class CampaignAdmin(admin.ModelAdmin):
|
|
list_display = ['name', 'start_time', 'end_time', 'is_active', 'created_at']
|
|
list_filter = ['start_time', 'end_time', 'created_at']
|
|
search_fields = ['name', 'description']
|
|
readonly_fields = ['created_at', 'updated_at', 'is_active']
|
|
date_hierarchy = 'start_time'
|
|
|
|
fieldsets = (
|
|
('اطلاعات کمپین', {
|
|
'fields': ('name', 'description', 'image')
|
|
}),
|
|
('زمانبندی', {
|
|
'fields': ('start_time', 'end_time')
|
|
}),
|
|
('وضعیت', {
|
|
'fields': ('is_active',)
|
|
}),
|
|
('اطلاعات زمانی', {
|
|
'fields': ('created_at', 'updated_at'),
|
|
'classes': ('collapse',)
|
|
}),
|
|
)
|
|
|
|
def is_active(self, obj):
|
|
return obj.is_active()
|
|
is_active.boolean = True
|
|
is_active.short_description = 'فعال'
|