2021-09-28 13:10:22 +00:00
|
|
|
from django.shortcuts import render, redirect, get_object_or_404
|
2021-09-30 17:09:42 +00:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2021-09-30 18:33:47 +00:00
|
|
|
from django.conf import settings
|
2021-09-28 13:10:22 +00:00
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
def films(request):
|
|
|
|
context = {}
|
2021-10-11 12:55:45 +00:00
|
|
|
context['films'] = models.Film.objects.filter(public=True).order_by('position', 'data__title')
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'films.html', context)
|
|
|
|
|
|
|
|
def film(request, slug):
|
|
|
|
context = {}
|
|
|
|
context['film'] = get_object_or_404(models.Film, slug=slug)
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'film.html', context)
|
|
|
|
|
2021-09-30 17:09:42 +00:00
|
|
|
def film_play(request, slug, lang):
|
2021-09-28 13:10:22 +00:00
|
|
|
context = {}
|
|
|
|
context['film'] = get_object_or_404(models.Film, slug=slug)
|
2021-09-30 17:09:42 +00:00
|
|
|
context['lang'] = lang
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'film_play.html', context)
|
|
|
|
|
|
|
|
def edits(request):
|
|
|
|
context = {}
|
|
|
|
context['edits'] = models.Edit.objects.filter(public=True).order_by('created')
|
|
|
|
return render(request, 'edits.html', context)
|
|
|
|
|
|
|
|
def edit(request, slug):
|
|
|
|
context = {}
|
|
|
|
context['edit'] = get_object_or_404(models.Edit, slug=slug)
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'edit.html', context)
|
|
|
|
|
2021-09-30 17:09:42 +00:00
|
|
|
def edit_play(request, slug, lang):
|
2021-09-28 13:10:22 +00:00
|
|
|
context = {}
|
|
|
|
context['edit'] = get_object_or_404(models.Edit, slug=slug)
|
2021-09-30 17:09:42 +00:00
|
|
|
context['lang'] = lang
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'edit_play.html', context)
|
|
|
|
|
|
|
|
def tv(request):
|
|
|
|
context = {}
|
2021-09-30 18:33:47 +00:00
|
|
|
context['settings'] = settings
|
2021-09-28 13:10:22 +00:00
|
|
|
return render(request, 'tv.html', context)
|
2021-09-30 17:09:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
def pandoraAPI(request):
|
|
|
|
import ox
|
|
|
|
from .utils import render_to_json_response
|
|
|
|
import json
|
|
|
|
data = json.loads(request.body.decode())
|
|
|
|
print('pandora request', data)
|
|
|
|
api = ox.api.signin('https://pad.ma/api/')
|
|
|
|
data = getattr(api, data['action'])(**data['data'])
|
|
|
|
print('response', data)
|
|
|
|
return render_to_json_response(data)
|
|
|
|
|