0.7.40
add subscribes for static pages
This commit is contained in:
@@ -59,7 +59,7 @@ def MainPage(request):
|
|||||||
|
|
||||||
def StaticPageView(request, url):
|
def StaticPageView(request, url):
|
||||||
from RoutesApp.forms import RouteForm
|
from RoutesApp.forms import RouteForm
|
||||||
from SubscribesApp.models import Subscribe
|
from SubscribesApp.funcs import get_subsribes_w_options
|
||||||
|
|
||||||
Dict = {}
|
Dict = {}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ def StaticPageView(request, url):
|
|||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
if url in ['for_movers', 'for_customers']:
|
if url in ['for_movers', 'for_customers']:
|
||||||
subscribes = Subscribe.objects.filter(enable=True)
|
subscribes, all_options = get_subsribes_w_options()
|
||||||
Dict.update({
|
Dict.update({
|
||||||
'subscribes': subscribes,
|
'subscribes': subscribes,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
from .models import *
|
from .models import *
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
|
|
||||||
|
|
||||||
|
def get_subsribes_w_options():
|
||||||
|
all_options = SubscribeOption.objects.filter(enable=True)
|
||||||
|
subscribes = Subscribe.objects.filter(enable=True)
|
||||||
|
for subscribe in subscribes:
|
||||||
|
subscribe_options_ids = subscribe.options.values_list('id', flat=True)
|
||||||
|
subscribe.disabled_options = all_options.exclude(id__in=subscribe_options_ids)
|
||||||
|
|
||||||
|
return subscribes, all_options
|
||||||
|
|
||||||
|
|
||||||
def get_profile_subscribe_page_content_html(request):
|
def get_profile_subscribe_page_content_html(request):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# data = json.loads(request.body)
|
# data = json.loads(request.body)
|
||||||
all_options = SubscribeOption.objects.filter(enable=True)
|
# all_options = SubscribeOption.objects.filter(enable=True)
|
||||||
|
subscribes, all_options = get_subsribes_w_options()
|
||||||
|
|
||||||
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:
|
||||||
@@ -17,10 +29,10 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
subscribe.disabled_options = all_options.exclude(id__in=subscribe_options_ids)
|
# subscribe.disabled_options = all_options.exclude(id__in=subscribe_options_ids)
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
'subscribe_for_user': subscribe_for_user,
|
'subscribe_for_user': subscribe_for_user,
|
||||||
|
|||||||
Reference in New Issue
Block a user