Display profiles
This commit is contained in:
		@@ -245,5 +245,25 @@ class CalendarSocialApp(Flask):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return render_template('event-details.html', event=event)
 | 
					        return render_template('event-details.html', event=event)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @staticmethod
 | 
				
			||||||
 | 
					    @route('/profile/@<string:username>')
 | 
				
			||||||
 | 
					    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__)
 | 
					app = CalendarSocialApp(__name__)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@
 | 
				
			|||||||
            </h1>
 | 
					            </h1>
 | 
				
			||||||
            <nav class="menu">
 | 
					            <nav class="menu">
 | 
				
			||||||
{% if current_user.is_authenticated %}
 | 
					{% if current_user.is_authenticated %}
 | 
				
			||||||
                {{ _('Logged in as %(username)s', username=current_user.username) }}
 | 
					                {{ _('Logged in as %(username)s', username=('<a href="' + url_for('display_profile', username=current_user.username) + '">' + current_user.username + '</a>') | safe) }}
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
                <ul>
 | 
					                <ul>
 | 
				
			||||||
{% if not current_user.is_authenticated %}
 | 
					{% if not current_user.is_authenticated %}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								calsocial/templates/profile-details.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								calsocial/templates/profile-details.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					{% extends 'base.html' %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block content %}
 | 
				
			||||||
 | 
					<h1>
 | 
				
			||||||
 | 
					    {{ profile.name }}
 | 
				
			||||||
 | 
					    <small>@{{ profile.user.username}}</small>
 | 
				
			||||||
 | 
					</h1>
 | 
				
			||||||
 | 
					{% endblock content %}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user