merge
This commit is contained in:
commit
2f01ab0aa2
4 changed files with 8 additions and 19 deletions
|
@ -14,7 +14,7 @@ import unicodedata
|
|||
from urllib import quote
|
||||
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Count, Q, Sum
|
||||
from django.db.models import Count, Q, Sum, Max
|
||||
from django.core.files.base import ContentFile
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User, Group
|
||||
|
@ -605,6 +605,7 @@ class Item(models.Model):
|
|||
'parts',
|
||||
'pixels',
|
||||
'timesaccessed',
|
||||
'accessed',
|
||||
'resolution',
|
||||
'width',
|
||||
'height',
|
||||
|
@ -720,6 +721,7 @@ class Item(models.Model):
|
|||
s.timesaccessed = self.accessed.aggregate(Sum('accessed'))['accessed__sum']
|
||||
if not s.timesaccessed:
|
||||
s.timesaccessed = 0
|
||||
s.accessed = self.accessed.aggregate(Max('access'))['access__max']
|
||||
s.save()
|
||||
#update cached values in clips
|
||||
self.clips.all().update(director=s.director, title=s.title)
|
||||
|
@ -1208,7 +1210,7 @@ class Access(models.Model):
|
|||
self.accessed += 1
|
||||
super(Access, self).save(*args, **kwargs)
|
||||
timesaccessed = Access.objects.filter(item=self.item).aggregate(Sum('accessed'))['accessed__sum']
|
||||
ItemSort.objects.filter(item=self.item).update(timesaccessed=timesaccessed)
|
||||
ItemSort.objects.filter(item=self.item).update(timesaccessed=timesaccessed, accessed=self.access)
|
||||
|
||||
def __unicode__(self):
|
||||
if self.user:
|
||||
|
|
|
@ -52,9 +52,8 @@ def _order_query(qs, sort, prefix='sort__'):
|
|||
operator = ''
|
||||
key = {
|
||||
'id': 'itemId',
|
||||
'accessed': 'accessed__access',
|
||||
}.get(e['key'], e['key'])
|
||||
if key not in ('accessed__access', 'accessed__accessed'):
|
||||
if key not in ('itemId', ):
|
||||
key = "%s%s" % (prefix, key)
|
||||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
|
@ -237,9 +236,9 @@ Positions
|
|||
r = {}
|
||||
for p in _p:
|
||||
if p == 'accessed':
|
||||
r[p] = m.a
|
||||
r[p] = m.sort.accessed or ''
|
||||
elif p == 'timesaccessed':
|
||||
r[p] = m.timesaccessed
|
||||
r[p] = m.sort.timesaccessed
|
||||
else:
|
||||
r[p] = m.json.get(p, '')
|
||||
if 'clip_qs' in query:
|
||||
|
@ -256,10 +255,6 @@ Positions
|
|||
return r
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
#response['data']['items'] = [m.get_json(_p) for m in qs]
|
||||
if 'timesaccessed' in _p:
|
||||
qs = qs.annotate(timesaccessed=Sum('accessed__accessed'))
|
||||
if 'accessed' in _p:
|
||||
qs = qs.annotate(a=Max('accessed__access'))
|
||||
if 'viewed' in _p or 'timesaccessed' in _p or 'accessed' in _p:
|
||||
qs = qs.select_related()
|
||||
response['data']['items'] = [only_p_sums(m) for m in qs]
|
||||
|
|
|
@ -4,18 +4,10 @@
|
|||
<title>{{settings.SITENAME}}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/png/icon16.png"/>
|
||||
<meta name="application-name" content="{{settings.SITENAME}}"/>
|
||||
<link rel="icon" href="/static/png/icon64.png" sizes="32x32"/>
|
||||
<link rel="icon" href="/static/png/icon64.png" sizes="48x48"/>
|
||||
<meta name="application-name" content="{{settings.SITENAME}}"/>
|
||||
<meta name="application-url" content="{{base_url}}"/>
|
||||
<script type='text/javascript'>
|
||||
if (typeof(console) == 'undefined') {
|
||||
console = {
|
||||
log: function() {}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="/static/oxjs/build/Ox.js"></script>
|
||||
<script type="text/javascript" src="/static/js/pandora.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -426,7 +426,7 @@ pandora.ui.list = function() {
|
|||
key: 'id',
|
||||
value: id,
|
||||
operator: '=='
|
||||
}
|
||||
};
|
||||
}),
|
||||
operator: '|'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue