2022-10-13 14:26:43 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
|
|
|
|
|
|
|
from .forms import CustomUserCreationForm
|
2022-12-12 07:20:20 +00:00
|
|
|
from .models import (
|
|
|
|
Account,
|
|
|
|
Callback,
|
|
|
|
Hook,
|
|
|
|
Plan,
|
|
|
|
Session,
|
|
|
|
Signal,
|
|
|
|
Strategy,
|
|
|
|
Trade,
|
|
|
|
TradingTime,
|
|
|
|
User,
|
|
|
|
)
|
2022-10-13 14:26:43 +00:00
|
|
|
|
2022-11-28 19:45:22 +00:00
|
|
|
# admin.site.__class__ = OTPAdminSite
|
2022-10-15 20:51:47 +00:00
|
|
|
|
|
|
|
# otp_admin_site = OTPAdminSite(OTPAdminSite.name)
|
|
|
|
# for model_cls, model_admin in admin.site._registry.items():
|
|
|
|
# otp_admin_site.register(model_cls, model_admin.__class__)
|
|
|
|
|
2022-10-13 14:26:43 +00:00
|
|
|
|
|
|
|
# Register your models here.
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
|
|
|
list_filter = ["plans"]
|
|
|
|
model = User
|
|
|
|
add_form = CustomUserCreationForm
|
|
|
|
fieldsets = (
|
|
|
|
*UserAdmin.fieldsets,
|
|
|
|
(
|
|
|
|
"Stripe information",
|
|
|
|
{"fields": ("stripe_id",)},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Payment information",
|
|
|
|
{
|
|
|
|
"fields": (
|
|
|
|
"plans",
|
|
|
|
"last_payment",
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-12-12 07:20:20 +00:00
|
|
|
class AccountAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "name", "exchange", "sandbox", "currency")
|
|
|
|
|
|
|
|
|
|
|
|
class HookAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "name", "hook", "received")
|
|
|
|
|
|
|
|
|
|
|
|
class SignalAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "name", "signal", "hook", "direction", "received", "type")
|
|
|
|
|
|
|
|
|
|
|
|
class TradeAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "account", "symbol", "amount", "direction", "status")
|
|
|
|
|
|
|
|
|
|
|
|
class CallbackAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("hook", "signal", "title", "symbol", "price")
|
|
|
|
|
|
|
|
|
|
|
|
class TradingTimeAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "name", "start_day", "start_time", "end_day", "end_time")
|
|
|
|
|
|
|
|
|
|
|
|
class StrategyAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ("user", "name", "description", "account", "enabled")
|
|
|
|
|
|
|
|
|
2022-10-13 14:26:43 +00:00
|
|
|
admin.site.register(User, CustomUserAdmin)
|
|
|
|
admin.site.register(Plan)
|
|
|
|
admin.site.register(Session)
|
2022-12-12 07:20:20 +00:00
|
|
|
|
|
|
|
admin.site.register(Account, AccountAdmin)
|
|
|
|
admin.site.register(Hook, HookAdmin)
|
|
|
|
admin.site.register(Signal, SignalAdmin)
|
|
|
|
admin.site.register(Trade, TradeAdmin)
|
|
|
|
admin.site.register(Callback, CallbackAdmin)
|
|
|
|
admin.site.register(TradingTime, TradingTimeAdmin)
|
|
|
|
admin.site.register(Strategy, StrategyAdmin)
|