basic sort title api
This commit is contained in:
parent
7e40c2667b
commit
47942e204c
2 changed files with 70 additions and 31 deletions
|
|
@ -38,12 +38,22 @@ class Person(db.Model):
|
|||
return cls.query.filter_by(name=name).first()
|
||||
|
||||
def save(self):
|
||||
from .models import Item, Find
|
||||
if not self.sortname:
|
||||
self.sortname = ox.get_sort_name(self.name)
|
||||
self.sortname = unicodedata.normalize('NFKD', self.sortname)
|
||||
self.sortsortname = ox.sort_string(self.sortname)
|
||||
self.numberofnames = len(self.name.split(' '))
|
||||
state.db.session.add(self)
|
||||
for i in Item.find({
|
||||
'query': {
|
||||
'conditions': [{'key': 'author', 'value': self.name, 'operator': '=='}]
|
||||
}
|
||||
}):
|
||||
i.update_sort()
|
||||
Find.query.filter_by(key='author', value=self.name).update({
|
||||
'sortvalue': self.sortname.lower()
|
||||
})
|
||||
state.db.session.commit()
|
||||
|
||||
def json(self, keys=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue