added new functionalities of G-Token
This commit is contained in:
@@ -71,3 +71,48 @@ class StripeConnectAccountAdmin(admin.ModelAdmin):
|
||||
"details_submitted",
|
||||
)
|
||||
search_fields = ("principal__name", "stripe_connect_id")
|
||||
|
||||
|
||||
class WithdrawalRequestAdmin(admin.ModelAdmin):
|
||||
list_display = ("id", "principal", "coins", "token", "amount", "status", "ref_id")
|
||||
list_filter = ("status", "principal")
|
||||
search_fields = (
|
||||
"ref_id",
|
||||
"token",
|
||||
"principal__user__username",
|
||||
) # Adjust if 'principal' has a different relation to User
|
||||
readonly_fields = ("ref_image", "reply", "notes")
|
||||
|
||||
fieldsets = (
|
||||
(None, {"fields": ("principal", "coins", "token", "amount", "status")}),
|
||||
(
|
||||
"Reference Information",
|
||||
{
|
||||
"fields": ("ref_image", "ref_id", "notes", "reply"),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
# def has_delete_permission(self, request, obj=None):
|
||||
# # Disable delete if the status is not 'denied' or 'dispute'
|
||||
# if obj is not None:
|
||||
# if obj.status in ["denied", "dispute"]:
|
||||
# return True
|
||||
# return False
|
||||
# return True
|
||||
|
||||
def has_add_permission(self, request, obj=None):
|
||||
# You can also control if adding is allowed
|
||||
return True
|
||||
|
||||
def has_change_permission(self, request, obj=None):
|
||||
# Control the ability to change existing records
|
||||
if obj is not None:
|
||||
if obj.status in ["submitted", "review"]:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
admin.site.register(models.WithdrawalRequest, WithdrawalRequestAdmin)
|
||||
|
||||
@@ -33,4 +33,10 @@ urlpatterns = [
|
||||
views.WithdrawalRequestView.as_view(),
|
||||
name="withdrawal-request-view",
|
||||
),
|
||||
# checking bank accounts
|
||||
path(
|
||||
"check-bank-accounts/",
|
||||
views.PrincipalBankAccountCheck.as_view(),
|
||||
name="check_bank_accounts",
|
||||
),
|
||||
]
|
||||
|
||||
@@ -419,3 +419,26 @@ class WithdrawalRequestView(APIView):
|
||||
status=status.HTTP_200_OK,
|
||||
message=constants.SUCCESS,
|
||||
)
|
||||
|
||||
|
||||
class PrincipalBankAccountCheck(APIView):
|
||||
authentication_classes = [JWTAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request):
|
||||
queryset = models.PrincipalBankAccount.objects.filter(principal=request.user)
|
||||
if queryset:
|
||||
response = {
|
||||
"status": status.HTTP_200_OK,
|
||||
"message": constants.SUCCESS,
|
||||
"data": True,
|
||||
}
|
||||
|
||||
return ApiResponse.success(**response)
|
||||
false_response = {
|
||||
"status": status.HTTP_200_OK,
|
||||
"message": constants.SUCCESS,
|
||||
"data": False,
|
||||
}
|
||||
|
||||
return ApiResponse.success(**false_response)
|
||||
|
||||
18
manage_wallets/migrations/0010_withdrawalrequest_token.py
Normal file
18
manage_wallets/migrations/0010_withdrawalrequest_token.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-04-23 11:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("manage_wallets", "0009_rename_coin_transaction_coins_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="withdrawalrequest",
|
||||
name="token",
|
||||
field=models.CharField(blank=True, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
@@ -3,6 +3,7 @@ from django.db import models
|
||||
from accounts.models import BaseModel, IAmPrincipal, IAmPrincipalType
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from manage_referrals.models import ReferralRecordReward
|
||||
from manage_subscriptions.models import PrincipalSubscription
|
||||
|
||||
# Create your models here.
|
||||
@@ -135,6 +136,7 @@ class WithdrawalRequest(BaseModel):
|
||||
IAmPrincipal, on_delete=models.CASCADE, related_name="withdrawal_requests"
|
||||
)
|
||||
coins = models.IntegerField(default=0)
|
||||
token = models.CharField(max_length=255, blank=True, null=True)
|
||||
amount = models.DecimalField(max_digits=14, decimal_places=2, default=0.00)
|
||||
ref_image = models.ImageField(upload_to="withdrawal", null=True, blank=True)
|
||||
ref_id = models.CharField(unique=True, max_length=255, null=True, blank=True)
|
||||
|
||||
@@ -78,10 +78,20 @@ class StatusUpdateView(LoginRequiredMixin, generic.View):
|
||||
id = request.POST.get("id")
|
||||
message = request.POST.get("message")
|
||||
status = request.POST.get("status")
|
||||
|
||||
print("Request.POST: ", request.POST)
|
||||
if id or message:
|
||||
try:
|
||||
instance = self.model.objects.get(id=id)
|
||||
print("status: ", status)
|
||||
if status == "transferred":
|
||||
print("Hello")
|
||||
bank_account = PrincipalBankAccount.objects.filter(principal=instance.principal)
|
||||
print("bank_account: ", bank_account)
|
||||
for account in bank_account:
|
||||
account.delete()
|
||||
print("Deleted all accounts")
|
||||
|
||||
instance.reply = message
|
||||
instance.status = status
|
||||
instance.save()
|
||||
|
||||
Reference in New Issue
Block a user