merging changes

This commit is contained in:
rlx 2011-06-04 04:38:15 +00:00
commit 5bc3e50aea
8 changed files with 63 additions and 2470 deletions

View file

@ -117,3 +117,4 @@ class Annotation(models.Model):
def __unicode__(self): def __unicode__(self):
return u"%s/%s-%s" %(self.item, self.start, self.end) return u"%s/%s-%s" %(self.item, self.start, self.end)

View file

@ -4,10 +4,12 @@ from __future__ import division, with_statement
from django.db import models from django.db import models
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User, Group
from django.db.models import Q
import ox import ox
from ox.django import fields from ox.django import fields
from annotation.models import Annotation
import managers import managers
@ -34,12 +36,28 @@ class Event(models.Model):
ordering = ('name_sort', ) ordering = ('name_sort', )
#start yyyy-mm-dd|mm-dd|dow 00:00|00:00 #start yyyy-mm-dd|mm-dd|dow 00:00|00:00
#end yyyy-mm-dd|mm-dd|dow 00:00|00:01
start = models.CharField(default='', max_length=255) start = models.CharField(default='', max_length=255)
end = models.CharField(default='', max_length=255)
startTime = models.BigIntegerField(default=0) startTime = models.BigIntegerField(default=0)
#end yyyy-mm-dd|mm-dd|dow 00:00|00:01
end = models.CharField(default='', max_length=255)
endTime = models.BigIntegerField(default=0) endTime = models.BigIntegerField(default=0)
duration = models.CharField(default='', max_length=255)
durationTime = models.BigIntegerField(default=0)
type = models.CharField(default='', max_length=255) type = models.CharField(default='', max_length=255)
matches = models.IntegerField(default=0)
def get_matches(self):
q = Q(value__icontains=" " + self.name)|Q(value__startswith=self.name)
for name in self.alternativeNames:
q = q|Q(value__icontains=" " + name)|Q(value__startswith=name)
return Annotation.objects.filter(q)
def update_matches(self):
self.matches = self.get_matches().count()
self.save()
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.name_sort: if not self.name_sort:
@ -56,7 +74,8 @@ class Event(models.Model):
'user': self.user.username, 'user': self.user.username,
} }
for key in ('created', 'modified', for key in ('created', 'modified',
'name', 'alternativeNames', 'start', 'end', 'name', 'alternativeNames',
'type'): 'start', 'end', 'duration',
'type', 'matches'):
j[key] = getattr(self, key) j[key] = getattr(self, key)
return j return j

View file

@ -464,6 +464,36 @@ def setPoster(request): #parse path and return info
return render_to_json_response(response) return render_to_json_response(response)
actions.register(setPoster, cache=False) actions.register(setPoster, cache=False)
def lookup(request):
'''
param data {
title: string,
director: [string],
year: string,
id: string
}
return {
status: {'code': int, 'text': string},
data: {
title: string,
director: [string],
year: string,
id: string
}
}
'''
data = json.loads(request.POST['data'])
if 'id' in data:
i = models.Item.objects.get(itemId=data['id'])
r = {'id': i.itemId}
for key in ('title', 'director', 'year'):
r[key] = i.get(key)
response = json_response(r)
else:
response = json_response(status=404, text='not found')
return render_to_json_response(response)
actions.register(lookup)
def getImdbId(request): def getImdbId(request):
''' '''
param data { param data {

View file

@ -124,13 +124,14 @@ pandora.reloadList = function() {
}); });
app.$ui.list.bindEvent({ app.$ui.list.bindEvent({
init: function(event, data) { init: function(event, data) {
app.$ui.folderList[listData.status] var folder = listData.status == 'private' ? 'personal' : listData.status;
.value(listData.id, 'items', data.items); app.$ui.folderList[folder].value(listData.id, 'items', data.items);
} }
}) })
.bindEventOnce({ .bindEventOnce({
load: function(event, data) { load: function(event, data) {
app.$ui.list.gainFocus().options({selected: [data.items]}); app.$ui.list.gainFocus();
if (data) app.$ui.list.options({selected: [data.items]});
} }
}) })
.reloadList(); .reloadList();

View file

@ -21,7 +21,7 @@ pandora.ui.info = function() {
) )
.bindEvent({ .bindEvent({
toggle: function(event, data) { toggle: function(event, data) {
UI.set({showInfo: !data.collapsed}); pandora.UI.set({showInfo: !data.collapsed});
pandora.resizeFolders(); pandora.resizeFolders();
} }
}); });

View file

@ -193,10 +193,10 @@ pandora.ui.list = function(view) { // fixme: remove view argument
}); });
}, },
'delete': function(event, data) { 'delete': function(event, data) {
getListData().editable && pandora.api.removeListItems({ pandora.getListData().editable && pandora.api.removeListItems({
list: app.user.ui.list, list: app.user.ui.list,
items: data.ids items: data.ids
}, reloadList); }, pandora.reloadList);
}, },
init: function(event, data) { init: function(event, data) {
app.$ui.total.html(pandora.ui.status('total', data)); app.$ui.total.html(pandora.ui.status('total', data));
@ -317,10 +317,10 @@ pandora.ui.list = function(view) { // fixme: remove view argument
}); });
}, },
paste: function(event, data) { paste: function(event, data) {
data.items && getListData().editable && pandora.api.addListItems({ data.items && pandora.getListData().editable && pandora.api.addListItems({
list: app.user.ui.list, list: app.user.ui.list,
items: data.items items: data.items
}, reloadList); }, pandora.reloadList);
}, },
select: function(event, data) { select: function(event, data) {
var $still, $timeline; var $still, $timeline;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff