From ad536089665f03e7b761d811619d6d22f57c7cb5 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 Jul 2018 09:57:23 +0200 Subject: [PATCH] Display profiles --- calsocial/__init__.py | 20 ++++++++++++++++++++ calsocial/templates/base.html | 2 +- calsocial/templates/profile-details.html | 8 ++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 calsocial/templates/profile-details.html diff --git a/calsocial/__init__.py b/calsocial/__init__.py index 38d63a6..9be5906 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -245,5 +245,25 @@ class CalendarSocialApp(Flask): return render_template('event-details.html', event=event) + @staticmethod + @route('/profile/@') + def display_profile(username): + """View to display profile details + """ + + from flask import abort + from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound + + from .models import Profile, User + + try: + profile = Profile.query.join(User).filter(User.username == username.lower()).one() + except NoResultFound: + abort(404) + except MultipleResultsFound: + abort(500) + + return render_template('profile-details.html', profile=profile) + app = CalendarSocialApp(__name__) diff --git a/calsocial/templates/base.html b/calsocial/templates/base.html index f06841c..14a7b4f 100644 --- a/calsocial/templates/base.html +++ b/calsocial/templates/base.html @@ -30,7 +30,7 @@