0.6.9
profile subscribe view
This commit is contained in:
16
SubscribesApp/js_urls.py
Normal file
16
SubscribesApp/js_urls.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
from django.urls import path
|
||||||
|
# from AuthApp.js_views import *
|
||||||
|
# from AuthApp.import_funcs import *
|
||||||
|
from .js_views import *
|
||||||
|
from django.contrib.auth import views
|
||||||
|
from RoutesApp.js_views import new_route_view_ajax
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('show_cur_subscribe/', show_cur_subscribe_ajax, name='show_cur_subscribe_ajax'),
|
||||||
|
# path('create_ticket/', create_ticket_ajax, name='create_ticket_ajax'),
|
||||||
|
# path('support_show_chat_by_ticket/', support_show_chat_by_ticket_ajax, name='support_show_chat_by_ticket_ajax'),
|
||||||
|
# # path('send_msg/', send_msg_ajax, name='send_msg_ajax'),
|
||||||
|
# # path('update_chat/', update_chat_ajax2, name='update_chat_ajax'),
|
||||||
|
# path('show_chat_w_user/', show_chat_w_user_ajax, name='show_chat_w_user_ajax'),
|
||||||
|
]
|
||||||
49
SubscribesApp/js_views.py
Normal file
49
SubscribesApp/js_views.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from uuid import uuid1
|
||||||
|
from .models import *
|
||||||
|
from django.contrib import auth
|
||||||
|
from django.http import HttpResponse, Http404, JsonResponse
|
||||||
|
from django.template import loader, RequestContext
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from BaseModels.mailSender import techSendMail
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
from datetime import datetime
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
from django.urls import reverse
|
||||||
|
# from .funcs import *
|
||||||
|
import json
|
||||||
|
from datetime import datetime, time
|
||||||
|
from channels.layers import get_channel_layer
|
||||||
|
from asgiref.sync import async_to_sync
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url='/profile/login/')
|
||||||
|
def show_cur_subscribe_ajax(request):
|
||||||
|
|
||||||
|
if request.method != 'POST':
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
# data = json.loads(request.body)
|
||||||
|
|
||||||
|
subscribe_for_user = SubscribeForUser.objects.filter(user=request.user)
|
||||||
|
if not subscribe_for_user:
|
||||||
|
tpl_name = 'blocks/profile/b_subscribe_variants.html'
|
||||||
|
else:
|
||||||
|
tpl_name = 'blocks/profile/b_subscribe_variants.html'
|
||||||
|
|
||||||
|
subscribes = Subscribe.objects.filter(enable=True)
|
||||||
|
|
||||||
|
Dict = {
|
||||||
|
'subscribe_for_user': subscribe_for_user,
|
||||||
|
'subscribes': subscribes
|
||||||
|
}
|
||||||
|
|
||||||
|
html = render_to_string(tpl_name, Dict, request=request)
|
||||||
|
return JsonResponse({'html': html}, status=200)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
msg = f'show_cur_subscribe_ajax Error = {str(e)}'
|
||||||
|
return JsonResponse({'error': msg}, status=400)
|
||||||
@@ -24,6 +24,8 @@ urlpatterns += i18n_patterns(
|
|||||||
path('routes/', include('RoutesApp.js_urls')),
|
path('routes/', include('RoutesApp.js_urls')),
|
||||||
path('routes/', include('RoutesApp.urls')),
|
path('routes/', include('RoutesApp.urls')),
|
||||||
|
|
||||||
|
path('subscribes/', include('SubscribesApp.js_urls')),
|
||||||
|
|
||||||
path('messages/', include('ChatServiceApp.js_urls')),
|
path('messages/', include('ChatServiceApp.js_urls')),
|
||||||
|
|
||||||
path('reference_data/', include('ReferenceDataApp.js_urls')),
|
path('reference_data/', include('ReferenceDataApp.js_urls')),
|
||||||
|
|||||||
Reference in New Issue
Block a user