diff --git a/community/community/widgets/Avatar.html b/community/community/widgets/Avatar.html index 59f59a91..b72fc909 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 00472b15..31027f41 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -21,7 +21,7 @@ app_license = "AGPL" # include js, css files in header of web template web_include_css = "community.bundle.css" # web_include_css = "/assets/community/css/community.css" -# web_include_js = "/assets/community/js/community.js" +web_include_js = "website.bundle.js" # include custom scss in every website theme (without file extension ".scss") # website_theme_scss = "community/public/scss/website" @@ -142,7 +142,8 @@ website_route_rules = [ {"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": "/user/", "to_route": "profiles/profile"}, + {"from_route": "/users/", "to_route": "profiles/profile"}, + {"from_route": "/users", "to_route": "profiles/profile"}, ] website_redirects = [ diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index babbe45b..385bf762 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -187,20 +187,6 @@ class LMSCourse(Document): def get_slugified_chapter_title(self, chapter): return slugify(chapter) - def get_course_progress(self): - """ Returns the course progress of the session user """ - lesson_count = len(self.get_lessons()) - completed_lessons = frappe.db.count("LMS Course Progress", - { - "course": self.name, - "owner": frappe.session.user, - "status": "Complete" - }) - precision = cint(frappe.db.get_default("float_precision")) or 3 - if not lesson_count: - return 0 - return flt(((completed_lessons/lesson_count) * 100), precision) - def get_batch(self, batch_name): return find("LMS Batch", name=batch_name, course=self.name) @@ -340,6 +326,20 @@ class LMSCourse(Document): }, ["status"]) + def get_course_progress(self, member=None): + """ Returns the course progress of the session user """ + lesson_count = len(self.get_lessons()) + completed_lessons = frappe.db.count("LMS Course Progress", + { + "course": self.name, + "owner": member or frappe.session.user, + "status": "Complete" + }) + precision = cint(frappe.db.get_default("float_precision")) or 3 + if not lesson_count: + return 0 + return flt(((completed_lessons/lesson_count) * 100), precision) + def get_neighbours(self, current, lessons): current = flt(current) numbers = sorted(lesson.number for lesson in lessons) diff --git a/community/lms/web_form/profile/profile.js b/community/lms/web_form/profile/profile.js index c9869a5c..984fb964 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 = `/users/${frappe.web_form.get_value(["username"])}`; }) } }) diff --git a/community/lms/web_template/course_cards/course_cards.html b/community/lms/web_template/course_cards/course_cards.html index 3e59bc97..693223e5 100644 --- a/community/lms/web_template/course_cards/course_cards.html +++ b/community/lms/web_template/course_cards/course_cards.html @@ -3,7 +3,7 @@
{% for course_row in courses %} {% set course = frappe.get_doc("LMS Course", course_row.course) %} - {{ widgets.CourseCard(course=course) }} + {{ widgets.CourseCard(course=course, show_progress_indicators=True) }} {% endfor %}
diff --git a/community/lms/widgets/BatchHeader.html b/community/lms/widgets/BatchHeader.html deleted file mode 100644 index a6c99cdc..00000000 --- a/community/lms/widgets/BatchHeader.html +++ /dev/null @@ -1,4 +0,0 @@ -
-

{{batch_name}}

-
{{member_count}} members
-
diff --git a/community/lms/widgets/CourseCard.html b/community/lms/widgets/CourseCard.html index 8fe82fb4..a2618e81 100644 --- a/community/lms/widgets/CourseCard.html +++ b/community/lms/widgets/CourseCard.html @@ -1,6 +1,8 @@ +{% set membership = course.get_membership(frappe.session.user) %} +
-
+
{% for tag in course.get_tags() %}
{{ tag }}
@@ -10,7 +12,9 @@
{{ course.title[0] }}
{% endif %}
+
+ +
{{ course.title }}
+ {% if membership and show_progress_indicators %} + {% set progress = course.get_course_progress() %} +
+
+
+ {% else %}
+ {% endif %} +
- {{ widgets.Avatar(member=course.get_instructor(), avatar_class="avatar-small") }} - - {{ course.get_instructor().full_name }} + + {{ widgets.Avatar(member=course.get_instructor(), avatar_class="avatar-small") }} + + + {{ course.get_instructor().full_name }} + + {% if course.get_students() | length %} @@ -42,14 +65,13 @@ {% endif %} {% set avg_rating = course.get_average_rating() %} {% if avg_rating %} - + {{ avg_rating }} {% endif %}
- {% set membership = course.get_membership(frappe.session.user) %} {% set lesson_index = course.get_lesson_index(membership.current_lesson) if membership and membership.current_lesson diff --git a/community/lms/widgets/CourseTeaser.html b/community/lms/widgets/CourseTeaser.html index 2b7b54ec..53bc6362 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 deleted file mode 100644 index 9c96c294..00000000 --- a/community/lms/widgets/InstructorSection.html +++ /dev/null @@ -1,6 +0,0 @@ -
- {{ widgets.Avatar(member=instructor, avatar_class="avatar-medium") }} - {{ instructor.full_name }} -
Course Creator
- -
diff --git a/community/lms/widgets/MemberCard.html b/community/lms/widgets/MemberCard.html index 77f00556..3ed9ed5d 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..57f08833 100644 --- a/community/lms/widgets/Reviews.html +++ b/community/lms/widgets/Reviews.html @@ -19,7 +19,7 @@ {% endmacro %} + +{% block script %} + +{% endblock %} diff --git a/community/www/profiles/profile.py b/community/www/profiles/profile.py index 2ea2bdd5..1498f215 100644 --- a/community/www/profiles/profile.py +++ b/community/www/profiles/profile.py @@ -4,7 +4,14 @@ def get_context(context): context.no_cache = 1 try: - context.member = frappe.get_doc("User", {"username": frappe.form_dict["username"]}) + username = frappe.form_dict["username"] + except KeyError: + username = frappe.db.get_value("User", frappe.session.user, ["username"]) + if username: + frappe.local.flags.redirect_location = "/users/" + username + raise frappe.Redirect + try: + context.member = frappe.get_doc("User", {"username": username}) except: context.template = "www/404.html" return