You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB
Python

from django.contrib.auth.mixins import LoginRequiredMixin
from mixins.views import ObjectCreate, ObjectDelete, ObjectList, ObjectUpdate
from two_factor.views.mixins import OTPRequiredMixin
from core.forms import OperatorWalletsForm, WalletForm
from core.models import OperatorWallets, Wallet
class WalletList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
list_template = "partials/wallet-list.html"
model = Wallet
page_title = "List of wallets to send profit to"
list_url_name = "wallets"
list_url_args = ["type"]
submit_url_name = "wallet_create"
class WalletCreate(LoginRequiredMixin, OTPRequiredMixin, ObjectCreate):
model = Wallet
form_class = WalletForm
submit_url_name = "wallet_create"
class WalletUpdate(LoginRequiredMixin, OTPRequiredMixin, ObjectUpdate):
model = Wallet
form_class = WalletForm
submit_url_name = "wallet_update"
class WalletDelete(LoginRequiredMixin, OTPRequiredMixin, ObjectDelete):
model = Wallet
class OperatorWalletsUpdate(LoginRequiredMixin, ObjectUpdate):
model = OperatorWallets
form_class = OperatorWalletsForm
page_title = "Update your designated wallets"
submit_url_name = "operator_wallets_update"
submit_url_args = ["type"]
pk_required = False
hide_cancel = True
def get_object(self, **kwargs):
wallet, _ = OperatorWallets.objects.get_or_create(user=self.request.user)
return wallet