fix(pg): uncomment
uncomment
This commit is contained in:
parent
a032eb1ccd
commit
33a7ab386e
2 changed files with 40 additions and 40 deletions
|
|
@ -6,8 +6,8 @@ from .views import user as user_views
|
|||
app_name = "wallet"
|
||||
|
||||
user_urlpatterns = [
|
||||
# path('transactions/', user_views.TransactionListView.as_view(), name='user_transaction_list_page'),
|
||||
# path('transactions/<pk>', user_views.TransactionDetailView.as_view(), name='user_transaction_detail_page'),
|
||||
path('transactions/', user_views.TransactionListView.as_view(), name='user_transaction_list_page'),
|
||||
path('transactions/<pk>', user_views.TransactionDetailView.as_view(), name='user_transaction_detail_page'),
|
||||
path('api/wallets/', user_views.WalletAccountListAPIView.as_view(), name='user_wallet_account_api'),
|
||||
path('api/transactions/', user_views.TransactionListAPIView.as_view(), name='user_transaction_list_api'),
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ from apps.wallet.serializers import TransactionSerializer, DepositSerializer, Wi
|
|||
AccountSerializer
|
||||
from ..constans import StateChoices, TypeChoices
|
||||
from ..filters import AccountFilter, UserTransactionFilter
|
||||
# from ..forms import TransactionActionForm
|
||||
from ..forms import TransactionActionForm
|
||||
|
||||
# from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def get_application(request):
|
||||
|
|
@ -186,44 +186,44 @@ class WithdrawVerify(generics.RetrieveAPIView):
|
|||
return Response(serializer.data)
|
||||
|
||||
|
||||
# @method_decorator(login_required, name='dispatch')
|
||||
# class TransactionListView(ListView):
|
||||
# model = Transaction
|
||||
# template_name = 'wallet/transaction_list.html'
|
||||
#
|
||||
# def get_queryset(self):
|
||||
# user = self.request.user
|
||||
# qs = super().get_queryset()
|
||||
# return qs.filter(Q(payee_id=user.pk) | Q(payer_id=user.pk)).all()
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class TransactionListView(ListView):
|
||||
model = Transaction
|
||||
template_name = 'wallet/transaction_list.html'
|
||||
|
||||
def get_queryset(self):
|
||||
user = self.request.user
|
||||
qs = super().get_queryset()
|
||||
return qs.filter(Q(payee_id=user.pk) | Q(payer_id=user.pk)).all()
|
||||
|
||||
|
||||
# @method_decorator(login_required, name='dispatch')
|
||||
# class TransactionDetailView(UpdateView):
|
||||
# model = Transaction
|
||||
# form_class = TransactionActionForm
|
||||
# template_name = 'wallet/transaction_detail.html'
|
||||
#
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context_data = super().get_context_data(**kwargs)
|
||||
# context_data['StateChoices'] = StateChoices
|
||||
# return context_data
|
||||
#
|
||||
# def get_queryset(self):
|
||||
# user = self.request.user
|
||||
# return Transaction.objects.filter(Q(payee=user) | Q(payer=user) | Q(payer__isnull=True)).all()
|
||||
#
|
||||
# def get_success_url(self):
|
||||
# return reverse('wallet:transaction_detail', kwargs={'pk': self.get_object().pk})
|
||||
#
|
||||
# def form_valid(self, form):
|
||||
# transaction: Transaction = form.instance
|
||||
# if 'pay' in self.request.POST:
|
||||
# result = transaction.pay(payer=self.request.user)
|
||||
# messages.error(self.request, _('success.'))
|
||||
# if 'receipt' in self.request.POST:
|
||||
# result = transaction.receipt()
|
||||
# messages.error(self.request, _('success.'))
|
||||
# return super().form_valid(form)
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class TransactionDetailView(UpdateView):
|
||||
model = Transaction
|
||||
form_class = TransactionActionForm
|
||||
template_name = 'wallet/transaction_detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context_data = super().get_context_data(**kwargs)
|
||||
context_data['StateChoices'] = StateChoices
|
||||
return context_data
|
||||
|
||||
def get_queryset(self):
|
||||
user = self.request.user
|
||||
return Transaction.objects.filter(Q(payee=user) | Q(payer=user) | Q(payer__isnull=True)).all()
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('wallet:transaction_detail', kwargs={'pk': self.get_object().pk})
|
||||
|
||||
def form_valid(self, form):
|
||||
transaction: Transaction = form.instance
|
||||
if 'pay' in self.request.POST:
|
||||
result = transaction.pay(payer=self.request.user)
|
||||
messages.error(self.request, _('success.'))
|
||||
if 'receipt' in self.request.POST:
|
||||
result = transaction.receipt()
|
||||
messages.error(self.request, _('success.'))
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue