2023-03-17 18:37:38 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from mixins.views import ObjectCreate, ObjectDelete, ObjectList, ObjectUpdate
|
|
|
|
from two_factor.views.mixins import OTPRequiredMixin
|
|
|
|
|
2023-03-20 11:06:37 +00:00
|
|
|
from core.forms import OperatorWalletsForm, WalletForm
|
|
|
|
from core.models import OperatorWallets, Wallet
|
2023-03-17 18:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class WalletList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
|
|
|
list_template = "partials/wallet-list.html"
|
|
|
|
model = Wallet
|
2023-03-18 10:48:07 +00:00
|
|
|
page_title = "List of wallets to send profit to"
|
2023-03-17 18:37:38 +00:00
|
|
|
|
|
|
|
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
|
2023-03-20 11:06:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|