robosats/api/admin.py

36 lines
1.1 KiB
Python
Raw Normal View History

2022-01-01 22:13:27 +00:00
from django.contrib import admin
2022-01-04 15:58:10 +00:00
from django.db import models
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import UserAdmin
from .models import Order, Profile
2022-01-01 22:13:27 +00:00
2022-01-04 15:58:10 +00:00
admin.site.unregister(Group)
admin.site.unregister(User)
class ProfileInline(admin.StackedInline):
model = Profile
can_delete = False
fields = ('avatar_tag',)
readonly_fields = ['avatar_tag']
# extended users with avatars
@admin.register(User)
class EUserAdmin(UserAdmin):
inlines = [ProfileInline]
list_display = ('avatar_tag',) + UserAdmin.list_display
list_display_links = ['username']
def avatar_tag(self, obj):
return obj.profile.avatar_tag()
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
list_display = ('id','type','maker','taker','status','amount','currency','created_at','expires_at')
list_display_links = ('maker','taker')
pass
@admin.register(Profile)
class UserProfileAdmin(admin.ModelAdmin):
2022-01-04 15:58:10 +00:00
list_display = ('avatar_tag','user','id','total_ratings','avg_rating','num_disputes','lost_disputes')
list_display_links =['user']
readonly_fields = ['avatar_tag']
pass