2018-08-10 13:06:33 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
/set_session app views.
|
|
|
|
"""
|
|
|
|
from django.http import HttpResponse
|
2018-10-02 13:31:58 -04:00
|
|
|
from django.views.decorators.http import require_POST
|
2018-08-10 13:06:33 -04:00
|
|
|
|
2018-10-02 13:31:58 -04:00
|
|
|
@require_POST
|
2018-08-10 13:06:33 -04:00
|
|
|
def index(request):
|
|
|
|
"""
|
|
|
|
A simple API endpoint for setting certain values in the users session.
|
|
|
|
"""
|
2018-09-20 13:09:24 -04:00
|
|
|
for key, value in request.POST.items():
|
|
|
|
if key not in ['hide_header', 'hide_chat']:
|
|
|
|
continue
|
|
|
|
if value == 'on':
|
|
|
|
request.session[key] = True
|
|
|
|
elif value == 'off':
|
|
|
|
request.session[key] = False
|
|
|
|
|
2018-08-10 13:06:33 -04:00
|
|
|
return HttpResponse('true')
|