Format + improve indexer

This commit is contained in:
PCoder 2022-03-05 00:44:07 +05:30
parent 41a2129e9a
commit a0c3dd57dd
2 changed files with 17 additions and 7 deletions

View File

@ -147,7 +147,8 @@ def refresh_data(filename, fmt=None, update_existing=False):
elif fmt['dataformat'] is DataFormat.RESOURCE_DETAIL:
res, source_id = get_by_id(row['ID'], Resource)
if not res: res = Resource(source_id=source_id)
if not res:
res = Resource(source_id=source_id)
res.title = row['Title']
res.citation = row['Citation']
res.url = fix_url(row['URL'].strip('#')) # remove weird #formatting#
@ -166,9 +167,11 @@ def refresh_data(filename, fmt=None, update_existing=False):
elif fmt['dataformat'] is DataFormat.PERSON_RESOURCE:
rzs, source_id = get_by_id(row['Resource'], Resource, first=False)
if not rzs or not rzs.first(): continue
if not rzs or not rzs.first():
continue
ppl, source_id = get_by_id(row['Person'], Person, first=False)
if not ppl or not ppl.first(): continue
if not ppl or not ppl.first():
continue
for person in ppl:
person.resources = []
for r in rzs:

View File

@ -666,10 +666,17 @@ Involved scientist''')
return False
def index(self):
self.field_indexer = " ".join([
self.first_name, self.last_name, self.organisation, self.position, self.biography
])
return True
if self:
self.field_indexer = " ".join([
self.first_name if self and self.first_name else "",
self.last_name if self and self.last_name else "",
self.organisation if self and self.organisation else "",
self.position if self and self.position else "",
self.biography if self and self.biography else ""
] if self else [])
return True
else:
return False
def fullname(self):
return " ".join([self.title if self.title else '',