refactor: added custom routing for profiles
- installed a regex conveter to werkzeug to support regular expresions in routes - added a website route rule to match all profiles
This commit is contained in:
25
community/www/profiles/profile.html
Normal file
25
community/www/profiles/profile.html
Normal file
@@ -0,0 +1,25 @@
|
||||
{% extends "templates/web.html" %}
|
||||
{% block page_content %}
|
||||
<div class="py-20 row">
|
||||
{% if user.photo %}
|
||||
<div class="col-sm-2 border border-dark">
|
||||
<img src="{{ user.photo }}" alt="{{ user.full_name }}">
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-sm-2">
|
||||
<div class="standard-image" style="font-size: 30px;">{{ user.abbr }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col">
|
||||
<h1>{{ user.full_name }}</h1>
|
||||
{% if user.short_intro %}
|
||||
<p class="lead"> {{ user.short_intro }} </p>
|
||||
{% endif %}
|
||||
{% if user.bio %}
|
||||
<p class="markdown-style"> {{ frappe.utils.md_to_html(user.bio) }} </p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<!-- this is a sample default web page template -->
|
||||
18
community/www/profiles/profile.py
Normal file
18
community/www/profiles/profile.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
username = frappe.form_dict.get('username')
|
||||
user = username and get_user(username)
|
||||
if not user:
|
||||
context.template = "www/404.html"
|
||||
|
||||
user.abbr = "".join([s[0] for s in user.full_name.split()])
|
||||
context.user = user
|
||||
|
||||
def get_user(username):
|
||||
try:
|
||||
return frappe.get_doc("Community Member", username)
|
||||
except frappe.DoesNotExistError:
|
||||
return
|
||||
Reference in New Issue
Block a user