0.12.51 subscribe page w dynamically load
This commit is contained in:
@@ -20,7 +20,7 @@ def get_order_status(order):
|
|||||||
|
|
||||||
# if res['amount'] == res['amount_charged'] and res['status'] == 'charged':
|
# if res['amount'] == res['amount_charged'] and res['status'] == 'charged':
|
||||||
order.save()
|
order.save()
|
||||||
return order.status
|
# return order.status
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -29,7 +29,7 @@ def get_order_status(order):
|
|||||||
msg = f'Exception get_order_status (data = {str(order.id)}) = {str(e)}'
|
msg = f'Exception get_order_status (data = {str(order.id)}) = {str(e)}'
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
return None
|
return order
|
||||||
|
|
||||||
def get_orders_for_user(user):
|
def get_orders_for_user(user):
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ from .models import *
|
|||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.translation import get_language, activate
|
from django.utils.translation import get_language, activate
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def get_cur_user_subscribe(user):
|
def get_cur_user_subscribe(user):
|
||||||
|
|
||||||
@@ -53,7 +55,12 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
from GeneralApp.funcs import get_and_set_lang
|
from GeneralApp.funcs import get_and_set_lang
|
||||||
lang = get_and_set_lang(request)
|
lang = get_and_set_lang(request)
|
||||||
|
|
||||||
# data = json.loads(request.body)
|
data = {}
|
||||||
|
if request.body:
|
||||||
|
data = json.loads(request.body)
|
||||||
|
check_orders_required = False
|
||||||
|
if data and 'check_orders_required' in data: #Требуется проверка статусов заказов
|
||||||
|
check_orders_required = True
|
||||||
# all_options = SubscribeOption.objects.filter(enable=True)
|
# all_options = SubscribeOption.objects.filter(enable=True)
|
||||||
subscribes, all_options = get_subscribes_w_options()
|
subscribes, all_options = get_subscribes_w_options()
|
||||||
|
|
||||||
@@ -63,9 +70,19 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
if request.user and request.user.is_authenticated:
|
if request.user and request.user.is_authenticated:
|
||||||
from BillingApp.funcs import get_orders_for_user, get_order_status
|
from BillingApp.funcs import get_orders_for_user, get_order_status
|
||||||
orders = get_orders_for_user(request.user)
|
orders = get_orders_for_user(request.user)
|
||||||
# for order in orders:
|
if orders:
|
||||||
# res = get_order_status(order)
|
if check_orders_required:
|
||||||
# subscribe_for_user = check_n_enable_subscribe_by_order(order)
|
for order in orders:
|
||||||
|
order = get_order_status(order)
|
||||||
|
subscribes_for_user = check_n_enable_subscribe_by_order(order)
|
||||||
|
if subscribes_for_user:
|
||||||
|
subscribe_for_user = subscribes_for_user[0]
|
||||||
|
else:
|
||||||
|
subscribes.get(id=order.subscribe.id).order_error = order.status
|
||||||
|
check_orders_required = False
|
||||||
|
else:
|
||||||
|
check_orders_required = True
|
||||||
|
|
||||||
|
|
||||||
if not subscribe_for_user:
|
if not subscribe_for_user:
|
||||||
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
|
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
|
||||||
@@ -86,7 +103,7 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
Dict = {
|
Dict = {
|
||||||
'subscribe_for_user': subscribe_for_user,
|
'subscribe_for_user': subscribe_for_user,
|
||||||
'subscribes': subscribes,
|
'subscribes': subscribes,
|
||||||
'active_orders': orders,
|
'check_orders_required': check_orders_required,
|
||||||
}
|
}
|
||||||
|
|
||||||
html = render_to_string(tpl_name, Dict, request=request)
|
html = render_to_string(tpl_name, Dict, request=request)
|
||||||
|
|||||||
Reference in New Issue
Block a user