Skip to content

Commit

Permalink
fix: admin record search error & named_areas use new record-map
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed Apr 23, 2024
1 parent c4e872f commit ae21d5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
12 changes: 8 additions & 4 deletions app/blueprints/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ def record_list():
#stmt = select(Unit.id, Unit.accession_number, Entity.id, Entity.field_number, Person.full_name, Person.full_name_en, Entity.collect_date, Entity.proxy_taxon_scientific_name, Entity.proxy_taxon_common_name) \
#.join(Unit, Unit.entity_id==Entity.id, isouter=True) \
#.join(Person, Entity.collector_id==Person.id, isouter=True)
taxon_family = aliased(Taxon)
stmt = select(

stmt_select = select(
Unit.id,
Unit.accession_number,
Record.id,
Expand All @@ -652,12 +652,15 @@ def record_list():
Record.proxy_taxon_id,
Unit.created,
Unit.updated,
Record.collection_id)\
Record.collection_id)

taxon_family = aliased(Taxon)
stmt = stmt_select\
.join(Unit, Unit.record_id==Record.id, isouter=True) \
.join(taxon_family, taxon_family.id==Record.proxy_taxon_id, isouter=True) \
#print(stmt, flush=True)
if q:
stmt = select(Unit.id, Unit.accession_number, Record.id, Record.collector_id, Record.field_number, Record.collect_date, Record.proxy_taxon_scientific_name, Record.proxy_taxon_common_name, Record.proxy_taxon_id) \
stmt = stmt_select\
.join(Unit, Unit.record_id==Record.id, isouter=True) \
.join(Person, Record.collector_id==Person.id, isouter=True)
#.join(TaxonRelation, TaxonRelation.depth==1, TaxonRelation.child_id==Record.proxy_taxon_id)
Expand Down Expand Up @@ -733,6 +736,7 @@ def record_list():

cat_lists= UserList.query.filter(UserList.user_id==current_user.id, UserList.entity_id==entity_id).all()

print(r, flush=True)
item = {
'collection_id': r[11],
'accession_number': r[1] or '',
Expand Down
14 changes: 4 additions & 10 deletions app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_named_area_list(self, list_name=''):

# TODO: list_name from setting
list_name_map = {
'default': [7, 8, 9, 5, 6],
'default': [7, 8, 9, 10, 5, 6],
'legacy': [1, 2, 3, 4, 5, 6],
}

Expand All @@ -218,14 +218,7 @@ def get_named_area_list(self, list_name=''):
ret[x] = sorted(ret[x], key=lambda x: x.area_class.sort)
return ret
else:
if list_name == 'default':
# TODO taiwan use new, other country use old
if country := RecordNamedAreaMap.query.filter(
RecordNamedAreaMap.record_id==self.id,
RecordNamedAreaMap.named_area_id==1311).first():
pass
else:
list_name = 'legacy'
pass

if area_class_ids := list_name_map.get(list_name):
na_list = []
Expand Down Expand Up @@ -450,9 +443,10 @@ def get_values(self):
data['assertions'][i.assertion_type.name] = i.value

for x in self.named_area_maps:
if x.named_area.area_class_id in [1, 5, 6] or x.named_area.area_class_id > 7:
if x.named_area.area_class_id in [5, 6] or x.named_area.area_class_id >= 7:
data['named_areas'][x.named_area.area_class.name] = x.named_area.to_dict()

data['named_areas__legacy'] = [x.to_dict() for x in self.get_named_area_list('legacy')],
return data

def display_altitude(self):
Expand Down
2 changes: 1 addition & 1 deletion app/templates/specimen-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ <h3 class="data-group-title">{{ _('採集資訊') }}</h3>
<div class="data-group-wrapper">
<div id="specimen-map"></div>
<h3 class="data-group-title">{{ _('地點') }}</h3>
{% for i in entity.record.named_areas %}
{% for i in entity.record.get_named_area_list('default') %}
{{ display_data2(i.area_class.label, i.display_name )}}
{% endfor %}
{{ display_data2(_('詳細地點'), entity.record.locality_text )}}
Expand Down

0 comments on commit ae21d5a

Please sign in to comment.