You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.8 KiB

# -*- coding: utf-8 -*-
from models import Webinar
from functions.custom_views import ExpoListView
from django.http import HttpResponse
import json
class WebinarView(ExpoListView):
model = Webinar
template_name = 'event_catalog.html'
def webinar_add_calendar(request, id):
args = {'success': False}
user = request.user
if user.is_authenticated():
web = Webinar.objects.safe_get(id=id)
if web:
user.calendar.webinars.add(web)
args['success'] = True
else:
args['not_authorized'] = True
args['success'] = True
return HttpResponse(json.dumps(args), content_type='application/json')
def webinar_remove_calendar(request, id):
args = {'success': False}
if request.user:
user = request.user
web = Webinar.objects.safe_get(id=id)
if web:
user.calendar.webinars.remove(web)
args['success'] = True
else:
args['not_authorized'] = True
args['success'] = True
return HttpResponse(json.dumps(args), content_type='application/json')
def webinar_visit(request, id):
args = {'success': False}
user = request.user
if user.is_authenticated():
web = Webinar.objects.safe_get(id=id)
if web:
web.users.add(user)
args['success'] = True
else:
args['not_authorized'] = True
args['success'] = True
return HttpResponse(json.dumps(args), content_type='application/json')
def webinar_unvisit(request, id):
args = {'success': False}
user = request.user
if user.is_authenticated():
web = Webinar.objects.safe_get(id=id)
if web:
web.users.remove(user)
else:
args['not_authorized'] = True
args['success'] = True
return HttpResponse(json.dumps(args), content_type='application/json')