inital version of scroll view, burger menu, css reset
This commit is contained in:
parent
0508d8cd9a
commit
4faf546335
20 changed files with 438 additions and 42 deletions
23
app/video/migrations/0002_auto_20210930_1527.py
Normal file
23
app/video/migrations/0002_auto_20210930_1527.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-30 15:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('video', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='edit',
|
||||
name='data',
|
||||
field=models.JSONField(blank=True, default=dict),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='film',
|
||||
name='data',
|
||||
field=models.JSONField(blank=True, default=dict),
|
||||
),
|
||||
]
|
||||
39
app/video/utils.py
Normal file
39
app/video/utils.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import datetime
|
||||
from django.utils import datetime_safe
|
||||
from django.http import HttpResponse, Http404
|
||||
import json
|
||||
from django.conf import settings
|
||||
|
||||
def json_response(data=None, status=200, text='ok'):
|
||||
if not data:
|
||||
data = {}
|
||||
return {'status': {'code': status, 'text': text}, 'data': data}
|
||||
|
||||
def _to_json(python_object):
|
||||
if isinstance(python_object, datetime.datetime):
|
||||
if python_object.year < 1900:
|
||||
tt = python_object.timetuple()
|
||||
return '%d-%02d-%02dT%02d:%02d%02dZ' % tuple(list(tt)[:6])
|
||||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
if isinstance(python_object, datetime_safe.datetime):
|
||||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
raise TypeError('%s %s is not JSON serializable' % (repr(python_object), type(python_object)))
|
||||
|
||||
def json_dump(data, fp, indent=4):
|
||||
return json.dump(data, fp, indent=indent, default=_to_json, ensure_ascii=False)
|
||||
|
||||
def json_dumps(data, indent=4):
|
||||
return json.dumps(data, indent=indent, default=_to_json, ensure_ascii=False)
|
||||
|
||||
def render_to_json_response(dictionary, content_type="application/json", status=200):
|
||||
indent = None
|
||||
if settings.DEBUG:
|
||||
content_type = "text/javascript"
|
||||
indent = 2
|
||||
if getattr(settings, 'JSON_DEBUG', False):
|
||||
print(json_dumps(dictionary, indent=2).encode('utf-8'))
|
||||
response = json_dumps(dictionary, indent=indent)
|
||||
if not isinstance(response, bytes):
|
||||
response = response.encode('utf-8')
|
||||
return HttpResponse(response, content_type=content_type, status=status)
|
||||
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
|
||||
from . import models
|
||||
|
||||
def films(request):
|
||||
context = {}
|
||||
context['films'] = models.Film.objects.filter(public=True).order_by('created')
|
||||
context['films'] = models.Film.objects.filter(public=True).order_by('data__title')
|
||||
return render(request, 'films.html', context)
|
||||
|
||||
def film(request, slug):
|
||||
|
|
@ -12,9 +14,10 @@ def film(request, slug):
|
|||
context['film'] = get_object_or_404(models.Film, slug=slug)
|
||||
return render(request, 'film.html', context)
|
||||
|
||||
def film_play(request, slug):
|
||||
def film_play(request, slug, lang):
|
||||
context = {}
|
||||
context['film'] = get_object_or_404(models.Film, slug=slug)
|
||||
context['lang'] = lang
|
||||
return render(request, 'film_play.html', context)
|
||||
|
||||
def edits(request):
|
||||
|
|
@ -27,11 +30,26 @@ def edit(request, slug):
|
|||
context['edit'] = get_object_or_404(models.Edit, slug=slug)
|
||||
return render(request, 'edit.html', context)
|
||||
|
||||
def edit_play(request, slug):
|
||||
def edit_play(request, slug, lang):
|
||||
context = {}
|
||||
context['edit'] = get_object_or_404(models.Edit, slug=slug)
|
||||
context['lang'] = lang
|
||||
return render(request, 'edit_play.html', context)
|
||||
|
||||
def tv(request):
|
||||
context = {}
|
||||
return render(request, 'tv.html', context)
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue