From e31b189045ec2dde5ebff0dcda448d66c0b51602 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 19 Aug 2021 09:35:02 +0530 Subject: [PATCH] fix: profile urls --- community/community/widgets/Avatar.html | 2 +- community/hooks.py | 36 ++------------------ 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/templates/message_card.html | 2 +- community/www/courses/certificate.html | 2 ++ community/www/new-sign-up.html | 2 +- 10 files changed, 13 insertions(+), 41 deletions(-) diff --git a/community/community/widgets/Avatar.html b/community/community/widgets/Avatar.html index 862419a4..59f59a91 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 718dc554..99ed1102 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -130,7 +130,7 @@ fixtures = ["Custom Field"] # auto_cancel_exempted_doctypes = ["Auto Repeat"] # Add all simple route rules here -primary_rules = [ +website_route_rules = [ {"from_route": "/sketches/", "to_route": "sketches/sketch"}, {"from_route": "/courses/", "to_route": "courses/course"}, {"from_route": "/courses//", "to_route": "courses/certificate"}, @@ -146,40 +146,10 @@ primary_rules = [ {"from_route": "/courses//about", "to_route": "batch/about"}, {"from_route": "/courses//progress", "to_route": "batch/progress"}, {"from_route": "/courses//join", "to_route": "batch/join"}, - {"from_route": "/discussions/", "to_route": "discussions/discussion"} + {"from_route": "/discussions/", "to_route": "discussions/discussion"}, + {"from_route": "/user/", "to_route": "profiles/profile"} ] -# Any frappe default URL is blocked by profile-rules, add it here to unblock it -whitelist = [ - "/home", - "/login", - "/update-password", - "/update-profile", - "/third-party-apps", - "/website_script.js", - "/courses", - "/sketches", - "/admin", - "/socket.io", - "/hackathons", - "/dashboard", - "/join-request", - "/add-a-new-batch", - "/new-sign-up", - "/message", - "/about", - "/edit-profile", - "/discussions" -] -whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist] - -# regex rule to match all profiles -profile_rules = [ - {"from_route": "/", "to_route": "profiles/profile"}, -] - -website_route_rules = primary_rules + whitelist_rules + profile_rules - website_redirects = [ {"source": "/update-profile", "target": "/edit-profile"}, ] diff --git a/community/lms/web_form/profile/profile.js b/community/lms/web_form/profile/profile.js index 286ed9b5..c9869a5c 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 = `/${frappe.web_form.get_value(["username"])}`; + window.location.href = `/user/${frappe.web_form.get_value(["username"])}`; }) } }) diff --git a/community/lms/widgets/CourseTeaser.html b/community/lms/widgets/CourseTeaser.html index 64ecb5ec..2b7b54ec 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 367148dd..9c96c294 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 d780eb34..77f00556 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 73073f8d..b5302ca3 100644 --- a/community/lms/widgets/Reviews.html +++ b/community/lms/widgets/Reviews.html @@ -18,7 +18,7 @@ diff --git a/community/www/new-sign-up.html b/community/www/new-sign-up.html index 05a6c3d8..1990dc3b 100644 --- a/community/www/new-sign-up.html +++ b/community/www/new-sign-up.html @@ -67,4 +67,4 @@ }) -{% endblock %} \ No newline at end of file +{% endblock %}