From 7493c8679c8d1a402f7df8717ee03a3c73afb7cf Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 12 Sep 2010 16:23:23 +0200 Subject: [PATCH] movie.mergeWith --- pandora/backend/models.py | 36 ++++++++++++++++++++++++++++++++---- pandora/settings.py | 10 ++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/pandora/backend/models.py b/pandora/backend/models.py index ab7d591ec..936dad3c8 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -160,6 +160,37 @@ class Movie(models.Model): self.updateSort() self.updateFacets() + def delete(self, *args, **kwargs): + self.delete_poster() + for f in glob("%s*"%self.timeline_prefix): + os.unlink(f) + for f in glob("%sstrip*"%self.timeline_prefix[:-8]): + os.unlink(f) + super(Movie, self).delete(*args, **kwargs) + + def mergeWith(self, other): + ''' + move all related tables to other and delete self + ''' + for stream in self.streams.all(): + stream.movie = other + stream.save() + for l in self.lists.all(): + l.movies.remove(self) + if l.movies.filter(id=other.id) == 0: + l.movies.add(other) + #FIXME: should this really happen for layers? + for l in self.layer.all(): + l.movies.remove(self) + if l.movies.filter(id=other.id) == 0: + l.movies.add(other) + if hasattr(self, 'files'): + for f in self.files.all(): + f.movie = other + f.save() + self.delete() + other.save() + ''' JSON cache related functions ''' @@ -455,7 +486,7 @@ class Movie(models.Model): def update_poster_urls(self): _current = {} for s in settings.POSTER_SERVICES: - url = s + '?movieId=' + self.movieId + url = '%s?movieId=%s'%(s, self.movieId) try: data = json.loads(ox.net.readUrlUnicode(url)) except: @@ -529,7 +560,6 @@ class Movie(models.Model): p.wait() return posters.keys() - class MovieFind(models.Model): """ used to search movies, all search values are in here @@ -632,7 +662,6 @@ class MovieSort(models.Model): language_desc = models.TextField(blank=True, db_index=True) - _private_fields = ('id', 'movie') #return available sort fields #FIXME: should return mapping name -> verbose_name @@ -796,7 +825,6 @@ class Collection(models.Model): def editable(self, user): return self.users.filter(id=user.id).count() > 0 - def movieid_path(h): return os.path.join('movie', h[:2], h[2:4], h[4:6], h[6:]) diff --git a/pandora/settings.py b/pandora/settings.py index 7a3bb8667..e1c49bbfd 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -30,10 +30,11 @@ location /protected/ { ADMINS = ( - ('j', 'j@mailb.org'), + #('admin', 'admin@example.com'), ) -DEFAULT_FROM_EMAIL='bot@0xdb.org' +DEFAULT_FROM_EMAIL='admin@' + URL.split('/')[0] +#DEFAULT_FROM_EMAIL='admin@example.com' MANAGERS = ADMINS @@ -44,7 +45,6 @@ DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. -#CACHE_BACKEND = 'memcached://127.0.0.1:11211/' #rabbitmq connection settings CELERY_RESULT_BACKEND = "database" @@ -140,7 +140,6 @@ VIDEO_PROFILE = '96p' VIDEO_DERIVATIVES = [] VIDEO_H264 = True - #Pad.ma #VIDEO_PROFILE = '480p' #VIDEO_DERIVATIVES = ['96p', '270p', '360p'] @@ -156,6 +155,9 @@ TRANSMISSON_PASSWORD='transmission' #list of poster services, https://wiki.0x2620.org/wiki/pandora/posterservice POSTER_SERVICES=[] +#0xdb.org +#POSTER_SERVICES=['http://data.0xdb.org/poster/'] + #overwrite default settings with local settings try: from local_settings import *