0.12.52 subscribe page w dynamically load

This commit is contained in:
SDE
2024-05-07 15:01:13 +03:00
parent b374e7aeca
commit 8ed567496b
3 changed files with 16 additions and 15 deletions

View File

@@ -48,7 +48,7 @@ def check_n_enable_subscribe_by_order(order):
return subscribes_for_user
def get_profile_subscribe_page_content_html(request):
def get_profile_subscribe_page_content_Dict(request):
try:
@@ -64,7 +64,7 @@ def get_profile_subscribe_page_content_html(request):
# all_options = SubscribeOption.objects.filter(enable=True)
subscribes, all_options = get_subscribes_w_options()
subscribe_for_user = None
subscribes_for_user = None
orders = None
if request.user and request.user.is_authenticated:
@@ -75,23 +75,21 @@ def get_profile_subscribe_page_content_html(request):
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:
if not subscribes_for_user:
subscribes.get(id=order.subscribe.id).order_error = order.status
check_orders_required = False
else:
check_orders_required = True
if not subscribe_for_user:
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
if not subscribes_for_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'
else:
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_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 = {
'subscribe_for_user': subscribe_for_user,
'subscribes': subscribes,
'check_orders_required': check_orders_required,
}
html = render_to_string(tpl_name, Dict, request=request)
return html
return {
'html': html,
'check_orders_required': check_orders_required,
}
except Exception as e:
msg = f'show_cur_subscribe_ajax Error = {str(e)}'

View File

@@ -91,8 +91,8 @@ def show_cur_subscribe_ajax(request):
lang = get_and_set_lang(request)
html = get_profile_subscribe_page_content_html(request)
return JsonResponse({'html': html}, status=200)
Dict = get_profile_subscribe_page_content_Dict(request)
return JsonResponse(Dict, status=200)
# try:
#