0.12.36 pays and subscribes
This commit is contained in:
@@ -3,7 +3,7 @@ from django.shortcuts import render
|
||||
from uuid import uuid1
|
||||
from .models import *
|
||||
from django.contrib import auth
|
||||
from django.http import HttpResponse, Http404, JsonResponse
|
||||
from django.http import HttpResponse, Http404, JsonResponse, HttpResponseRedirect
|
||||
from django.template import loader, RequestContext
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from BaseModels.mailSender import techSendMail
|
||||
@@ -17,6 +17,7 @@ from datetime import datetime, time, timedelta
|
||||
from channels.layers import get_channel_layer
|
||||
from asgiref.sync import async_to_sync
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
from django.shortcuts import redirect
|
||||
|
||||
|
||||
@login_required()#login_url='/profile/login/')
|
||||
@@ -33,6 +34,18 @@ def subscribe_now_ajax(request):
|
||||
|
||||
subscribe = Subscribe.objects.get(id=data['subscribe_id'])
|
||||
|
||||
kwargs_for_order = {
|
||||
'user': request.user,
|
||||
'subscribe': subscribe,
|
||||
'currency': 'USD',
|
||||
'sum': subscribe.price,
|
||||
}
|
||||
|
||||
from BillingApp.funcs import create_subscribe_order
|
||||
order = create_subscribe_order(kwargs_for_order)
|
||||
if order:
|
||||
return JsonResponse({'redirect': order.pay_page})
|
||||
|
||||
kwargs = {
|
||||
'user': request.user,
|
||||
'subscribe': subscribe,
|
||||
@@ -41,13 +54,10 @@ def subscribe_now_ajax(request):
|
||||
'paid_period_to_DT': datetime.now() + timedelta(hours=subscribe.period),
|
||||
'receive_finish_subscribe_msg': True,
|
||||
}
|
||||
|
||||
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
|
||||
if subscribe_for_user:
|
||||
subscribe_for_user.update(**kwargs)
|
||||
subscribe_for_user = subscribe_for_user[0]
|
||||
else:
|
||||
subscribe_for_user = SubscribeForUser.objects.create(**kwargs)
|
||||
|
||||
if not subscribe_for_user:
|
||||
tpl_name = 'blocks/profile/b_subscribe_variants.html'
|
||||
|
||||
Reference in New Issue
Block a user