From 944378c1df9da64368c6904a74a1f768ad9095d9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 5 Jul 2010 14:07:59 +0200 Subject: [PATCH 1/3] remove dead code --- pandora/backend/models.py | 70 +++++---------------------------------- 1 file changed, 9 insertions(+), 61 deletions(-) diff --git a/pandora/backend/models.py b/pandora/backend/models.py index 6a1f5c6..e34dc15 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -139,6 +139,12 @@ def movie_path(f, size): url_hash = f.movieId return os.path.join('movie', url_hash[:2], url_hash[2:4], url_hash[4:6], name) +def poster_path(f): + name = "%s.%s" % (f.movieId, 'jpg') + url_hash = f.movieId + return os.path.join('poster', url_hash[:2], url_hash[2:4], url_hash[4:6], name) + + class Movie(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) @@ -242,51 +248,9 @@ class Movie(models.Model): q = q | Q(url__contains=w.url) return self.reviews_all.filter(q).filter(manual=False) - ''' - #these values get populated with imdb/oxdb values on save() - #edits will be overwritten - title = models.CharField(max_length=1000) - year = models.CharField(max_length=4) - runtime = models.IntegerField(null=True, blank=True) - release_date = models.DateField(null=True, blank=True) - tagline = models.TextField(blank=True) - plot = models.TextField(blank=True) - plot_outline = models.TextField(blank=True) - - rating = models.FloatField(null=True, blank=True) - votes = models.IntegerField(null=True, blank=True) - - budget = models.IntegerField(null=True, blank=True) - gross = models.IntegerField(null=True, blank=True) - profit = models.IntegerField(null=True, blank=True) - - series_imdb = models.CharField(max_length=7, default='') - series_title = models.TextField(blank=True, default='') - episode_title = models.TextField(blank=True, default='') - season = models.IntegerField(default=-1) - episode = models.IntegerField(default=-1) - ''' json = fields.DictField(default={}, editable=False) - ''' - directors = fields.TupleField(default=()) - writers = fields.TupleField(default=()) - editors = fields.TupleField(default=()) - producers = fields.TupleField(default=()) - cinematographers = fields.TupleField(default=()) - cast = fields.TupleField(default=()) - alternative_titles = fields.TupleField(default=()) - genres = fields.TupleField(default=()) - keywords = fields.TupleField(default=()) - countries = fields.TupleField(default=()) - languages = fields.TupleField(default=()) - trivia = fields.TupleField(default=()) - locations = fields.TupleField(default=()) - connections = fields.DictField(default={}) - reviews = fields.TupleField(default=()) - ''' - #FIXME: use data.0xdb.org ''' tpb_id = models.CharField(max_length=128, blank=True) @@ -300,6 +264,7 @@ class Movie(models.Model): poster = models.TextField(blank=True) posters_disabled = models.TextField(blank=True) posters_available = models.TextField(blank=True) + poster = models.ImageField(default=None, blank=True, upload_to=poster_path) ''' poster_height = models.IntegerField(default=0) poster_width = models.IntegerField(default=0) @@ -329,24 +294,7 @@ class Movie(models.Model): if self.id: self.json = self.get_json() - ''' - #populate auto values for faster results - #FIXME: why is it not possible to use setattr to set List instead of db value? - common_fields = [f.name for f in MovieImdb._meta.fields] - only_relevant = lambda f: f not in ('id', 'created', 'modified', 'imdbId') - common_fields = filter(only_relevant, common_fields) - for f in common_fields: - setattr(self, f, self.get(f)) - for f in ('directors', 'writers', 'editors', 'producers', 'cinematographers', - 'reviews', 'countries', 'languages', - 'keywords', 'genres', 'trivia', 'alternative_titles'): - value = getattr(self, 'get_' + f) - setattr(self, f, tuple([v.json() for v in value()])) - for f in ('cast', ): - value = getattr(self, 'get_' + f) - setattr(self, f, value()) - self.connections = self.connections_json() - ''' + super(Movie, self).save(*args, **kwargs) self.updateFind() self.updateSort() @@ -398,7 +346,7 @@ class Movie(models.Model): if fields: for f in fields: if f.endswith('.length') and f[:-7] in ('cast', 'genre', 'trivia'): - movie[f] = getattr(self.sort.all()[0], f[:-7]) + movie[f] = getattr(self.sort, f[:-7]) return movie def fields(self): From e0d7b59cbb862d8bcf1fe5d6022666612391e2f3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 5 Jul 2010 14:35:51 +0200 Subject: [PATCH 2/3] remove autocomplete --- pandora/static/js/pandora.js | 53 ++---------------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index d35a967..a89afa6 100644 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -1,6 +1,6 @@ $(function(){ Ox.debug = Ox.print; - Ox.print = function() {}; + //Ox.print = function() {}; Ox.theme("modern"); app = new Ox.App({ @@ -49,54 +49,7 @@ $(function(){ .css({ marginLeft: "4px" }); - app.menu = new Ox.MainMenu({ - extras: [ - new Ox.Input({ - autocomplete: function(option, value, callback) { - var field = option.substring(6).toLowerCase(); - if(typeof(callback) == 'undefined') { - callback = value; - value = null; - } - Ox.debug('app.menu.find.autocomplete: option: ', option, 'value: ', value, ', callback:',callback); - Ox.debug('app.menu.find.autocomplete: field: ', field); - if(field == 'all') { - callback([]); - } else if (value) { - value = value.toLowerCase(); - //var order = $.inArray(field, ['year', 'date'])?'-':''; - app.request('find', { - query: { - conditions: [ - { - key: field, - value: value, - operator: '~' - } - ] - }, - list: 'all', - sort: [{key:field, operator: ''}], - keys: [field], - range: [0, 10] - }, function(result) { - var items = $.map( - result.data.items, - function(item, i) { return item.title; } - ); - callback(items); - }); - } - }, - clear: true, - highlight: false, - id: "find", - label: ["Find: Title", "Find: All", "Find: Director", "Find: Country", "Find: Cinematographer"], - labelWidth: 96 - }).width(320), - loadingIcon - ], menus: [ { id: "pandoraMM", @@ -314,6 +267,7 @@ $(function(){ app.menu.bindEvent('click_logout', function(event, data) { app.logout(); }); + app.menu.bindEvent('click_login', function(element) { var labelWidth = 64; var inputWidth = labelWidth+200; @@ -390,7 +344,6 @@ $(function(){ .append(d) .open(); }); - var bottomPanel = Ox.Toolbar({size: "small"}) .css({ zIndex: 2, @@ -497,7 +450,7 @@ $(function(){ }] }).appendTo(content); - app.bindEvent('submit_find', function(event, data) { + app.menu.bindEvent('submit_find', function(event, data) { app.results.options({ request: function(options) { app.request("find", $.extend(options, { From 1aeda255eb7db2edae2cd27cab71521a1d826415 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 5 Jul 2010 14:38:01 +0200 Subject: [PATCH 3/3] merge working version --- pandora/static/js/pandora.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index c38a306..0a480aa 100644 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -1,6 +1,6 @@ $(function(){ Ox.debug = Ox.print; - Ox.print = function() {}; + //Ox.print = function() {}; Ox.theme("modern"); app = new Ox.App({