forked from 0x2620/pandora
add smart edit support to backend
This commit is contained in:
parent
c187102b0d
commit
8aafc4f0b9
2 changed files with 23 additions and 10 deletions
|
@ -10,7 +10,7 @@ import subprocess
|
||||||
from urllib import quote
|
from urllib import quote
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
from ox.django.fields import TupleField
|
from ox.django.fields import DictField, TupleField
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
@ -40,6 +40,9 @@ class Edit(models.Model):
|
||||||
description = models.TextField(default='')
|
description = models.TextField(default='')
|
||||||
rightslevel = models.IntegerField(db_index=True, default=0)
|
rightslevel = models.IntegerField(db_index=True, default=0)
|
||||||
|
|
||||||
|
query = DictField(default={"static": True})
|
||||||
|
type = models.CharField(max_length=255, default='static')
|
||||||
|
|
||||||
icon = models.ImageField(default=None, blank=True, null=True,
|
icon = models.ImageField(default=None, blank=True, null=True,
|
||||||
upload_to=lambda i, x: i.path("icon.jpg"))
|
upload_to=lambda i, x: i.path("icon.jpg"))
|
||||||
|
|
||||||
|
@ -164,7 +167,13 @@ class Edit(models.Model):
|
||||||
pos.section = 'personal'
|
pos.section = 'personal'
|
||||||
pos.save()
|
pos.save()
|
||||||
if 'type' in data:
|
if 'type' in data:
|
||||||
self.type = data['type'] == 'pdf' and 'pdf' or 'html'
|
if data['type'] == 'static':
|
||||||
|
self.query = {"static":True}
|
||||||
|
self.type = 'static'
|
||||||
|
else:
|
||||||
|
self.type = 'dynamic'
|
||||||
|
if self.query.get('static', False):
|
||||||
|
self.query = {}
|
||||||
if 'posterFrames' in data:
|
if 'posterFrames' in data:
|
||||||
self.poster_frames = tuple(data['posterFrames'])
|
self.poster_frames = tuple(data['posterFrames'])
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -236,22 +245,22 @@ class Edit(models.Model):
|
||||||
def json(self, keys=None, user=None):
|
def json(self, keys=None, user=None):
|
||||||
if not keys:
|
if not keys:
|
||||||
keys=[
|
keys=[
|
||||||
|
'clips',
|
||||||
'description',
|
'description',
|
||||||
|
'duration',
|
||||||
'editable',
|
'editable',
|
||||||
'rightslevel',
|
|
||||||
'id',
|
'id',
|
||||||
'items',
|
'items',
|
||||||
'clips',
|
|
||||||
'duration',
|
|
||||||
'name',
|
'name',
|
||||||
'posterFrames',
|
'posterFrames',
|
||||||
|
'query',
|
||||||
|
'rightslevel',
|
||||||
'status',
|
'status',
|
||||||
'subscribed',
|
'subscribed',
|
||||||
'user'
|
'type',
|
||||||
|
'user',
|
||||||
]
|
]
|
||||||
response = {
|
response = {}
|
||||||
'type': 'static'
|
|
||||||
}
|
|
||||||
_map = {
|
_map = {
|
||||||
'posterFrames': 'poster_frames'
|
'posterFrames': 'poster_frames'
|
||||||
}
|
}
|
||||||
|
@ -260,6 +269,9 @@ class Edit(models.Model):
|
||||||
response[key] = self.get_id()
|
response[key] = self.get_id()
|
||||||
elif key == 'items':
|
elif key == 'items':
|
||||||
response[key] = self.clips.all().count()
|
response[key] = self.clips.all().count()
|
||||||
|
elif key == 'query':
|
||||||
|
if not self.query.get('static', False):
|
||||||
|
response[key] = self.query
|
||||||
elif key == 'clips':
|
elif key == 'clips':
|
||||||
response[key] = [c.json(user) for c in self.clips.all().order_by('index')]
|
response[key] = [c.json(user) for c in self.clips.all().order_by('index')]
|
||||||
elif key == 'duration':
|
elif key == 'duration':
|
||||||
|
|
|
@ -223,7 +223,8 @@ actions.register(getEdit)
|
||||||
def addEdit(request):
|
def addEdit(request):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name
|
[name],
|
||||||
|
[type]
|
||||||
}
|
}
|
||||||
returns {
|
returns {
|
||||||
id
|
id
|
||||||
|
|
Loading…
Reference in a new issue