forked from 0x2620/pandora
tweak clip table
This commit is contained in:
parent
60c1ecf399
commit
950b6533b0
6 changed files with 24 additions and 12 deletions
|
|
@ -204,10 +204,13 @@ class ClipManager(Manager):
|
|||
#anonymous can only see public clips
|
||||
if not user or user.is_anonymous():
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
qs = qs.filter(item__level__lte=allowed_level)
|
||||
qs = qs.filter(sort__rightslevel__lte=allowed_level)
|
||||
#users can see public clips, there own clips and clips of there groups
|
||||
else:
|
||||
allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()]
|
||||
qs = qs.filter(Q(item__level__lte=allowed_level)|Q(item__user=user)|Q(item__groups__in=user.groups.all()))
|
||||
q = Q(sort__rightslevel__lte=allowed_level)|Q(user=user.id)
|
||||
if user.groups.count():
|
||||
q |= Q(item__groups__in=user.groups.all())
|
||||
qs = qs.filter(q)
|
||||
#admins can see all available clips
|
||||
return qs
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ class MetaClip:
|
|||
else:
|
||||
self.hue = self.saturation = self.lightness = 0
|
||||
self.volume = 0
|
||||
self.director = self.item.sort.director
|
||||
self.title = self.item.sort.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.public_id = u"%s/%s-%s" %(self.item.itemId, float(self.start), float(self.end))
|
||||
|
|
@ -35,6 +33,9 @@ class MetaClip:
|
|||
streams = self.item.streams()
|
||||
if streams:
|
||||
self.aspect_ratio = streams[0].aspect_ratio
|
||||
if self.item:
|
||||
self.user = self.item.user and self.item.user.id
|
||||
self.sort = self.item.sort
|
||||
if self.id:
|
||||
sortvalue = ''
|
||||
if self.id:
|
||||
|
|
@ -115,6 +116,8 @@ attrs = {
|
|||
'aspect_ratio': models.FloatField(default=0),
|
||||
|
||||
'item': models.ForeignKey('item.Item', related_name='clips'),
|
||||
'sort': models.ForeignKey('item.ItemSort', related_name='clips'),
|
||||
'user': models.IntegerField(db_index=True, null=True),
|
||||
|
||||
#seconds
|
||||
'start': models.FloatField(default=-1, db_index=True),
|
||||
|
|
@ -128,8 +131,6 @@ attrs = {
|
|||
'lightness': models.FloatField(default=0, db_index=True),
|
||||
'volume': models.FloatField(default=0, null=True, db_index=True),
|
||||
|
||||
'director': models.CharField(max_length=1000, null=True, db_index=True),
|
||||
'title': models.CharField(max_length=1000, db_index=True),
|
||||
'sortvalue': models.CharField(max_length=1000, null=True, db_index=True),
|
||||
'findvalue': models.TextField(null=True),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ def order_query(qs, sort):
|
|||
operator = ''
|
||||
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume',
|
||||
'duration', 'sortvalue', 'videoRatio',
|
||||
'director', 'title',
|
||||
'random__random')
|
||||
key = {
|
||||
'id': 'public_id',
|
||||
|
|
@ -60,7 +59,7 @@ def order_query(qs, sort):
|
|||
}.get(key, key)
|
||||
elif key not in clip_keys:
|
||||
#key mgith need to be changed, see order_sort in item/views.py
|
||||
key = "item__sort__%s" % key
|
||||
key = "sort__%s" % key
|
||||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
if order_by:
|
||||
|
|
@ -94,7 +93,7 @@ def findClips(request):
|
|||
keys = filter(lambda k: k not in settings.CONFIG['clipLayers'] + ['annotations'],
|
||||
data['keys'])
|
||||
if filter(lambda k: k not in models.Clip.clip_keys, keys):
|
||||
qs = qs.select_related('item__sort')
|
||||
qs = qs.select_related('sort')
|
||||
|
||||
def add(p):
|
||||
ids.append(p.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue