0.12.52 subscribe page w dynamically load
This commit is contained in:
@@ -42,8 +42,9 @@ def get_profile_page_content_html(request, page_name, data):
|
|||||||
elif page_name == 'support':
|
elif page_name == 'support':
|
||||||
return get_profile_support_page_content_html(request, data)
|
return get_profile_support_page_content_html(request, data)
|
||||||
elif page_name == 'my_subscribe':
|
elif page_name == 'my_subscribe':
|
||||||
from SubscribesApp.funcs import get_profile_subscribe_page_content_html
|
from SubscribesApp.funcs import get_profile_subscribe_page_content_Dict
|
||||||
return get_profile_subscribe_page_content_html(request)
|
res = get_profile_subscribe_page_content_Dict(request)
|
||||||
|
return res['html']
|
||||||
elif page_name == 'change_profile':
|
elif page_name == 'change_profile':
|
||||||
return get_profile_change_page_content_html(request)
|
return get_profile_change_page_content_html(request)
|
||||||
elif page_name == 'dashboard':
|
elif page_name == 'dashboard':
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def check_n_enable_subscribe_by_order(order):
|
|||||||
return subscribes_for_user
|
return subscribes_for_user
|
||||||
|
|
||||||
|
|
||||||
def get_profile_subscribe_page_content_html(request):
|
def get_profile_subscribe_page_content_Dict(request):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
# 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()
|
||||||
|
|
||||||
subscribe_for_user = None
|
subscribes_for_user = None
|
||||||
|
|
||||||
orders = None
|
orders = None
|
||||||
if request.user and request.user.is_authenticated:
|
if request.user and request.user.is_authenticated:
|
||||||
@@ -75,23 +75,21 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
for order in orders:
|
for order in orders:
|
||||||
order = get_order_status(order)
|
order = get_order_status(order)
|
||||||
subscribes_for_user = check_n_enable_subscribe_by_order(order)
|
subscribes_for_user = check_n_enable_subscribe_by_order(order)
|
||||||
if subscribes_for_user:
|
if not subscribes_for_user:
|
||||||
subscribe_for_user = subscribes_for_user[0]
|
|
||||||
else:
|
|
||||||
subscribes.get(id=order.subscribe.id).order_error = order.status
|
subscribes.get(id=order.subscribe.id).order_error = order.status
|
||||||
check_orders_required = False
|
check_orders_required = False
|
||||||
else:
|
else:
|
||||||
check_orders_required = True
|
check_orders_required = True
|
||||||
|
|
||||||
|
|
||||||
if not subscribe_for_user:
|
if not subscribes_for_user:
|
||||||
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
|
subscribes_for_user = SubscribeForUser.objects.filter(user=request.user)
|
||||||
|
|
||||||
if not subscribe_for_user:
|
if not subscribes_for_user:
|
||||||
tpl_name = 'blocks/profile/b_subscribe_variants.html'
|
tpl_name = 'blocks/profile/b_subscribe_variants.html'
|
||||||
else:
|
else:
|
||||||
tpl_name = 'blocks/profile/b_subscribe_current.html'
|
tpl_name = 'blocks/profile/b_subscribe_current.html'
|
||||||
subscribe_for_user = subscribe_for_user[0]
|
subscribe_for_user = subscribes_for_user[0]
|
||||||
subscribe_options_ids = subscribe_for_user.subscribe.options.values_list('id', flat=True)
|
subscribe_options_ids = subscribe_for_user.subscribe.options.values_list('id', flat=True)
|
||||||
subscribe_for_user.subscribe.disabled_options = all_options.exclude(id__in=subscribe_options_ids)
|
subscribe_for_user.subscribe.disabled_options = all_options.exclude(id__in=subscribe_options_ids)
|
||||||
|
|
||||||
@@ -103,11 +101,13 @@ 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,
|
||||||
'check_orders_required': check_orders_required,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html = render_to_string(tpl_name, Dict, request=request)
|
html = render_to_string(tpl_name, Dict, request=request)
|
||||||
return html
|
return {
|
||||||
|
'html': html,
|
||||||
|
'check_orders_required': check_orders_required,
|
||||||
|
}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f'show_cur_subscribe_ajax Error = {str(e)}'
|
msg = f'show_cur_subscribe_ajax Error = {str(e)}'
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ def show_cur_subscribe_ajax(request):
|
|||||||
|
|
||||||
lang = get_and_set_lang(request)
|
lang = get_and_set_lang(request)
|
||||||
|
|
||||||
html = get_profile_subscribe_page_content_html(request)
|
Dict = get_profile_subscribe_page_content_Dict(request)
|
||||||
return JsonResponse({'html': html}, status=200)
|
return JsonResponse(Dict, status=200)
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user