This commit is contained in:
j 2011-01-29 16:49:11 +05:30
parent d172ef85e2
commit b888983fcb
3 changed files with 100 additions and 19 deletions

View file

@ -229,7 +229,8 @@ class File(models.Model):
'name': self.name,
'size': self.size,
'info': self.info,
'instances': self.instances.count()
'instances': self.instances.count(),
'is_main': self.is_main
}
if keys:
for k in data.keys():

View file

@ -14,7 +14,7 @@ from ox.django.decorators import login_required_json
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
from ox.django.views import task_status
from item.utils import parse_path
from item import utils
from item.models import get_item
from item.views import _parse_query
import item.tasks
@ -244,7 +244,7 @@ def editFile(request):
if f.item.id != data['itemId']:
if len(data['itemId']) != 7:
folder = f.instances.all()[0].folder
item_info = parse_path(folder)
item_info = utils.parse_path(folder)
item = get_item(item_info)
else:
item = get_item({'imdbId': data['itemId']})
@ -419,27 +419,14 @@ Positions
elif 'keys' in query:
response['data']['items'] = []
qs = models.File.objects.filter(item__in=query['qs'])
qs = _order_query(qs, query['sort'])
#qs = _order_query(qs, query['sort'])
keys = query['keys']
qs = qs[query['range'][0]:query['range'][1]]
response['data']['items'] = [f.json(keys) for f in qs]
else: # otherwise stats
items = query['qs']
files = models.File.objects.filter(item__in=query['qs'])
#files = models.File.objects.all().filter(item__in=items).exclude(size__gt=0)
r = files.aggregate(
Sum('duration'),
Sum('pixels'),
Sum('size')
)
response['data']['duration'] = r['duration__sum']
response['data']['files'] = files.count()
response['data']['items'] = items.count()
response['data']['pixels'] = r['pixels__sum']
response['data']['runtime'] = items.filter(sort__runtime_desc__gt=0).aggregate(Sum('sort__runtime_desc'))['sort__runtime_desc__sum']
if response['data']['runtime'] == None:
response['data']['runtime'] = 0
response['data']['size'] = r['size__sum']
response['data']['items'] = files.count()
return render_to_json_response(response)
actions.register(findFiles)

View file

@ -1691,7 +1691,7 @@ var pandora = new Ox.App({
},
item: function() {
var that;
if (app.user.ui.itemView == 'info') {
if (app.user.ui.itemView == 'info' || app.user.ui.itemView == 'files') {
that = new Ox.Element('div');
} else if (app.user.ui.itemView == 'player') {
that = new Ox.Element('div');
@ -1818,6 +1818,99 @@ var pandora = new Ox.App({
});
});
*/
} else if (app.user.ui.itemView == 'files') {
app.$ui.contentPanel.replace(1,
app.$ui.item = new Ox.TextList({
columns: [
{
align: "left",
id: "name",
operator: "+",
title: "Name",
unique: true,
visible: true,
width: 400
},
{
align: "left",
id: "oshash",
operator: "+",
title: "oshash",
visible: true,
width: 120
},
{
align: "left",
id: "instances",
operator: "+",
title: "Instances",
visible: true,
width: 60
},
{
align: "left",
id: "width",
operator: "+",
title: "Width",
visible: true,
width: 60
},
{
align: "left",
id: "height",
operator: "+",
title: "Height",
visible: true,
width: 60
},
{
align: "left",
id: "duration",
operator: "+",
title: "Duration",
visible: true,
width: 80,
format: {type: "duration", args: [0, "medium"]}
},
{
align: "left",
id: "size",
operator: "+",
title: "Size",
visible: true,
width: 80,
format: {type: "value", args: ["B"]}
},
{
align: "left",
id: "is_main",
operator: "+",
title: "Main",
visible: true,
width: 140
}
],
columnsMovable: true,
columnsRemovable: true,
columnsResizable: true,
columnsVisible: true,
id: 'files',
request: function(data, callback) {
//Ox.print('data, Query.toObject', data, Query.toObject())
pandora.api.findFiles($.extend(data, {
query: {
conditions: [{
key: 'id',
value: result.data.item.id,
operator: '='
}]
}
}), callback);
},
scrollbarVisible: true,
sort: [{key: 'name', operator:'+'}]
})
);
}
app.$ui.total.html(result.data.item.title + ' (' + result.data.item.director.join(', ') + ')')
});