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
|
2022-06-07 22:14:56 +00:00
|
|
|
from api.models import OnchainPayment, Order, LNPayment, Profile, MarketTick, Currency
|
2022-01-01 22:13:27 +00:00
|
|
|
|
2022-01-04 15:58:10 +00:00
|
|
|
admin.site.unregister(Group)
|
|
|
|
admin.site.unregister(User)
|
|
|
|
|
2022-02-17 19:50:10 +00:00
|
|
|
|
2022-01-04 15:58:10 +00:00
|
|
|
class ProfileInline(admin.StackedInline):
|
|
|
|
model = Profile
|
2022-02-17 19:50:10 +00:00
|
|
|
can_delete = False
|
|
|
|
fields = ("avatar_tag", )
|
|
|
|
readonly_fields = ["avatar_tag"]
|
2022-03-18 21:21:13 +00:00
|
|
|
show_change_link = True
|
2022-02-17 19:50:10 +00:00
|
|
|
|
2022-01-04 15:58:10 +00:00
|
|
|
# extended users with avatars
|
|
|
|
@admin.register(User)
|
2022-03-18 21:21:13 +00:00
|
|
|
class EUserAdmin(AdminChangeLinksMixin, UserAdmin):
|
2022-01-04 15:58:10 +00:00
|
|
|
inlines = [ProfileInline]
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = (
|
|
|
|
"avatar_tag",
|
|
|
|
"id",
|
2022-03-18 21:21:13 +00:00
|
|
|
"profile_link",
|
2022-02-17 19:50:10 +00:00
|
|
|
"username",
|
|
|
|
"last_login",
|
|
|
|
"date_joined",
|
|
|
|
"is_staff",
|
|
|
|
)
|
|
|
|
list_display_links = ("id", "username")
|
2022-03-18 21:21:13 +00:00
|
|
|
change_links = (
|
|
|
|
"profile",
|
|
|
|
)
|
2022-02-17 19:50:10 +00:00
|
|
|
ordering = ("-id", )
|
|
|
|
|
2022-01-04 15:58:10 +00:00
|
|
|
def avatar_tag(self, obj):
|
|
|
|
return obj.profile.avatar_tag()
|
|
|
|
|
2022-01-18 16:57:55 +00:00
|
|
|
|
2022-01-04 13:47:37 +00:00
|
|
|
@admin.register(Order)
|
2022-01-05 11:20:08 +00:00
|
|
|
class OrderAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = (
|
|
|
|
"id",
|
|
|
|
"type",
|
|
|
|
"maker_link",
|
|
|
|
"taker_link",
|
|
|
|
"status",
|
2022-03-22 17:49:57 +00:00
|
|
|
"amt",
|
2022-02-17 19:50:10 +00:00
|
|
|
"currency_link",
|
|
|
|
"t0_satoshis",
|
|
|
|
"is_disputed",
|
|
|
|
"is_fiat_sent",
|
|
|
|
"created_at",
|
|
|
|
"expires_at",
|
2022-06-07 22:14:56 +00:00
|
|
|
"payout_tx_link",
|
2022-02-17 19:50:10 +00:00
|
|
|
"payout_link",
|
|
|
|
"maker_bond_link",
|
|
|
|
"taker_bond_link",
|
|
|
|
"trade_escrow_link",
|
|
|
|
)
|
|
|
|
list_display_links = ("id", "type")
|
|
|
|
change_links = (
|
|
|
|
"maker",
|
|
|
|
"taker",
|
|
|
|
"currency",
|
2022-06-07 22:14:56 +00:00
|
|
|
"payout_tx",
|
2022-02-17 19:50:10 +00:00
|
|
|
"payout",
|
|
|
|
"maker_bond",
|
|
|
|
"taker_bond",
|
|
|
|
"trade_escrow",
|
|
|
|
)
|
2022-06-29 11:26:55 +00:00
|
|
|
raw_id_fields = (
|
|
|
|
"maker",
|
|
|
|
"taker",
|
|
|
|
"payout_tx",
|
|
|
|
"payout",
|
|
|
|
"maker_bond",
|
|
|
|
"taker_bond",
|
|
|
|
"trade_escrow",
|
|
|
|
)
|
2022-06-20 17:56:08 +00:00
|
|
|
list_filter = ("is_disputed", "is_fiat_sent", "is_swap","type", "currency", "status")
|
2022-03-22 17:49:57 +00:00
|
|
|
search_fields = ["id","amount","min_amount","max_amount"]
|
|
|
|
|
|
|
|
def amt(self, obj):
|
|
|
|
if obj.has_range and obj.amount == None:
|
|
|
|
return str(float(obj.min_amount))+"-"+ str(float(obj.max_amount))
|
|
|
|
else:
|
|
|
|
return float(obj.amount)
|
2022-01-05 10:30:38 +00:00
|
|
|
|
|
|
|
@admin.register(LNPayment)
|
2022-01-05 11:20:08 +00:00
|
|
|
class LNPaymentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = (
|
|
|
|
"hash",
|
|
|
|
"concept",
|
|
|
|
"status",
|
|
|
|
"num_satoshis",
|
2022-03-20 23:32:25 +00:00
|
|
|
"fee",
|
2022-02-17 19:50:10 +00:00
|
|
|
"type",
|
|
|
|
"expires_at",
|
|
|
|
"expiry_height",
|
|
|
|
"sender_link",
|
|
|
|
"receiver_link",
|
|
|
|
"order_made_link",
|
|
|
|
"order_taken_link",
|
|
|
|
"order_escrow_link",
|
2022-06-19 06:09:21 +00:00
|
|
|
"order_paid_LN_link",
|
2022-02-17 19:50:10 +00:00
|
|
|
)
|
|
|
|
list_display_links = ("hash", "concept")
|
|
|
|
change_links = (
|
|
|
|
"sender",
|
|
|
|
"receiver",
|
|
|
|
"order_made",
|
|
|
|
"order_taken",
|
|
|
|
"order_escrow",
|
2022-06-19 06:09:21 +00:00
|
|
|
"order_paid_LN",
|
2022-02-17 19:50:10 +00:00
|
|
|
)
|
|
|
|
list_filter = ("type", "concept", "status")
|
|
|
|
ordering = ("-expires_at", )
|
2022-03-18 21:21:13 +00:00
|
|
|
search_fields = ["payment_hash","num_satoshis","sender__username","receiver__username","description"]
|
2022-02-17 19:50:10 +00:00
|
|
|
|
2022-06-07 22:14:56 +00:00
|
|
|
@admin.register(OnchainPayment)
|
|
|
|
class OnchainPaymentAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
|
|
|
list_display = (
|
|
|
|
"id",
|
|
|
|
"address",
|
|
|
|
"concept",
|
|
|
|
"status",
|
|
|
|
"num_satoshis",
|
|
|
|
"hash",
|
|
|
|
"swap_fee_rate",
|
|
|
|
"mining_fee_sats",
|
|
|
|
"balance_link",
|
2022-06-20 08:30:00 +00:00
|
|
|
"order_paid_TX_link",
|
2022-06-07 22:14:56 +00:00
|
|
|
)
|
|
|
|
change_links = (
|
|
|
|
"balance",
|
2022-06-20 08:30:00 +00:00
|
|
|
"order_paid_TX",
|
2022-06-07 22:14:56 +00:00
|
|
|
)
|
|
|
|
list_display_links = ("id","address", "concept")
|
|
|
|
list_filter = ("concept", "status")
|
|
|
|
search_fields = ["address","num_satoshis","receiver__username","txid"]
|
2022-01-04 13:47:37 +00:00
|
|
|
|
|
|
|
@admin.register(Profile)
|
2022-01-05 11:20:08 +00:00
|
|
|
class UserProfileAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = (
|
|
|
|
"avatar_tag",
|
|
|
|
"id",
|
|
|
|
"user_link",
|
2022-03-05 18:43:15 +00:00
|
|
|
"is_referred",
|
2022-02-24 13:01:17 +00:00
|
|
|
"telegram_enabled",
|
2022-02-17 19:50:10 +00:00
|
|
|
"total_contracts",
|
2022-03-07 21:46:52 +00:00
|
|
|
"pending_rewards",
|
|
|
|
"earned_rewards",
|
|
|
|
"claimed_rewards",
|
2022-02-17 19:50:10 +00:00
|
|
|
"platform_rating",
|
|
|
|
"total_ratings",
|
|
|
|
"avg_rating",
|
|
|
|
"num_disputes",
|
|
|
|
"lost_disputes",
|
|
|
|
)
|
2022-07-03 17:39:40 +00:00
|
|
|
raw_id_fields = (
|
|
|
|
"user",
|
|
|
|
"referred_by",
|
|
|
|
)
|
2022-03-21 12:13:57 +00:00
|
|
|
list_editable = ["pending_rewards", "earned_rewards"]
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display_links = ("avatar_tag", "id")
|
|
|
|
change_links = ["user"]
|
|
|
|
readonly_fields = ["avatar_tag"]
|
2022-03-18 21:21:13 +00:00
|
|
|
search_fields = ["user__username","id"]
|
2022-05-30 11:19:12 +00:00
|
|
|
readonly_fields = ("public_key", "encrypted_private_key")
|
2022-02-17 19:50:10 +00:00
|
|
|
|
2022-01-07 22:46:30 +00:00
|
|
|
|
2022-01-16 16:06:53 +00:00
|
|
|
@admin.register(Currency)
|
|
|
|
class CurrencieAdmin(admin.ModelAdmin):
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = ("id", "currency", "exchange_rate", "timestamp")
|
|
|
|
list_display_links = ("id", "currency")
|
|
|
|
readonly_fields = ("currency", "exchange_rate", "timestamp")
|
|
|
|
ordering = ("id", )
|
|
|
|
|
2022-01-07 22:46:30 +00:00
|
|
|
@admin.register(MarketTick)
|
|
|
|
class MarketTickAdmin(admin.ModelAdmin):
|
2022-02-17 19:50:10 +00:00
|
|
|
list_display = ("timestamp", "price", "volume", "premium", "currency",
|
|
|
|
"fee")
|
|
|
|
readonly_fields = ("timestamp", "price", "volume", "premium", "currency",
|
|
|
|
"fee")
|
|
|
|
list_filter = ["currency"]
|
|
|
|
ordering = ("-timestamp", )
|