116 lines
3.0 KiB
Python
116 lines
3.0 KiB
Python
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
|
|
from .forms import CustomUserCreationForm
|
|
from .models import ( # AssetRestriction,; Plan,; Session,
|
|
Account,
|
|
AssetGroup,
|
|
Callback,
|
|
Hook,
|
|
NotificationSettings,
|
|
RiskModel,
|
|
Signal,
|
|
Strategy,
|
|
Trade,
|
|
TradingTime,
|
|
User,
|
|
)
|
|
|
|
# admin.site.__class__ = OTPAdminSite
|
|
|
|
# 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__)
|
|
|
|
|
|
# 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",
|
|
)
|
|
},
|
|
),
|
|
)
|
|
|
|
|
|
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")
|
|
|
|
|
|
class NotificationSettingsAdmin(admin.ModelAdmin):
|
|
list_display = ("user", "ntfy_topic", "ntfy_url")
|
|
|
|
|
|
class RiskModelAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
"user",
|
|
"name",
|
|
"description",
|
|
"max_loss_percent",
|
|
"max_risk_percent",
|
|
"max_open_trades",
|
|
"max_open_trades_per_symbol",
|
|
)
|
|
|
|
|
|
class AssetGroupAdmin(admin.ModelAdmin):
|
|
list_display = ("user", "name", "description", "webhook_id")
|
|
|
|
|
|
# class AssetRestrictionAdmin(admin.ModelAdmin):
|
|
# list_display = ("user", "name", "description", "webhook_id", "group")
|
|
|
|
|
|
admin.site.register(User, CustomUserAdmin)
|
|
# admin.site.register(Plan)
|
|
# admin.site.register(Session)
|
|
|
|
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)
|
|
admin.site.register(NotificationSettings, NotificationSettingsAdmin)
|
|
admin.site.register(RiskModel, RiskModelAdmin)
|
|
admin.site.register(AssetGroup, AssetGroupAdmin)
|
|
# admin.site.register(AssetRestriction, AssetRestrictionAdmin)
|