From a0b77f5d08b72f6fffd4daef02d3dda07913d267 Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Tue, 7 Sep 2021 16:57:35 +0530 Subject: [PATCH] feat: added get_profile_url function to get the profile url in templates This takes care of generating the correct profile URL depending on the `profile_url_prefix` setting. Issue #192 --- community/community/widgets/Avatar.html | 2 +- community/hooks.py | 7 ++++++- community/lms/web_form/profile/profile.js | 2 +- community/lms/widgets/CourseTeaser.html | 2 +- community/lms/widgets/InstructorSection.html | 2 +- community/lms/widgets/MemberCard.html | 2 +- community/lms/widgets/Reviews.html | 2 +- community/page_renderers.py | 7 ------- community/templates/discussions/reply_card.html | 2 +- 9 files changed, 13 insertions(+), 15 deletions(-) diff --git a/community/community/widgets/Avatar.html b/community/community/widgets/Avatar.html index 59f59a91..6450ac9f 100644 --- a/community/community/widgets/Avatar.html +++ b/community/community/widgets/Avatar.html @@ -1,5 +1,5 @@ {% set color = member.get_palette() %} - + {% if member.user_image %} diff --git a/community/hooks.py b/community/hooks.py index 7bfb7a70..40e0e8ba 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -149,8 +149,13 @@ website_redirects = [ update_website_context = [ 'community.widgets.update_website_context', - 'community.page_renderers.update_website_context' ] +jinja = { + "methods": [ + "community.page_renderers.get_profile_url" + ], + "filters": [] +} ## Specify the additional tabs to be included in the user profile page. ## Each entry must be a subclass of community.community.plugins.ProfileTab # profile_tabs = [] diff --git a/community/lms/web_form/profile/profile.js b/community/lms/web_form/profile/profile.js index c9869a5c..8a707633 100644 --- a/community/lms/web_form/profile/profile.js +++ b/community/lms/web_form/profile/profile.js @@ -8,7 +8,7 @@ frappe.ready(function () { frappe.web_form.after_save = () => { setTimeout(() => { - window.location.href = `/user/${frappe.web_form.get_value(["username"])}`; + window.location.href = `/profile_/${frappe.web_form.get_value(["username"])}`; }) } }) diff --git a/community/lms/widgets/CourseTeaser.html b/community/lms/widgets/CourseTeaser.html index 2b7b54ec..280d2783 100644 --- a/community/lms/widgets/CourseTeaser.html +++ b/community/lms/widgets/CourseTeaser.html @@ -12,7 +12,7 @@ {% endif %}
{% with author = course.get_instructor() %} - {{ widgets.Avatar(member=author, avatar_class="avatar-medium") }} {{ author.full_name }} + {{ widgets.Avatar(member=author, avatar_class="avatar-medium") }} {{ author.full_name }} {% endwith %}
diff --git a/community/lms/widgets/InstructorSection.html b/community/lms/widgets/InstructorSection.html index 9c96c294..c478e452 100644 --- a/community/lms/widgets/InstructorSection.html +++ b/community/lms/widgets/InstructorSection.html @@ -1,6 +1,6 @@
{{ widgets.Avatar(member=instructor, avatar_class="avatar-medium") }} - {{ instructor.full_name }} + {{ instructor.full_name }}
Course Creator
diff --git a/community/lms/widgets/MemberCard.html b/community/lms/widgets/MemberCard.html index 77f00556..89879cbb 100644 --- a/community/lms/widgets/MemberCard.html +++ b/community/lms/widgets/MemberCard.html @@ -11,5 +11,5 @@ Created {{ course_count }} {{ suffix }} {% endif %} - + diff --git a/community/lms/widgets/Reviews.html b/community/lms/widgets/Reviews.html index f9ba6524..8fe25df4 100644 --- a/community/lms/widgets/Reviews.html +++ b/community/lms/widgets/Reviews.html @@ -19,7 +19,7 @@