filter/sort

This commit is contained in:
j 2022-01-27 14:42:48 +00:00
commit 097d64a2ce
7 changed files with 78 additions and 19 deletions

View file

@ -24,7 +24,7 @@ class Command(BaseCommand):
keys = [
'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
'country', 'type',
'country', 'type', 'year',
'duration', 'featuring', 'cinematographer',
'hue', 'saturation', 'lightness',
'folder', 'folderdescription', 'rightslevel'
@ -50,6 +50,7 @@ class Command(BaseCommand):
folders[item['folder']] = {
'title': item['folder'],
'date': item.get('date', ''),
'year': item.get('year', ''),
'country': item.get('country', []),
'featuring': item.get('featuring', []),
'type': item['type'],

View file

@ -37,6 +37,12 @@ class Film(models.Model):
if folder:
return Text.objects.filter(Q(data__folder=folder) | Q(data__related=folder))
def duration_seconds(self):
duration = 0
for item in self.data.get('items', []):
duration += item['duration']
return duration
def duration(self):
return ox.format_duration(self.data['duration'] * 1000, verbosity=1, milliseconds=False)

View file

@ -1,5 +1,6 @@
import logging
import json
from collections import Counter
from django.shortcuts import render, redirect, get_object_or_404
from django.views.decorators.csrf import csrf_exempt
@ -56,6 +57,16 @@ def get_stream_prefix(request):
def films(request):
context = {}
context['films'] = models.Film.objects.filter(public=True).order_by('position', 'data__title')
types = []
for f in context['films']:
types += f.data['type']
types = Counter(types)
context['types'] = []
for t in sorted(types):
context['types'].append({
'title': '%s (%s)' % (t, types[t]), 'value': t
})
context['stream_prefix'] = get_stream_prefix(request)
context['settings'] = settings
return render(request, 'films.html', context)