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:
|
||||
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
||||
if query['group'] != "keyword":
|
||||
order_by = (order_by, 'value_sort')
|
||||
order_by = (order_by, 'sortvalue')
|
||||
else:
|
||||
order_by = (order_by,)
|
||||
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')
|
||||
else:
|
||||
order_by = ('-value_sort', 'items')
|
||||
order_by = ('-sortvalue', 'items')
|
||||
response['data']['items'] = []
|
||||
items = 'items'
|
||||
item_qs = query['qs']
|
||||
|
|
|
@ -741,10 +741,10 @@ class Item(models.Model):
|
|||
Facet.objects.filter(item=self, key=key, value__in=removed_values).delete()
|
||||
for value in current_values:
|
||||
if value not in saved_values:
|
||||
value_sort = value
|
||||
sortvalue = value
|
||||
if key in self.person_keys:
|
||||
value_sort = get_name_sort(value)
|
||||
Facet.objects.get_or_create(item=self, key=key, value=value, value_sort=value_sort)
|
||||
sortvalue = get_name_sort(value)
|
||||
Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue)
|
||||
|
||||
def path(self, name=''):
|
||||
h = self.itemId
|
||||
|
@ -1204,13 +1204,13 @@ class Facet(models.Model):
|
|||
item = models.ForeignKey('Item', related_name='facets')
|
||||
key = models.CharField(max_length=200, 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):
|
||||
return u"%s=%s" % (self.key, self.value)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.value_sort:
|
||||
self.value_sort = utils.sort_string(self.value)
|
||||
if not self.sortvalue:
|
||||
self.sortvalue = utils.sort_string(self.value)
|
||||
super(Facet, self).save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ def _order_query(qs, sort, prefix='sort__'):
|
|||
elif sort[0]['key'] == 'year':
|
||||
sort.append({'operator': '+', 'key': 'director'})
|
||||
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': 'year'})
|
||||
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':
|
||||
order_by = query['sort'][0]['operator'] == '-' and '-items' or 'items'
|
||||
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)
|
||||
elif query['group'] != "keyword":
|
||||
order_by = (order_by, 'value_sort')
|
||||
order_by = (order_by, 'sortvalue')
|
||||
else:
|
||||
order_by = (order_by,)
|
||||
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')
|
||||
else:
|
||||
order_by = ('-value_sort', 'items')
|
||||
order_by = ('-sortvalue', 'items')
|
||||
return order_by
|
||||
|
||||
def parse_query(data, user):
|
||||
|
|
|
@ -52,9 +52,13 @@ class Person(models.Model):
|
|||
self.numberofnames = len(self.name.split(' '))
|
||||
super(Person, self).save(*args, **kwargs)
|
||||
item.models.Facet.objects.filter(
|
||||
key__in=item.models.Item.person_keys, value=self.name
|
||||
).exclude(value_sort=self.sortname
|
||||
).update(value_sort=self.sortname)
|
||||
key__in=item.models.Item.person_keys,
|
||||
value=self.name
|
||||
).exclude(
|
||||
sortvalue=self.sortname
|
||||
).update(
|
||||
sortvalue=self.sortname
|
||||
)
|
||||
|
||||
def get_or_create(model, name, imdbId=None):
|
||||
if imdbId:
|
||||
|
|
Loading…
Reference in a new issue