def login(): if request.method == 'GET': return html.ok('login', {}) name = request.values.get('username', '') password = request.values.get('password', '') user = Person.query.filter(Person.first_name == name).first() if user and user.check_password(password): login_user(user, remember=True) return redirect(request.values.get('next', '/')) return html.ok('login')
def show_album(album_id): return html.ok( 'photos/show_photos', { 'cards': [{ 'photo': p, 'text': p.description, 'href': f'/photos/highres/{p.id}' } for p in Photo.query.filter(Photo.category == album_id)] })
def show_groceries(): if request.method == 'POST': item_name = request.values.get('name') if item_name: db.session.add(Grocery(creator_id=current_user.id, text=item_name)) db.session.commit() return redirect(url_for('show_groceries')) data = { 'groceries': Grocery.query.filter(Grocery.fetched_date.is_(None)).all() } return html.ok('groceries', data)
def show_albums(): category_photo = { c: Photo.query.filter(Photo.category == c).first() for c in categories() } return html.ok( 'photos/show_photos', { 'cards': [{ 'photo': p, 'text': c, 'href': f'/photos/album/{c}' } for c, p in category_photo.items()] })
def photo_upload_page(errors=[]): return html.ok('photos/photo_upload', { 'categories': [c for c in categories()], 'errors': errors })
def show_highres(photo_id): return html.ok('photos/show_highres', {'photo': Photo.query.get(int(photo_id))})