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