forked from 0x2620/pandora
cleanup name
This commit is contained in:
parent
d1efe62ddb
commit
90f735acb5
4 changed files with 21 additions and 17 deletions
|
@ -480,14 +480,14 @@ Positions
|
||||||
else:
|
else:
|
||||||
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
||||||
if query['group'] != "keyword":
|
if query['group'] != "keyword":
|
||||||
order_by = (order_by, 'value_sort')
|
order_by = (order_by, 'sortvalue')
|
||||||
else:
|
else:
|
||||||
order_by = (order_by,)
|
order_by = (order_by,)
|
||||||
else:
|
else:
|
||||||
order_by = query['sort'][0]['operator'] == '-' and '-value_sort' or 'value_sort'
|
order_by = query['sort'][0]['operator'] == '-' and '-sortvalue' or 'sortvalue'
|
||||||
order_by = (order_by, 'items')
|
order_by = (order_by, 'items')
|
||||||
else:
|
else:
|
||||||
order_by = ('-value_sort', 'items')
|
order_by = ('-sortvalue', 'items')
|
||||||
response['data']['items'] = []
|
response['data']['items'] = []
|
||||||
items = 'items'
|
items = 'items'
|
||||||
item_qs = query['qs']
|
item_qs = query['qs']
|
||||||
|
|
|
@ -741,10 +741,10 @@ class Item(models.Model):
|
||||||
Facet.objects.filter(item=self, key=key, value__in=removed_values).delete()
|
Facet.objects.filter(item=self, key=key, value__in=removed_values).delete()
|
||||||
for value in current_values:
|
for value in current_values:
|
||||||
if value not in saved_values:
|
if value not in saved_values:
|
||||||
value_sort = value
|
sortvalue = value
|
||||||
if key in self.person_keys:
|
if key in self.person_keys:
|
||||||
value_sort = get_name_sort(value)
|
sortvalue = get_name_sort(value)
|
||||||
Facet.objects.get_or_create(item=self, key=key, value=value, value_sort=value_sort)
|
Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue)
|
||||||
|
|
||||||
def path(self, name=''):
|
def path(self, name=''):
|
||||||
h = self.itemId
|
h = self.itemId
|
||||||
|
@ -1204,13 +1204,13 @@ class Facet(models.Model):
|
||||||
item = models.ForeignKey('Item', related_name='facets')
|
item = models.ForeignKey('Item', related_name='facets')
|
||||||
key = models.CharField(max_length=200, db_index=True)
|
key = models.CharField(max_length=200, db_index=True)
|
||||||
value = models.CharField(max_length=1000, db_index=True)
|
value = models.CharField(max_length=1000, db_index=True)
|
||||||
value_sort = models.CharField(max_length=1000, db_index=True)
|
sortvalue = models.CharField(max_length=1000, db_index=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s=%s" % (self.key, self.value)
|
return u"%s=%s" % (self.key, self.value)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.value_sort:
|
if not self.sortvalue:
|
||||||
self.value_sort = utils.sort_string(self.value)
|
self.sortvalue = utils.sort_string(self.value)
|
||||||
super(Facet, self).save(*args, **kwargs)
|
super(Facet, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ def _order_query(qs, sort, prefix='sort__'):
|
||||||
elif sort[0]['key'] == 'year':
|
elif sort[0]['key'] == 'year':
|
||||||
sort.append({'operator': '+', 'key': 'director'})
|
sort.append({'operator': '+', 'key': 'director'})
|
||||||
sort.append({'operator': '+', 'key': 'title'})
|
sort.append({'operator': '+', 'key': 'title'})
|
||||||
elif not sort[0]['key'] in ('value', 'value_sort'):
|
elif not sort[0]['key'] in ('value', 'sortvalue'):
|
||||||
sort.append({'operator': '+', 'key': 'director'})
|
sort.append({'operator': '+', 'key': 'director'})
|
||||||
sort.append({'operator': '-', 'key': 'year'})
|
sort.append({'operator': '-', 'key': 'year'})
|
||||||
sort.append({'operator': '+', 'key': 'title'})
|
sort.append({'operator': '+', 'key': 'title'})
|
||||||
|
@ -69,17 +69,17 @@ def _order_by_group(query):
|
||||||
if len(query['sort']) == 1 and query['sort'][0]['key'] == 'items':
|
if len(query['sort']) == 1 and query['sort'][0]['key'] == 'items':
|
||||||
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
||||||
if query['group'] == "year":
|
if query['group'] == "year":
|
||||||
secondary = query['sort'][0]['operator'] == '-' and '-value_sort' or 'value_sort'
|
secondary = query['sort'][0]['operator'] == '-' and '-sortvalue' or 'sortvalue'
|
||||||
order_by = (order_by, secondary)
|
order_by = (order_by, secondary)
|
||||||
elif query['group'] != "keyword":
|
elif query['group'] != "keyword":
|
||||||
order_by = (order_by, 'value_sort')
|
order_by = (order_by, 'sortvalue')
|
||||||
else:
|
else:
|
||||||
order_by = (order_by,)
|
order_by = (order_by,)
|
||||||
else:
|
else:
|
||||||
order_by = query['sort'][0]['operator'] == '-' and '-value_sort' or 'value_sort'
|
order_by = query['sort'][0]['operator'] == '-' and '-sortvalue' or 'sortvalue'
|
||||||
order_by = (order_by, 'items')
|
order_by = (order_by, 'items')
|
||||||
else:
|
else:
|
||||||
order_by = ('-value_sort', 'items')
|
order_by = ('-sortvalue', 'items')
|
||||||
return order_by
|
return order_by
|
||||||
|
|
||||||
def parse_query(data, user):
|
def parse_query(data, user):
|
||||||
|
|
|
@ -52,9 +52,13 @@ class Person(models.Model):
|
||||||
self.numberofnames = len(self.name.split(' '))
|
self.numberofnames = len(self.name.split(' '))
|
||||||
super(Person, self).save(*args, **kwargs)
|
super(Person, self).save(*args, **kwargs)
|
||||||
item.models.Facet.objects.filter(
|
item.models.Facet.objects.filter(
|
||||||
key__in=item.models.Item.person_keys, value=self.name
|
key__in=item.models.Item.person_keys,
|
||||||
).exclude(value_sort=self.sortname
|
value=self.name
|
||||||
).update(value_sort=self.sortname)
|
).exclude(
|
||||||
|
sortvalue=self.sortname
|
||||||
|
).update(
|
||||||
|
sortvalue=self.sortname
|
||||||
|
)
|
||||||
|
|
||||||
def get_or_create(model, name, imdbId=None):
|
def get_or_create(model, name, imdbId=None):
|
||||||
if imdbId:
|
if imdbId:
|
||||||
|
|
Loading…
Reference in a new issue