From aedb3d3d456764cab6c6944e4255a28ad0632eca Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 10 Aug 2021 16:39:17 +0530 Subject: [PATCH 1/7] fix: sketch cards --- community/lms/widgets/SketchCard.html | 34 +++++++++++++++++++++++++++ community/public/icons/like.svg | 3 +++ 2 files changed, 37 insertions(+) create mode 100644 community/lms/widgets/SketchCard.html create mode 100644 community/public/icons/like.svg diff --git a/community/lms/widgets/SketchCard.html b/community/lms/widgets/SketchCard.html new file mode 100644 index 00000000..0595d50b --- /dev/null +++ b/community/lms/widgets/SketchCard.html @@ -0,0 +1,34 @@ +
+
+ + + +
+ + +
diff --git a/community/public/icons/like.svg b/community/public/icons/like.svg new file mode 100644 index 00000000..dc0a13ec --- /dev/null +++ b/community/public/icons/like.svg @@ -0,0 +1,3 @@ + + + From 5ea744de5cd34bd8ba9516b6a3014faa1f5bea42 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 10 Aug 2021 16:46:48 +0530 Subject: [PATCH 2/7] fix: removed unused file --- community/lms/widgets/SketchTeaser.html | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 community/lms/widgets/SketchTeaser.html diff --git a/community/lms/widgets/SketchTeaser.html b/community/lms/widgets/SketchTeaser.html deleted file mode 100644 index 02f5f5d7..00000000 --- a/community/lms/widgets/SketchTeaser.html +++ /dev/null @@ -1,16 +0,0 @@ -
- - -
From 3e2c6b3343e618e82af396f3a686921ec7437c06 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 10 Aug 2021 17:08:32 +0530 Subject: [PATCH 3/7] fix: sketch image call --- community/lms/widgets/SketchCard.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community/lms/widgets/SketchCard.html b/community/lms/widgets/SketchCard.html index 0595d50b..ed2d4966 100644 --- a/community/lms/widgets/SketchCard.html +++ b/community/lms/widgets/SketchCard.html @@ -1,7 +1,7 @@
@@ -45,7 +50,8 @@
{{ lesson.render_html() }}
{% else %}
- This lesson is not available for Preview. Please join the course to access this lesson. Checkout Course Details. + This lesson is not available for Preview. Please join the course to access this lesson. Checkout Course Details.
{% endif %} diff --git a/community/www/courses/course.js b/community/www/courses/course.js index 2e7688dc..4429816b 100644 --- a/community/www/courses/course.js +++ b/community/www/courses/course.js @@ -169,6 +169,7 @@ var show_review_dialog = (e) => { } var rotate_chapter_icon = (e) => { + e.preventDefault(); var icon = $(e.currentTarget).children(".chapter-icon"); if (icon.css("transform") == "none") { icon.css("transform", "rotate(90deg)"); diff --git a/community/www/discussions/discussion.html b/community/www/discussions/discussion.html new file mode 100644 index 00000000..afa8d8b1 --- /dev/null +++ b/community/www/discussions/discussion.html @@ -0,0 +1,16 @@ +{% extends "templates/base.html" %} +{% block title %}{{ thread.title }}{% endblock %} +{% block head_include %} + +{% endblock %} + +{% block content %} +
+
+ {{ widgets.BreadCrumb(thread=thread) }} +
{{ thread.title }}
+ {{ widgets.DiscussionMessage(thread=thread.name) }} +
+
+{% endblock %} diff --git a/community/www/discussions/discussion.py b/community/www/discussions/discussion.py new file mode 100644 index 00000000..605e70c8 --- /dev/null +++ b/community/www/discussions/discussion.py @@ -0,0 +1,18 @@ +import frappe + +def get_context(context): + context.no_cache = 1 + + try: + thread_name = frappe.form_dict["discussion"] + except KeyError: + redirect_to_discussions() + + context.thread = frappe.db.get_value("Discussion Thread", thread_name, ["name", "title"], as_dict=True) + + if not len(context.thread): + redirect_to_discussions + +def redirect_to_discussions(): + frappe.local.flags.redirect_location = "/discussions" + raise frappe.Redirect diff --git a/community/www/discussions/index.html b/community/www/discussions/index.html new file mode 100644 index 00000000..1f7a6ad2 --- /dev/null +++ b/community/www/discussions/index.html @@ -0,0 +1,65 @@ +{% extends "templates/base.html" %} +{% block title %}{{ 'Discussions' }}{% endblock %} +{% block head_include %} + +{% endblock %} + +{% block content %} +
+
+
+ {{_('Discussions')}} +
+ + Start a Discussion
+
+
+ {% if threads | length %} +
+ {% for thread in threads %} +
+
{{ thread.title }}
+
+
+ + + + {{ thread.message_count }} + + + + {{ thread.member_count }} + + +
+ +
+ {% endfor %} +
+ {% else %} +
+ No discussions yet. +
+ {% endif %} +
+
+ + + + +{% endblock %} diff --git a/community/www/discussions/index.js b/community/www/discussions/index.js new file mode 100644 index 00000000..0cac1f1a --- /dev/null +++ b/community/www/discussions/index.js @@ -0,0 +1,14 @@ +frappe.ready(() => { + $("#new-topic").click((e) => { + show_new_topic_modal(e); + }) +}) + +var show_new_topic_modal = (e) => { + e.preventDefault(); + if (frappe.session.user == "Guest") { + window.location.href = `/login?redirect-to=/discussions/`; + return; + } + $("#discussion-modal").modal("show"); +} diff --git a/community/www/discussions/index.py b/community/www/discussions/index.py new file mode 100644 index 00000000..d474b2a5 --- /dev/null +++ b/community/www/discussions/index.py @@ -0,0 +1,17 @@ +import frappe + +def get_context(context): + context.threads = get_threads() + +def get_threads(): + threads = frappe.get_all("Discussion Thread", fields=["name", "title"]) + for thread in threads: + messages = frappe.get_all("Discussion Message", + { + "thread": thread.name + }, + ["owner"], + as_list=True) + thread.message_count = len(messages) + thread.member_count = len(set(messages)) + return threads