rename date/access
This commit is contained in:
parent
f2d32a7121
commit
ba2dd341d3
6 changed files with 34 additions and 59 deletions
|
@ -253,35 +253,35 @@
|
|||
"title": "Budget",
|
||||
"type": "integer",
|
||||
"columnWidth": 90,
|
||||
"format": {"type": "currency", "args": ["$", 0]}
|
||||
"format": {"type": "unit", "args": ["$"]}
|
||||
},
|
||||
{
|
||||
"id": "gross",
|
||||
"title": "Gross",
|
||||
"type": "integer",
|
||||
"columnWidth": 90,
|
||||
"format": {"type": "currency", "args": ["$", 0]}
|
||||
"format": {"type": "unit", "args": ["$"]}
|
||||
},
|
||||
{
|
||||
"id": "profit",
|
||||
"title": "Profit",
|
||||
"type": "integer",
|
||||
"columnWidth": 90,
|
||||
"format": {"type": "currency", "args": ["$", 0]}
|
||||
"format": {"type": "unit", "args": ["$"]}
|
||||
},
|
||||
{
|
||||
"id": "rating",
|
||||
"title": "Rating",
|
||||
"type": "float",
|
||||
"columnWidth": 60,
|
||||
"format": {"type": "percent", "args": [10, 2]}
|
||||
"format": {"type": "unit", "args": ["%", 2]}
|
||||
},
|
||||
{
|
||||
"id": "votes",
|
||||
"title": "Votes",
|
||||
"type": "integer",
|
||||
"type": "float",
|
||||
"columnWidth": 60,
|
||||
"format": {"type": "percent", "args": ["auto", 2]}
|
||||
"format": {"type": "unit", "args": ["%", 2]}
|
||||
},
|
||||
{
|
||||
"id": "id",
|
||||
|
@ -418,39 +418,31 @@
|
|||
"find": true
|
||||
},
|
||||
{
|
||||
"id": "published",
|
||||
"title": "Date Published",
|
||||
"id": "created",
|
||||
"title": "Date Created",
|
||||
"type": "date",
|
||||
"columnWidth": 90,
|
||||
"columnWidth": 150,
|
||||
"format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}
|
||||
},
|
||||
{
|
||||
"id": "modified",
|
||||
"title": "Date Modified",
|
||||
"title": "Last Modified",
|
||||
"type": "date",
|
||||
"columnWidth": 90,
|
||||
"columnWidth": 150,
|
||||
"format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}
|
||||
},
|
||||
{
|
||||
"id": "accessed",
|
||||
"title": "Date Accessed",
|
||||
"title": "Last Accessed",
|
||||
"type": "date",
|
||||
"columnWidth": 90,
|
||||
"columnWidth": 150,
|
||||
"format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}
|
||||
},
|
||||
{
|
||||
"id": "viewed",
|
||||
"title": "Date Viewed",
|
||||
"type": "date",
|
||||
"columnWidth": 90,
|
||||
"format": {"type": "date", "args": ["%Y-%m-%d %H:%M:%S"]}
|
||||
},
|
||||
{
|
||||
"id": "popularity",
|
||||
"title": "Popularity",
|
||||
"id": "timesaccessed",
|
||||
"title": "Times Accessed",
|
||||
"type": "integer",
|
||||
"columnWidth": 60,
|
||||
"format": {"type": "percent", "args": ["auto", 2]}
|
||||
"columnWidth": 60
|
||||
},
|
||||
{
|
||||
"id": "rightslevel",
|
||||
|
@ -460,7 +452,7 @@
|
|||
"format": {"type": "ColorLevel", "args": [
|
||||
["Public", "Relaxed", "Regular", "Restricted", "Private"]
|
||||
]},
|
||||
"list": ["Public", "Relaxed", "Regular", "Restricted", "Private"],
|
||||
"list": ["Public", "Relaxed", "Regular", "Restricted", "Private", "Unknown"],
|
||||
"sortOperator": "+"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -57,17 +57,6 @@ def init(request):
|
|||
config = copy.deepcopy(settings.CONFIG)
|
||||
del config['keys'] #is this needed?
|
||||
|
||||
#populate max values for percent requests
|
||||
for key in filter(lambda k: 'format' in k, config['itemKeys']):
|
||||
if key['format']['type'] == 'percent' and key['format']['args'][0] == 'auto':
|
||||
name = key['id']
|
||||
if name == 'popularity':
|
||||
name = 'item__accessed__accessed'
|
||||
value = ItemSort.objects.aggregate(Sum(name))['%s__sum'%name]
|
||||
else:
|
||||
value = ItemSort.objects.aggregate(Max(name))['%s__max'%name]
|
||||
key['format']['args'][0] = value
|
||||
|
||||
response['data']['site'] = config
|
||||
response['data']['user'] = init_user(request.user, request)
|
||||
return render_to_json_response(response)
|
||||
|
|
|
@ -132,7 +132,6 @@ def get_item(info, user=None, async=False):
|
|||
class Item(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
published = models.DateTimeField(default=datetime.now, editable=False)
|
||||
|
||||
user = models.ForeignKey(User, null=True, related_name='items')
|
||||
groups = models.ManyToManyField(Group, blank=True, related_name='items')
|
||||
|
@ -594,6 +593,7 @@ class Item(models.Model):
|
|||
'aspectratio',
|
||||
'bitrate',
|
||||
'clips',
|
||||
'created',
|
||||
'cutsperminute',
|
||||
'duration',
|
||||
'hue',
|
||||
|
@ -604,8 +604,7 @@ class Item(models.Model):
|
|||
'numberoffiles',
|
||||
'parts',
|
||||
'pixels',
|
||||
'popularity',
|
||||
'published',
|
||||
'timesaccessed',
|
||||
'resolution',
|
||||
'rightslevel',
|
||||
'saturation',
|
||||
|
@ -667,7 +666,7 @@ class Item(models.Model):
|
|||
#sort keys based on database, these will always be available
|
||||
s.itemId = self.itemId.replace('0x', 'xx')
|
||||
s.modified = self.modified
|
||||
s.published = self.published
|
||||
s.created = self.created
|
||||
s.rightslevel = self.level
|
||||
|
||||
s.aspectratio = self.get('aspectratio')
|
||||
|
@ -714,7 +713,7 @@ class Item(models.Model):
|
|||
else:
|
||||
s.cutsperminute = None
|
||||
s.wordsperminute = None
|
||||
s.popularity = self.accessed.aggregate(Sum('accessed'))['accessed__sum']
|
||||
s.timesaccessed = self.accessed.aggregate(Sum('accessed'))['accessed__sum']
|
||||
s.save()
|
||||
#update cached values in clips
|
||||
self.clips.all().update(director=s.director, title=s.title)
|
||||
|
|
|
@ -242,8 +242,8 @@ Positions
|
|||
r[p] = value.exists() and value[0].v or None
|
||||
elif p == 'accessed':
|
||||
r[p] = m.a
|
||||
elif p == 'popularity':
|
||||
r[p] = m.sort.popularity
|
||||
elif p == 'timesaccessed':
|
||||
r[p] = m.sort.timesaccessed
|
||||
else:
|
||||
r[p] = m.json.get(p, '')
|
||||
if 'clip_qs' in query:
|
||||
|
@ -260,11 +260,11 @@ Positions
|
|||
return r
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
#response['data']['items'] = [m.get_json(_p) for m in qs]
|
||||
if 'popularity' in _p:
|
||||
qs = qs.annotate(popularity=Sum('accessed__accessed'))
|
||||
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 'popularity' in _p or 'accessed' in _p:
|
||||
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]
|
||||
else:
|
||||
|
|
|
@ -4,21 +4,16 @@
|
|||
|
||||
pandora.ui.filterForm = function(list) {
|
||||
var that = Ox.Filter({
|
||||
findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(key) {
|
||||
return {
|
||||
autocomplete: key.autocomplete,
|
||||
autocompleteSortKey: key.autocompleteSortKey,
|
||||
format: key.format,
|
||||
id: key.id,
|
||||
title: key.title,
|
||||
type: key.type == 'layer'
|
||||
findKeys: Ox.merge(Ox.map(pandora.site.itemKeys, function(itemKey) {
|
||||
var key = Ox.clone(itemKey);
|
||||
key.type = key.type == 'layer'
|
||||
? Ox.getObjectById(pandora.site.layers, key.id).type
|
||||
: key.type
|
||||
};
|
||||
: key.type;
|
||||
return key;
|
||||
}), {
|
||||
id: 'list',
|
||||
title: 'List',
|
||||
type: 'list'
|
||||
type: 'string'
|
||||
}),
|
||||
list: list ? null : {
|
||||
sort: pandora.user.ui.listSort,
|
||||
|
|
|
@ -65,7 +65,7 @@ pandora.ui.list = function() {
|
|||
return {
|
||||
align: ['string', 'text'].indexOf(
|
||||
Ox.isArray(key.type) ? key.type[0]: key.type
|
||||
) > -1 ? 'left' : key.type == 'label' ? 'center' : 'right',
|
||||
) > -1 ? 'left' : key.type == 'list' ? 'center' : 'right',
|
||||
defaultWidth: key.columnWidth,
|
||||
format: key.format,
|
||||
id: key.id,
|
||||
|
|
Loading…
Reference in a new issue