From a9165e7230bcb873a721584abf7ae0853f0b6c34 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 18 Oct 2011 11:08:09 +0200 Subject: [PATCH] deselect, make sure target folder exists --- README | 16 ++++++++-------- pandora/item/models.py | 22 +++++++--------------- pandora/item/timelines.py | 6 ++++-- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/README b/README index 02505dec4..83116ded4 100644 --- a/README +++ b/README @@ -5,8 +5,9 @@ To setup a development instance of pan.do/ra, you need python, bazaar, pip and virtualenv and several other python modules: * Packages - apt-get install python-setuptools python-pip python-virtualenv ipython - apt-get install python-dev python-imaging python-numpy python-psycopg2 + apt-get install bzr git subversion mercurial \ + python-setuptools python-pip python-virtualenv ipython \ + python-dev python-imaging python-numpy python-psycopg2 bzr branch http://code.0x2620.org/pandora pandora cd pandora @@ -17,13 +18,12 @@ you need python, bazaar, pip and virtualenv and several other python modules: bzr branch http://code.0x2620.org/oxjs * Additional pandora tools: - You need current versions of mkvtoolnix, oxframe, oxtimeline installed. + You need current versions of oxframe, oxtimeline installed. For Ubuntu we provide these packages in a ppa: - sudo apt-get install python-software-properties - sudo add-apt-repository ppa:j/pandora - sudo add-apt-repository ppa:gstreamer-developers/ppa - sudo apt-get update - sudo apt-get install oxframe oxtimeline mkvtoolnix + apt-get install python-software-properties + add-apt-repository ppa:j/pandora + apt-get update + apt-get install oxframe oxtimeline * Database We use postgresql but other databases might also work diff --git a/pandora/item/models.py b/pandora/item/models.py index 875681c11..40a7bc29b 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -760,8 +760,15 @@ class Item(models.Model): def update_selected(self): for s in self.sets(): if s.filter(Q(is_video=True)|Q(is_audio=True)).filter(available=False).count() == 0: + update = False + deselect = self.files.filter(selected=True).exclude(id__in=s) + if deselect.count() > 0: + deselect.update(selected=False) + update = True if s.filter(selected=False).count() > 0: s.update(selected=True, wanted=False) + update = True + if update: self.rendered = False self.save() self.update_timeline() @@ -1117,18 +1124,3 @@ class Facet(models.Model): self.value_sort = utils.sort_string(self.value) super(Facet, self).save(*args, **kwargs) - -class PosterUrl(models.Model): - - class Meta: - unique_together = ("item", "service", "url") - ordering = ('-height', ) - - item = models.ForeignKey(Item, related_name='poster_urls') - url = models.CharField(max_length=1024) - service = models.CharField(max_length=1024) - width = models.IntegerField(default=80) - height = models.IntegerField(default=128) - - def __unicode__(self): - return u'%s %s %dx%d' % (unicode(self.item), self.service, self.width, self.height) diff --git a/pandora/item/timelines.py b/pandora/item/timelines.py index fa4e70499..3d8af1504 100644 --- a/pandora/item/timelines.py +++ b/pandora/item/timelines.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 - from __future__ import division, with_statement - +import os from glob import glob import Image +import ox + def loadTimeline(timeline_prefix, height=64): files = sorted(glob('%s%sp*.png' % (timeline_prefix, height))) f = Image.open(files[0]) @@ -98,6 +99,7 @@ def join_timelines(timelines, prefix): timeline_name = '%s%sp%04d.png' % (prefix, height, i) timeline.crop((0, 0, pos, height)).save(timeline_name) + ox.makedirs(os.path.dirname(prefix)) makeTiles(prefix, 16, 3600) makeTimelineOverview(prefix, 1920, height=16) makeTimelineOverview(prefix, 1920, height=64)