aab21
This commit is contained in:
commit
0508d8cd9a
53 changed files with 765 additions and 0 deletions
0
app/video/__init__.py
Normal file
0
app/video/__init__.py
Normal file
12
app/video/admin.py
Normal file
12
app/video/admin.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
@admin.decorators.register(models.Film)
|
||||
class FilmAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
@admin.decorators.register(models.Edit)
|
||||
class EditAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
6
app/video/apps.py
Normal file
6
app/video/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class VideoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app.video'
|
||||
30
app/video/management/commands/load_titles.py
Normal file
30
app/video/management/commands/load_titles.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
import ox
|
||||
from ... import models
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'import titles from pan.do/ra'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--api", dest="api", type=str, default='https://pad.ma/api/'),
|
||||
parser.add_argument("--group", dest="group", type=str, default='Asian Art Biennial 2021'),
|
||||
|
||||
def handle(self, *args, **options):
|
||||
api = ox.api.signin(options['api'])
|
||||
query = {
|
||||
'query': {
|
||||
'conditions': [{'key': 'groups', 'value': options['group'], 'operator': '=='}]
|
||||
},
|
||||
'keys': ['id', 'title', 'director', 'summary', 'source'],
|
||||
'range': [0, 1000]
|
||||
}
|
||||
for item in api.find(**query)['data']['items']:
|
||||
print(item)
|
||||
f, c = models.Film.objects.get_or_create(padma_id=item['id'])
|
||||
for key, value in item.items():
|
||||
if key != 'id':
|
||||
f.data[key] = value
|
||||
f.public = True
|
||||
f.slug = item['id']
|
||||
f.save()
|
||||
41
app/video/migrations/0001_initial.py
Normal file
41
app/video/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Generated by Django 3.2.7 on 2021-09-28 12:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Edit',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('modified', models.DateTimeField(auto_now=True)),
|
||||
('slug', models.SlugField()),
|
||||
('public', models.BooleanField(default=False)),
|
||||
('padma_id', models.CharField(max_length=1024)),
|
||||
('annotation_user', models.CharField(max_length=1024)),
|
||||
('vimeo_id', models.CharField(default=None, max_length=255, null=True)),
|
||||
('data', models.JSONField(default=dict)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Film',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('modified', models.DateTimeField(auto_now=True)),
|
||||
('slug', models.SlugField()),
|
||||
('public', models.BooleanField(default=False)),
|
||||
('padma_id', models.CharField(max_length=255)),
|
||||
('vimeo_id', models.CharField(default=None, max_length=255, null=True)),
|
||||
('data', models.JSONField(default=dict)),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
app/video/migrations/__init__.py
Normal file
0
app/video/migrations/__init__.py
Normal file
40
app/video/models.py
Normal file
40
app/video/models.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import logging
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Film(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
slug = models.SlugField()
|
||||
public = models.BooleanField(default=False)
|
||||
|
||||
padma_id = models.CharField(max_length=255)
|
||||
vimeo_id = models.CharField(max_length=255, default=None, null=True)
|
||||
|
||||
data = models.JSONField(default=dict, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.data.get('title', self.slug)
|
||||
|
||||
|
||||
class Edit(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
slug = models.SlugField()
|
||||
public = models.BooleanField(default=False)
|
||||
|
||||
padma_id = models.CharField(max_length=1024)
|
||||
annotation_user = models.CharField(max_length=1024)
|
||||
vimeo_id = models.CharField(max_length=255, default=None, null=True)
|
||||
|
||||
data = models.JSONField(default=dict, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.data.get('title', self.slug)
|
||||
3
app/video/tests.py
Normal file
3
app/video/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
37
app/video/views.py
Normal file
37
app/video/views.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
|
||||
from . import models
|
||||
|
||||
def films(request):
|
||||
context = {}
|
||||
context['films'] = models.Film.objects.filter(public=True).order_by('created')
|
||||
return render(request, 'films.html', context)
|
||||
|
||||
def film(request, slug):
|
||||
context = {}
|
||||
context['film'] = get_object_or_404(models.Film, slug=slug)
|
||||
return render(request, 'film.html', context)
|
||||
|
||||
def film_play(request, slug):
|
||||
context = {}
|
||||
context['film'] = get_object_or_404(models.Film, slug=slug)
|
||||
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)
|
||||
return render(request, 'edit.html', context)
|
||||
|
||||
def edit_play(request, slug):
|
||||
context = {}
|
||||
context['edit'] = get_object_or_404(models.Edit, slug=slug)
|
||||
return render(request, 'edit_play.html', context)
|
||||
|
||||
def tv(request):
|
||||
context = {}
|
||||
return render(request, 'tv.html', context)
|
||||
Loading…
Add table
Add a link
Reference in a new issue