fix subscribe_for_user
This commit is contained in:
SDE
2023-08-31 19:09:18 +03:00
parent c8a902998f
commit 7f2e216db4

View File

@@ -79,6 +79,7 @@ def show_cur_subscribe_ajax(request):
try: try:
# data = json.loads(request.body) # data = json.loads(request.body)
all_options = SubscribeOption.objects.filter(enable=True)
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user) subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
if not subscribe_for_user: if not subscribe_for_user:
@@ -86,8 +87,9 @@ def show_cur_subscribe_ajax(request):
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 = subscribe_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)
all_options = SubscribeOption.objects.filter(enable=True)
subscribes = Subscribe.objects.filter(enable=True) subscribes = Subscribe.objects.filter(enable=True)
for subscribe in subscribes: for subscribe in subscribes:
subscribe_options_ids = subscribe.options.values_list('id', flat=True) subscribe_options_ids = subscribe.options.values_list('id', flat=True)