movie.mergeWith
This commit is contained in:
parent
966c5d435a
commit
7493c8679c
2 changed files with 38 additions and 8 deletions
|
@ -160,6 +160,37 @@ class Movie(models.Model):
|
||||||
self.updateSort()
|
self.updateSort()
|
||||||
self.updateFacets()
|
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
|
JSON cache related functions
|
||||||
'''
|
'''
|
||||||
|
@ -455,7 +486,7 @@ class Movie(models.Model):
|
||||||
def update_poster_urls(self):
|
def update_poster_urls(self):
|
||||||
_current = {}
|
_current = {}
|
||||||
for s in settings.POSTER_SERVICES:
|
for s in settings.POSTER_SERVICES:
|
||||||
url = s + '?movieId=' + self.movieId
|
url = '%s?movieId=%s'%(s, self.movieId)
|
||||||
try:
|
try:
|
||||||
data = json.loads(ox.net.readUrlUnicode(url))
|
data = json.loads(ox.net.readUrlUnicode(url))
|
||||||
except:
|
except:
|
||||||
|
@ -529,7 +560,6 @@ class Movie(models.Model):
|
||||||
p.wait()
|
p.wait()
|
||||||
return posters.keys()
|
return posters.keys()
|
||||||
|
|
||||||
|
|
||||||
class MovieFind(models.Model):
|
class MovieFind(models.Model):
|
||||||
"""
|
"""
|
||||||
used to search movies, all search values are in here
|
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)
|
language_desc = models.TextField(blank=True, db_index=True)
|
||||||
|
|
||||||
|
|
||||||
_private_fields = ('id', 'movie')
|
_private_fields = ('id', 'movie')
|
||||||
#return available sort fields
|
#return available sort fields
|
||||||
#FIXME: should return mapping name -> verbose_name
|
#FIXME: should return mapping name -> verbose_name
|
||||||
|
@ -796,7 +825,6 @@ class Collection(models.Model):
|
||||||
def editable(self, user):
|
def editable(self, user):
|
||||||
return self.users.filter(id=user.id).count() > 0
|
return self.users.filter(id=user.id).count() > 0
|
||||||
|
|
||||||
|
|
||||||
def movieid_path(h):
|
def movieid_path(h):
|
||||||
return os.path.join('movie', h[:2], h[2:4], h[4:6], h[6:])
|
return os.path.join('movie', h[:2], h[2:4], h[4:6], h[6:])
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,11 @@ location /protected/ {
|
||||||
|
|
||||||
|
|
||||||
ADMINS = (
|
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
|
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_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
|
||||||
DATABASE_PORT = '' # Set to empty string for default. 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
|
#rabbitmq connection settings
|
||||||
CELERY_RESULT_BACKEND = "database"
|
CELERY_RESULT_BACKEND = "database"
|
||||||
|
@ -140,7 +140,6 @@ VIDEO_PROFILE = '96p'
|
||||||
VIDEO_DERIVATIVES = []
|
VIDEO_DERIVATIVES = []
|
||||||
VIDEO_H264 = True
|
VIDEO_H264 = True
|
||||||
|
|
||||||
|
|
||||||
#Pad.ma
|
#Pad.ma
|
||||||
#VIDEO_PROFILE = '480p'
|
#VIDEO_PROFILE = '480p'
|
||||||
#VIDEO_DERIVATIVES = ['96p', '270p', '360p']
|
#VIDEO_DERIVATIVES = ['96p', '270p', '360p']
|
||||||
|
@ -156,6 +155,9 @@ TRANSMISSON_PASSWORD='transmission'
|
||||||
#list of poster services, https://wiki.0x2620.org/wiki/pandora/posterservice
|
#list of poster services, https://wiki.0x2620.org/wiki/pandora/posterservice
|
||||||
POSTER_SERVICES=[]
|
POSTER_SERVICES=[]
|
||||||
|
|
||||||
|
#0xdb.org
|
||||||
|
#POSTER_SERVICES=['http://data.0xdb.org/poster/']
|
||||||
|
|
||||||
#overwrite default settings with local settings
|
#overwrite default settings with local settings
|
||||||
try:
|
try:
|
||||||
from local_settings import *
|
from local_settings import *
|
||||||
|
|
Loading…
Reference in a new issue