From eb3adc740dbf535736f2e3a00b815afac3e33fa0 Mon Sep 17 00:00:00 2001 From: aj Date: Sat, 2 Mar 2019 14:58:24 +0000 Subject: [PATCH] art sorting by index for main and by date --- sarsoo/art/db.py | 11 +++++------ sarsoo/music/music.py | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sarsoo/art/db.py b/sarsoo/art/db.py index 2f39ffd..1692603 100644 --- a/sarsoo/art/db.py +++ b/sarsoo/art/db.py @@ -13,14 +13,12 @@ def getTagDicts(): except google.cloud.exceptions.NotFound: return 'no such document' - dicts = [] - for tag in tags: - dicts.append(tag.to_dict()) - + dicts = list(map(lambda x: x.to_dict(), tags)) + for artdict in dicts: artdict['splash'] = artdict['splash'].get().to_dict() - return dicts + return sorted(dicts, key=lambda k: k['index']) def getPopulatedTagDict(name): @@ -31,7 +29,8 @@ def getPopulatedTagDict(name): image_list = [] for image in tag_dicts['art']: image_list.append(image.get().to_dict()) - tag_dicts['images'] = image_list + + tag_dicts['images'] = sorted(image_list, key = lambda k: k['date'], reverse = True) return tag_dicts diff --git a/sarsoo/music/music.py b/sarsoo/music/music.py index fe980d0..22b9d29 100644 --- a/sarsoo/music/music.py +++ b/sarsoo/music/music.py @@ -3,6 +3,8 @@ from jinja2 import TemplateNotFound from google.cloud import firestore +fs = firestore.Client() + urlprefix = 'music' music_print = Blueprint('music', __name__, template_folder='templates') @@ -10,4 +12,7 @@ music_print = Blueprint('music', __name__, template_folder='templates') @music_print.route('/') def root(): + fmkey = fs.document('key/fm').get().to_dict()['clientid'] + + return render_template('music/index.html')