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.
70 lines
1.9 KiB
70 lines
1.9 KiB
# -*- coding: utf-8 -*-
|
|
from django.http import HttpResponse
|
|
from models import Conference
|
|
from functions.custom_views import ExpoListView
|
|
import json
|
|
|
|
class ConferenceView(ExpoListView):
|
|
model = Conference
|
|
template_name = 'event_catalog.html'
|
|
|
|
def conference_add_calendar(request, id):
|
|
args = {'success': False}
|
|
user = request.user
|
|
|
|
if user.is_authenticated():
|
|
conf = Conference.objects.safe_get(id=id)
|
|
if conf:
|
|
user.calendar.conferences.add(conf)
|
|
args['success'] = True
|
|
else:
|
|
args['not_authorized'] = True
|
|
args['success'] = True
|
|
|
|
return HttpResponse(json.dumps(args), content_type='application/json')
|
|
|
|
def conference_remove_calendar(request, id):
|
|
args = {'success': False}
|
|
if request.user:
|
|
user = request.user
|
|
conf = Conference.objects.safe_get(id=id)
|
|
if conf:
|
|
user.calendar.conferences.remove(conf)
|
|
args['success'] = True
|
|
else:
|
|
args['not_authorized'] = True
|
|
args['success'] = True
|
|
|
|
|
|
return HttpResponse(json.dumps(args), content_type='application/json')
|
|
|
|
def conference_visit(request, id):
|
|
args = {'success': False}
|
|
user = request.user
|
|
if user.is_authenticated():
|
|
conf = Conference.objects.safe_get(id=id)
|
|
if conf:
|
|
conf.users.add(user)
|
|
args['success'] = True
|
|
|
|
else:
|
|
args['not_authorized'] = True
|
|
args['success'] = True
|
|
|
|
return HttpResponse(json.dumps(args), content_type='application/json')
|
|
|
|
def conference_unvisit(request, id):
|
|
args = {'success': False}
|
|
user = request.user
|
|
if user.is_authenticated():
|
|
conf = Conference.objects.safe_get(id=id)
|
|
if conf:
|
|
conf.users.remove(user)
|
|
else:
|
|
args['not_authorized'] = True
|
|
args['success'] = True
|
|
|
|
return HttpResponse(json.dumps(args), content_type='application/json')
|
|
|
|
|
|
|
|
|