inital commit
This commit is contained in:
50
accounts/admin.py
Normal file
50
accounts/admin.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
|
||||
|
||||
from .models import CustomerProfile, User, VendorProfile
|
||||
|
||||
|
||||
@admin.register(User)
|
||||
class UserAdmin(DjangoUserAdmin):
|
||||
ordering = ("email",)
|
||||
list_display = ("email", "first_name", "last_name", "is_vendor", "is_customer", "is_staff")
|
||||
search_fields = ("email", "first_name", "last_name", "phone_number")
|
||||
list_filter = ("is_vendor", "is_customer", "is_staff", "is_superuser", "is_active")
|
||||
|
||||
fieldsets = (
|
||||
(None, {"fields": ("email", "password")}),
|
||||
("Personal info", {"fields": ("first_name", "last_name", "phone_number")}),
|
||||
(
|
||||
"Roles",
|
||||
{"fields": ("is_vendor", "is_customer")},
|
||||
),
|
||||
(
|
||||
"Permissions",
|
||||
{"fields": ("is_active", "is_staff", "is_superuser", "groups", "user_permissions")},
|
||||
),
|
||||
("Important dates", {"fields": ("last_login", "date_joined")}),
|
||||
)
|
||||
add_fieldsets = (
|
||||
(
|
||||
None,
|
||||
{
|
||||
"classes": ("wide",),
|
||||
"fields": ("email", "password1", "password2", "is_vendor", "is_customer"),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(VendorProfile)
|
||||
class VendorProfileAdmin(admin.ModelAdmin):
|
||||
list_display = ("business_name", "user", "slug", "city", "country", "updated_at")
|
||||
search_fields = ("business_name", "user__email", "contact_email")
|
||||
list_filter = ("country", "state")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
|
||||
|
||||
@admin.register(CustomerProfile)
|
||||
class CustomerProfileAdmin(admin.ModelAdmin):
|
||||
list_display = ("user", "preferred_contact_method", "updated_at")
|
||||
search_fields = ("user__email", "emergency_contact_name")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
Reference in New Issue
Block a user