fix task
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.http import JsonResponse
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
from SubscribesApp.models import SubscribeForUser
|
from SubscribesApp.models import SubscribeForUser
|
||||||
@@ -31,6 +31,6 @@ class SubscribersView(APIView):
|
|||||||
else:
|
else:
|
||||||
subscribe_for_user.update(auto_continue=False)
|
subscribe_for_user.update(auto_continue=False)
|
||||||
|
|
||||||
return Response("Subscriptions updated successfully", status=status.HTTP_200_OK)
|
return JsonResponse({"message": "Subscriptions updated successfully"}, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
return Response("User not found", status=status.HTTP_404_NOT_FOUND)
|
return JsonResponse({"message": "User not found"}, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def check_auto_subscribe():
|
|||||||
def subscription_expiration_check():
|
def subscription_expiration_check():
|
||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
subscribes = SubscribeForUser.objects.filter(paid_period_to_DT__gte=current_time)
|
subscribes = SubscribeForUser.objects.filter(paid_period_to_DT__gte=current_time)
|
||||||
|
if subscribes:
|
||||||
for subscribe in subscribes:
|
for subscribe in subscribes:
|
||||||
expiration_date = subscribe.paid_period_to_DT
|
expiration_date = subscribe.paid_period_to_DT
|
||||||
remaining_days = (expiration_date - current_time).days
|
remaining_days = (expiration_date - current_time).days
|
||||||
|
|||||||
Reference in New Issue
Block a user