events and places

This commit is contained in:
j 2011-09-28 03:40:36 +02:00
parent ce8656ef53
commit 6f0393d12c
4 changed files with 150 additions and 23 deletions

View file

@ -20,6 +20,7 @@ def parseCondition(condition, user):
k = { k = {
'user': 'user__username', 'user': 'user__username',
'place': 'places__id', 'place': 'places__id',
'event': 'events__id',
}.get(k, k) }.get(k, k)
if not k: if not k:
k = 'name' k = 'name'
@ -41,12 +42,12 @@ def parseCondition(condition, user):
return q return q
if k == 'id': if k == 'id':
v = ox.from32(v.split('/')[-1]) v = ox.from32(v.split('/')[-1])
elif k in ('places__id', ): elif k in ('places__id', 'events__id'):
v = ox.from32(v) v = ox.from32(v)
if isinstance(v, bool): #featured and public flag if isinstance(v, bool): #featured and public flag
key = k key = k
elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches', elif k in ('lat', 'lng', 'area', 'south', 'west', 'north', 'east', 'matches',
'id', 'places__id'): 'id', 'places__id', 'events__id'):
key = "%s%s" % (k, { key = "%s%s" % (k, {
'>': '__gt', '>': '__gt',
'>=': '__gte', '>=': '__gte',

View file

@ -51,6 +51,7 @@ class Event(models.Model):
matches = models.IntegerField(default=0) matches = models.IntegerField(default=0)
items = models.ManyToManyField(Item, blank=True, related_name='events') items = models.ManyToManyField(Item, blank=True, related_name='events')
annotations = models.ManyToManyField(Annotation, blank=True, related_name='events')
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@ -64,6 +65,10 @@ class Event(models.Model):
def update_matches(self): def update_matches(self):
matches = self.get_matches() matches = self.get_matches()
self.matches = matches.count() self.matches = matches.count()
for i in self.annotations.exclude(id__in=matches):
self.annotations.remove(i)
for i in matches.exclude(id__in=self.annotations.all()):
self.annotations.add(i)
ids = list(set([a.item.id for a in matches])) ids = list(set([a.item.id for a in matches]))
for i in self.items.exclude(id__in=ids): for i in self.items.exclude(id__in=ids):
self.items.remove(i) self.items.remove(i)

View file

@ -39,6 +39,7 @@ pandora.ui.item = function() {
); );
} else if (pandora.user.ui.itemView == 'calendar') { } else if (pandora.user.ui.itemView == 'calendar') {
var video = result.data.stream;
pandora.api.findEvents({ pandora.api.findEvents({
itemQuery: {conditions: [{key: 'id', value: pandora.user.ui.item, operator:'='}]}, itemQuery: {conditions: [{key: 'id', value: pandora.user.ui.item, operator:'='}]},
keys: ['id', 'name', 'start', 'end'], keys: ['id', 'name', 'start', 'end'],
@ -55,10 +56,68 @@ pandora.ui.item = function() {
range: [-5000, 5000], range: [-5000, 5000],
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE, width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
zoom: 4 zoom: 4
}).bindEvent({
select: function(event) {
pandora.$ui.clips.options({
items: function(data, callback) {
pandora.api.findAnnotations(Ox.extend(data, {
query: {
conditions:[{
key: 'event',
value: event.id,
operator:'=='
}]
},
itemQuery: {conditions: [{
key: 'id',
value: pandora.user.ui.item,
operator: '=='
}]}
}), callback);
}
});
}
}) })
}, },
{ {
element: Ox.Element(), element: Ox.Element(),
element: pandora.$ui.clips = Ox.IconList({
fixedRatio: video.aspectRatio,
item: function(data, sort, size) {
size = size || 128;
var width = size,
height = Math.round(size / video.aspectRatio),
itemId = data.id.split('/')[0],
url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg';
return {
height: height,
id: data['id'],
info: Ox.formatDuration(data['in'], 'short') +' - '+ Ox.formatDuration(data['out'], 'short'),
title: data.value,
url: url,
width: width
};
},
items: [],
keys: ['id', 'value', 'in', 'out'],
size: 128,
sort: pandora.user.ui.itemSort,
unique: 'id'
}).bindEvent({
open: function(data) {
var id = data.ids[0],
item = pandora.user.ui.item,
points = {
'in': pandora.$ui.clips.value(id, 'in'),
out: pandora.$ui.clips.value(id, 'out')
};
pandora.UI.set('videoPoints.' + item, Ox.extend(points, {
position: points['in']
}));
pandora.UI.set('itemView', 'timeline');
}
}),
id: 'place', id: 'place',
size: 144 + Ox.UI.SCROLLBAR_SIZE size: 144 + Ox.UI.SCROLLBAR_SIZE
} }
@ -449,18 +508,22 @@ pandora.ui.item = function() {
toolbar: true, toolbar: true,
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE
}).bindEvent({ }).bindEvent({
selectplace: function(event, place) { selectplace: function(place) {
if(place) { if(place) {
pandora.$ui.clips.options({ pandora.$ui.clips.options({
items: function(data, callback) { items: function(data, callback) {
return pandora.api.findAnnotations(Ox.extend(data, { return pandora.api.findAnnotations(Ox.extend(data, {
query: { query: {
conditions:[{key: 'place', value: place.id, operator:'='}] conditions:[{
key: 'place',
value: place.id,
operator:'=='
}]
}, },
itemQuery: {conditions: [{ itemQuery: {conditions: [{
key: 'id', key: 'id',
value: pandora.user.ui.item, value: pandora.user.ui.item,
operator: '=' operator: '=='
}]} }]}
}), callback); }), callback);
} }
@ -478,10 +541,11 @@ pandora.ui.item = function() {
fixedRatio: video.aspectRatio, fixedRatio: video.aspectRatio,
item: function(data, sort, size) { item: function(data, sort, size) {
size = size || 128; size = size || 128;
var ratio = data.aspectRatio, Ox.print('DATA', data);
width = size, var width = size,
height = Math.round(size / ratio), height = Math.round(size / video.aspectRatio),
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg'; itemId = data.id.split('/')[0],
url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg';
return { return {
height: height, height: height,
id: data['id'], id: data['id'],
@ -492,7 +556,7 @@ pandora.ui.item = function() {
}; };
}, },
items: [], items: [],
keys: ['id', 'value', 'in', 'out', 'aspectRatio', 'item'], keys: ['id', 'value', 'in', 'out'],
size: 128, size: 128,
sort: pandora.user.ui.itemSort, sort: pandora.user.ui.itemSort,
unique: 'id' unique: 'id'
@ -507,7 +571,7 @@ pandora.ui.item = function() {
pandora.UI.set('videoPoints.' + item, Ox.extend(points, { pandora.UI.set('videoPoints.' + item, Ox.extend(points, {
position: points['in'] position: points['in']
})); }));
pandora.URL.set(item + '/timeline'); pandora.UI.set('itemView', 'timeline');
} }
}), }),
id: 'place', id: 'place',

View file

@ -422,13 +422,16 @@ pandora.ui.list = function() {
toolbar: true, toolbar: true,
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE, width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
}).bindEvent({ }).bindEvent({
selectplace: function(event, place) { selectplace: function(place) {
if(place && place.id[0] != '_') { if(place && place.id[0] != '_') {
pandora.$ui.clips.options({ pandora.$ui.clips.options({
items: function(data, callback) { items: function(data, callback) {
return pandora.api.findAnnotations(Ox.extend(data, { return pandora.api.findAnnotations(Ox.extend(data, {
query: { query: {
conditions:[{key: 'place', value: place.id, operator:'='}] conditions:[{key: 'place',
value: place.id,
operator:'=='
}]
}, },
itemQuery: pandora.user.ui.find itemQuery: pandora.user.ui.find
}), callback); }), callback);
@ -446,11 +449,11 @@ pandora.ui.list = function() {
element: pandora.$ui.clips = Ox.IconList({ element: pandora.$ui.clips = Ox.IconList({
fixedRatio: fixedRatio, fixedRatio: fixedRatio,
item: function(data, sort, size) { item: function(data, sort, size) {
Ox.print('RATIO', data.videoRatio);
size = size || 128; size = size || 128;
var width = data.videoRatio < fixedRatio ? size : size * data.videoRatio / fixedRatio, var width = data.videoRatio < fixedRatio ? size : size * data.videoRatio / fixedRatio,
height = width / data.videoRatio, height = Math.round(width / data.videoRatio),
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg'; itemId = data.id.split('/')[0],
url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg';
return { return {
height: height, height: height,
id: data.id, id: data.id,
@ -462,7 +465,7 @@ pandora.ui.list = function() {
}; };
}, },
items: [], items: [],
keys: ['id', 'value', 'in', 'out', 'videoRatio', 'item'], keys: ['id', 'value', 'in', 'out', 'videoRatio'],
size: 128, size: 128,
sort: pandora.user.ui.listSort, sort: pandora.user.ui.listSort,
unique: 'id' unique: 'id'
@ -477,10 +480,10 @@ pandora.ui.list = function() {
pandora.UI.set('videoPoints.' + item, Ox.extend(points, { pandora.UI.set('videoPoints.' + item, Ox.extend(points, {
position: points['in'] position: points['in']
})); }));
pandora.URL.set(item + '/timeline'); pandora.UI.set('itemView', 'timeline');
} }
}), }),
id: 'place', id: 'clips',
size: 144 + Ox.UI.SCROLLBAR_SIZE size: 144 + Ox.UI.SCROLLBAR_SIZE
} }
], ],
@ -490,14 +493,52 @@ pandora.ui.list = function() {
pandora.$ui.map.resizeMap(); pandora.$ui.map.resizeMap();
}); });
} else if (view == 'calendar') { } else if (view == 'calendar') {
var fixedRatio = 16/9;
that = Ox.SplitPanel({ that = Ox.SplitPanel({
elements: [ elements: [
{ {
element: pandora.$ui.calendar = Ox.Element() element: pandora.$ui.calendar = Ox.Element()
}, },
{ {
element: Ox.Element(), element: pandora.$ui.clips = Ox.IconList({
id: 'place', fixedRatio: fixedRatio,
item: function(data, sort, size) {
size = size || 128;
var width = data.videoRatio < fixedRatio ? size : size * data.videoRatio / fixedRatio,
height = Math.round(width / data.videoRatio),
itemId = data.id.split('/')[0],
url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg';
Ox.print(data.videoRatio, size, fixedRatio, width, height);
return {
height: height,
id: data.id,
info: Ox.formatDuration(data['in'], 'short') + ' - '
+ Ox.formatDuration(data['out'], 'short'),
title: data.value,
url: url,
width: width
};
},
items: [],
keys: ['id', 'value', 'in', 'out', 'videoRatio'],
size: 128,
sort: pandora.user.ui.listSort,
unique: 'id'
}).bindEvent({
open: function(data) {
var id = data.ids[0],
item = pandora.$ui.clips.value(id, 'item'),
points = {
'in': pandora.$ui.clips.value(id, 'in'),
out: pandora.$ui.clips.value(id, 'out')
};
pandora.UI.set('videoPoints.' + item, Ox.extend(points, {
position: points['in']
}));
pandora.UI.set('itemView', 'timeline');
}
}),
id: 'clips',
size: 144 + Ox.UI.SCROLLBAR_SIZE size: 144 + Ox.UI.SCROLLBAR_SIZE
} }
], ],
@ -518,6 +559,22 @@ pandora.ui.list = function() {
range: [-5000, 5000], range: [-5000, 5000],
width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE, width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE,
zoom: 4 zoom: 4
}).bindEvent({
select: function(event) {
pandora.$ui.clips.options({
items: function(data, callback) {
return pandora.api.findAnnotations(Ox.extend(data, {
query: {
conditions:[{key: 'event',
value: event.id,
operator:'=='
}]
},
itemQuery: pandora.user.ui.find
}), callback);
}
});
}
})); }));
}); });
} else { } else {
@ -574,7 +631,7 @@ pandora.ui.list = function() {
return { return {
key: 'id', key: 'id',
value: id, value: id,
operator: '=' operator: '=='
} }
}), }),
operator: '|' operator: '|'
@ -662,7 +719,7 @@ pandora.ui.list = function() {
return { return {
key: 'id', key: 'id',
value: id, value: id,
operator: '=' operator: '=='
} }
}), }),
operator: '|' operator: '|'