Initial commit: Django backend with Campaign, ContactUs, and Composition APIs
This commit is contained in:
72
api/admin.py
Normal file
72
api/admin.py
Normal file
@@ -0,0 +1,72 @@
|
||||
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 = 'فعال'
|
||||
Reference in New Issue
Block a user