Skip to content

Commit

Permalink
update admin for account module
Browse files Browse the repository at this point in the history
  • Loading branch information
muhuchah committed Jun 14, 2024
1 parent 63472d5 commit 818fff7
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions Karoo_BackEnd/Karoo_BackEnd/account_module/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.contrib import admin
from .models import User, DiscountCode, Address
# Register your models here.
from .models import User, DiscountCode, Address, City, Province

class AdminUser(admin.ModelAdmin):

class AdminUser(admin.ModelAdmin):
list_display = [ 'email', 'full_name','is_active', 'phone_number']
list_filter = ['is_staff','is_active' ]

Expand All @@ -13,11 +12,33 @@ class AdminDiscountCode(admin.ModelAdmin):
list_filter = ['discount_percent']


class AdminAddress(admin.ModelAdmin):
list_display = ['user','province','city']
list_filter = ['city']
class CityInline(admin.TabularInline):
model = City
extra = 1


class ProvinceAdmin(admin.ModelAdmin):
list_display = ('name',)
search_fields = ('name',)
ordering = ('name',)
inlines = [CityInline]


class CityAdmin(admin.ModelAdmin):
list_display = ('name', 'province')
search_fields = ('name', 'province__name')
list_filter = ('province',)
ordering = ('name',)


class AddressAdmin(admin.ModelAdmin):
list_display = ('user', 'province', 'city')
search_fields = ('user__username', 'province__name', 'city__name')
list_filter = ('province', 'city')
ordering = ('user',)

admin.site.register(User, AdminUser)
admin.site.register(DiscountCode, AdminDiscountCode)
admin.site.register(Address, AdminAddress)
#admin.site.register(DiscountCode, AdminDiscountCode)
admin.site.register(Address, AddressAdmin)
admin.site.register(Province, ProvinceAdmin)
admin.site.register(City, CityAdmin)

0 comments on commit 818fff7

Please sign in to comment.