add order by code in tags lists and select

This commit is contained in:
Cayo Puigdefabregas 2022-03-02 13:07:04 +01:00
parent ab89b7eff0
commit ad09d298a0
2 changed files with 4 additions and 4 deletions

View File

@ -464,9 +464,9 @@ class TagDeviceForm(FlaskForm):
if self.delete: if self.delete:
tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by( tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(
device_id=self.device_id device_id=self.device_id
) ).order_by(Tag.id)
else: else:
tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(device_id=None) tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(device_id=None).order_by(Tag.id)
self.tag.choices = [(tag.id, tag.id) for tag in tags] self.tag.choices = [(tag.id, tag.id) for tag in tags]

View File

@ -47,7 +47,7 @@ class DeviceListMix(View):
tags = ( tags = (
Tag.query.filter(Tag.owner_id == current_user.id) Tag.query.filter(Tag.owner_id == current_user.id)
.filter(Tag.device_id.is_(None)) .filter(Tag.device_id.is_(None))
.order_by(Tag.created.desc()) .order_by(Tag.id.asc())
) )
if lot_id: if lot_id:
@ -236,7 +236,7 @@ class TagListView(View):
def dispatch_request(self): def dispatch_request(self):
lots = Lot.query.filter(Lot.owner_id == current_user.id) lots = Lot.query.filter(Lot.owner_id == current_user.id)
tags = Tag.query.filter(Tag.owner_id == current_user.id) tags = Tag.query.filter(Tag.owner_id == current_user.id).order_by(Tag.id)
context = { context = {
'lots': lots, 'lots': lots,
'tags': tags, 'tags': tags,