feat: pluggable profile tabs
Added ProfileTab class to represent a profile tab and made the profile page render the tabs specified in the hook `profile_tabs`. This allows plugging in new tabs in the profile page without makeing any changes to the community module.
This commit is contained in:
@@ -3,9 +3,20 @@ from community.lms.models import Sketch
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
try:
|
||||
context.member = frappe.get_doc("User", {"username": frappe.form_dict["username"]})
|
||||
except:
|
||||
context.template = "www/404.html"
|
||||
else:
|
||||
context.sketches = Sketch.get_recent_sketches(owner=context.member.email)
|
||||
return
|
||||
|
||||
context.profile_tabs = get_profile_tabs(context.member)
|
||||
|
||||
def get_profile_tabs(user):
|
||||
"""Returns the enabled ProfileTab objects.
|
||||
|
||||
Each ProfileTab is rendered as a tab on the profile page and the
|
||||
they are specified as profile_tabs hook.
|
||||
"""
|
||||
tabs = frappe.get_hooks("profile_tabs") or []
|
||||
return [frappe.get_attr(tab)(user) for tab in tabs]
|
||||
|
||||
Reference in New Issue
Block a user