robosats/api/admin.py

50 lines
2.2 KiB
Python
Raw Normal View History

2022-01-01 22:13:27 +00:00
from django.contrib import admin
2022-01-05 11:20:08 +00:00
from django_admin_relation_links import AdminChangeLinksMixin
2022-01-04 15:58:10 +00:00
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import UserAdmin
from .models import Order, LNPayment, Profile, MarketTick
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','id','username','last_login','date_joined','is_staff')
list_display_links = ('id','username')
2022-01-04 15:58:10 +00:00
def avatar_tag(self, obj):
return obj.profile.avatar_tag()
@admin.register(Order)
2022-01-05 11:20:08 +00:00
class OrderAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ('id','type','maker_link','taker_link','status','amount','currency','t0_satoshis','is_disputed','is_fiat_sent','created_at','expires_at', 'buyer_invoice_link','maker_bond_link','taker_bond_link','trade_escrow_link')
2022-01-05 11:20:08 +00:00
list_display_links = ('id','type')
change_links = ('maker','taker','buyer_invoice','maker_bond','taker_invoice','taker_bond','trade_escrow')
list_filter = ('is_disputed','is_fiat_sent','type','currency','status')
@admin.register(LNPayment)
2022-01-05 11:20:08 +00:00
class LNPaymentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
2022-01-06 20:33:40 +00:00
list_display = ('id','concept','status','num_satoshis','type','invoice','expires_at','sender_link','receiver_link')
2022-01-05 11:20:08 +00:00
list_display_links = ('id','concept')
change_links = ('sender','receiver')
list_filter = ('type','concept','status')
@admin.register(Profile)
2022-01-05 11:20:08 +00:00
class UserProfileAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
list_display = ('avatar_tag','id','user_link','total_ratings','avg_rating','num_disputes','lost_disputes')
list_display_links = ('avatar_tag','id')
change_links =['user']
readonly_fields = ['avatar_tag']
@admin.register(MarketTick)
class MarketTickAdmin(admin.ModelAdmin):
list_display = ('timestamp','price','volume','premium','currency','fee')
readonly_fields = ('timestamp','price','volume','premium','currency','fee')
list_filter = ['currency']