list(set does not keep order, only make lists unique creating facets for now
This commit is contained in:
parent
59ad75f7ab
commit
62659b107d
1 changed files with 5 additions and 2 deletions
|
@ -179,7 +179,7 @@ class Item(models.Model):
|
||||||
'cinematographers', 'languages', 'genres', 'keywords',
|
'cinematographers', 'languages', 'genres', 'keywords',
|
||||||
'episode_directors'):
|
'episode_directors'):
|
||||||
if key in data:
|
if key in data:
|
||||||
data[key[:-1]] = list(set(data.pop(key)))
|
data[key[:-1]] = data.pop(key)
|
||||||
if 'countries' in data:
|
if 'countries' in data:
|
||||||
data['country'] = data.pop('countries')
|
data['country'] = data.pop('countries')
|
||||||
if 'release date' in data:
|
if 'release date' in data:
|
||||||
|
@ -193,7 +193,7 @@ class Item(models.Model):
|
||||||
data['actor'] = [data['cast'][0]]
|
data['actor'] = [data['cast'][0]]
|
||||||
else:
|
else:
|
||||||
data['actor'] = [c[0] for c in data['cast']]
|
data['actor'] = [c[0] for c in data['cast']]
|
||||||
data['actor'] = list(set(data['actor']))
|
data['actor'] = data['actor']
|
||||||
self.external_data = data
|
self.external_data = data
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
@ -250,6 +250,8 @@ class Item(models.Model):
|
||||||
'''
|
'''
|
||||||
move all related tables to other and delete self
|
move all related tables to other and delete self
|
||||||
'''
|
'''
|
||||||
|
#FIXME: stream path is wrong after this, should this be dealt with in save?
|
||||||
|
# its more that streams have to be generated again after merging
|
||||||
for stream in self.streams.all():
|
for stream in self.streams.all():
|
||||||
stream.item = other
|
stream.item = other
|
||||||
stream.save()
|
stream.save()
|
||||||
|
@ -549,6 +551,7 @@ class Item(models.Model):
|
||||||
current_values = self.get(key, [])
|
current_values = self.get(key, [])
|
||||||
if not isinstance(current_values, list):
|
if not isinstance(current_values, list):
|
||||||
current_values = [current_values]
|
current_values = [current_values]
|
||||||
|
current_values = list(set(current_values))
|
||||||
saved_values = [i.value for i in Facet.objects.filter(item=self, key=key)]
|
saved_values = [i.value for i in Facet.objects.filter(item=self, key=key)]
|
||||||
removed_values = filter(lambda i: i not in current_values, saved_values)
|
removed_values = filter(lambda i: i not in current_values, saved_values)
|
||||||
if removed_values:
|
if removed_values:
|
||||||
|
|
Loading…
Reference in a new issue