diff --git a/community/community/doctype/discussion_message/discussion_message.py b/community/community/doctype/discussion_message/discussion_message.py
deleted file mode 100644
index 3a9e672d..00000000
--- a/community/community/doctype/discussion_message/discussion_message.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2021, FOSS United and contributors
-# For license information, please see license.txt
-
-import frappe
-from frappe.model.document import Document
-from community.widgets import Widget, Widgets
-
-class DiscussionMessage(Document):
- def after_insert(self):
- data = {
- "message": self,
- "widgets": Widgets()
- }
- template = frappe.render_template("community/templates/message_card.html", data)
- thread_info = frappe.db.get_value("Discussion Thread", self.thread, ["reference_doctype", "reference_docname"], as_dict=True)
- frappe.publish_realtime(event="publish_message",
- message = {
- "thread": self.thread,
- "template": template,
- "thread_info": thread_info
- },
- after_commit=True)
diff --git a/community/community/doctype/discussion_message/__init__.py b/community/community/doctype/discussion_reply/__init__.py
similarity index 100%
rename from community/community/doctype/discussion_message/__init__.py
rename to community/community/doctype/discussion_reply/__init__.py
diff --git a/community/community/doctype/discussion_thread/discussion_thread.js b/community/community/doctype/discussion_reply/discussion_reply.js
similarity index 77%
rename from community/community/doctype/discussion_thread/discussion_thread.js
rename to community/community/doctype/discussion_reply/discussion_reply.js
index 93fdaaa4..1c72808d 100644
--- a/community/community/doctype/discussion_thread/discussion_thread.js
+++ b/community/community/doctype/discussion_reply/discussion_reply.js
@@ -1,7 +1,7 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Discussion Thread', {
+frappe.ui.form.on('Discussion Reply', {
// refresh: function(frm) {
// }
diff --git a/community/community/doctype/discussion_message/discussion_message.json b/community/community/doctype/discussion_reply/discussion_reply.json
similarity index 54%
rename from community/community/doctype/discussion_message/discussion_message.json
rename to community/community/doctype/discussion_reply/discussion_reply.json
index 4a7d653d..f8eb7632 100644
--- a/community/community/doctype/discussion_message/discussion_message.json
+++ b/community/community/doctype/discussion_reply/discussion_reply.json
@@ -5,49 +5,31 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
- "thread",
- "column_break_2",
- "parent_message",
- "section_break_4",
- "message"
+ "topic",
+ "reply"
],
"fields": [
{
- "fieldname": "message",
+ "fieldname": "reply",
"fieldtype": "Long Text",
"in_list_view": 1,
- "label": "Message"
+ "label": "Reply"
},
{
- "fieldname": "thread",
+ "fieldname": "topic",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
- "label": "Thread",
- "options": "Discussion Thread"
- },
- {
- "fieldname": "column_break_2",
- "fieldtype": "Column Break"
- },
- {
- "fieldname": "parent_message",
- "fieldtype": "Link",
- "in_list_view": 1,
- "label": "Parent Message",
- "options": "Discussion Message"
- },
- {
- "fieldname": "section_break_4",
- "fieldtype": "Section Break"
+ "label": "Topic",
+ "options": "Discussion Topic"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-08-12 15:59:04.811286",
+ "modified": "2021-08-27 15:06:51.362714",
"modified_by": "Administrator",
"module": "Community",
- "name": "Discussion Message",
+ "name": "Discussion Reply",
"owner": "Administrator",
"permissions": [
{
diff --git a/community/community/doctype/discussion_reply/discussion_reply.py b/community/community/doctype/discussion_reply/discussion_reply.py
new file mode 100644
index 00000000..973a3a7b
--- /dev/null
+++ b/community/community/doctype/discussion_reply/discussion_reply.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2021, FOSS United and contributors
+# For license information, please see license.txt
+
+import frappe
+from frappe.model.document import Document
+from community.widgets import Widgets
+
+class DiscussionReply(Document):
+ def after_insert(self):
+ data = {
+ "reply": self,
+ "topic": {
+ "name": self.topic
+ },
+ "widgets": Widgets()
+ }
+ template = frappe.render_template("community/templates/discussions/reply_card.html", data)
+ topic_info = frappe.get_all("Discussion Topic", {"name": self.topic}, ["reference_doctype", "reference_docname", "name", "title", "owner", "creation"])
+ sidebar = frappe.render_template("community/templates/discussions/sidebar.html", { "topic": topic_info[0], "widgets": Widgets() })
+ new_topic_template = frappe.render_template("community/templates/discussions/reply_section.html", { "topics": topic_info, "widgets": Widgets() })
+
+ frappe.publish_realtime(event="publish_message",
+ message = {
+ "template": template,
+ "topic_info": topic_info[0],
+ "sidebar": sidebar,
+ "new_topic_template": new_topic_template
+ },
+ after_commit=True)
diff --git a/community/community/doctype/discussion_thread/test_discussion_thread.py b/community/community/doctype/discussion_reply/test_discussion_reply.py
similarity index 69%
rename from community/community/doctype/discussion_thread/test_discussion_thread.py
rename to community/community/doctype/discussion_reply/test_discussion_reply.py
index b692f56e..45485242 100644
--- a/community/community/doctype/discussion_thread/test_discussion_thread.py
+++ b/community/community/doctype/discussion_reply/test_discussion_reply.py
@@ -4,5 +4,5 @@
# import frappe
import unittest
-class TestDiscussionThread(unittest.TestCase):
+class TestDiscussionReply(unittest.TestCase):
pass
diff --git a/community/community/doctype/discussion_thread/discussion_thread.py b/community/community/doctype/discussion_thread/discussion_thread.py
deleted file mode 100644
index cef7ef57..00000000
--- a/community/community/doctype/discussion_thread/discussion_thread.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (c) 2021, FOSS United and contributors
-# For license information, please see license.txt
-
-import frappe
-from frappe.model.document import Document
-
-class DiscussionThread(Document):
- pass
-
-@frappe.whitelist()
-def submit_discussion(doctype, docname, message, title=None, thread_name=None):
- thread = []
- filters = {}
- if doctype and docname:
- filters = {
- "reference_doctype": doctype,
- "reference_docname": docname
- }
-
- elif thread_name:
- filters = {
- "name": thread_name
- }
-
- if filters:
- thread = frappe.get_all("Discussion Thread",filters)
- if len(thread):
- thread = thread[0]
- save_message(message, thread)
-
- else:
- thread = frappe.get_doc({
- "doctype": "Discussion Thread",
- "title": title,
- "reference_doctype": doctype,
- "reference_docname": docname
- })
- thread.save(ignore_permissions=True)
- save_message(message, thread)
-
- return thread.name
-
-def save_message(message, thread):
- frappe.get_doc({
- "doctype": "Discussion Message",
- "message": message,
- "thread": thread.name
- }).save(ignore_permissions=True)
diff --git a/community/community/doctype/discussion_thread/__init__.py b/community/community/doctype/discussion_topic/__init__.py
similarity index 100%
rename from community/community/doctype/discussion_thread/__init__.py
rename to community/community/doctype/discussion_topic/__init__.py
diff --git a/community/community/doctype/discussion_message/discussion_message.js b/community/community/doctype/discussion_topic/discussion_topic.js
similarity index 77%
rename from community/community/doctype/discussion_message/discussion_message.js
rename to community/community/doctype/discussion_topic/discussion_topic.js
index 6044a179..2eebd44c 100644
--- a/community/community/doctype/discussion_message/discussion_message.js
+++ b/community/community/doctype/discussion_topic/discussion_topic.js
@@ -1,7 +1,7 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
-frappe.ui.form.on('Discussion Message', {
+frappe.ui.form.on('Discussion Topic', {
// refresh: function(frm) {
// }
diff --git a/community/community/doctype/discussion_thread/discussion_thread.json b/community/community/doctype/discussion_topic/discussion_topic.json
similarity index 97%
rename from community/community/doctype/discussion_thread/discussion_thread.json
rename to community/community/doctype/discussion_topic/discussion_topic.json
index 5442c60b..c82eca04 100644
--- a/community/community/doctype/discussion_thread/discussion_thread.json
+++ b/community/community/doctype/discussion_topic/discussion_topic.json
@@ -33,7 +33,7 @@
"modified": "2021-08-11 12:29:43.564123",
"modified_by": "Administrator",
"module": "Community",
- "name": "Discussion Thread",
+ "name": "Discussion Topic",
"owner": "Administrator",
"permissions": [
{
@@ -54,4 +54,4 @@
"sort_order": "DESC",
"title_field": "title",
"track_changes": 1
-}
\ No newline at end of file
+}
diff --git a/community/community/doctype/discussion_topic/discussion_topic.py b/community/community/doctype/discussion_topic/discussion_topic.py
new file mode 100644
index 00000000..4ab8558f
--- /dev/null
+++ b/community/community/doctype/discussion_topic/discussion_topic.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2021, FOSS United and contributors
+# For license information, please see license.txt
+
+import frappe
+from frappe.model.document import Document
+
+class DiscussionTopic(Document):
+ pass
+
+@frappe.whitelist()
+def submit_discussion(doctype, docname, reply, title, topic_name=None):
+ if topic_name:
+ save_message(reply, topic_name)
+ return topic_name
+
+ topic = frappe.get_doc({
+ "doctype": "Discussion Topic",
+ "title": title,
+ "reference_doctype": doctype,
+ "reference_docname": docname
+ })
+ topic.save(ignore_permissions=True)
+ save_message(reply, topic.name)
+ return topic.name
+
+def save_message(reply, topic):
+ frappe.get_doc({
+ "doctype": "Discussion Reply",
+ "reply": reply,
+ "topic": topic
+ }).save(ignore_permissions=True)
+
+@frappe.whitelist()
+def get_docname(route):
+ return frappe.db.get_value("Web Page", {"route": route}, ["name"])
diff --git a/community/community/doctype/discussion_message/test_discussion_message.py b/community/community/doctype/discussion_topic/test_discussion_topic.py
similarity index 69%
rename from community/community/doctype/discussion_message/test_discussion_message.py
rename to community/community/doctype/discussion_topic/test_discussion_topic.py
index 7d7145a8..56eaec14 100644
--- a/community/community/doctype/discussion_message/test_discussion_message.py
+++ b/community/community/doctype/discussion_topic/test_discussion_topic.py
@@ -4,5 +4,5 @@
# import frappe
import unittest
-class TestDiscussionMessage(unittest.TestCase):
+class TestDiscussionTopic(unittest.TestCase):
pass
diff --git a/community/www/discussions/__init__.py b/community/community/web_template/discussions/__init__.py
similarity index 100%
rename from community/www/discussions/__init__.py
rename to community/community/web_template/discussions/__init__.py
diff --git a/community/community/web_template/discussions/discussions.html b/community/community/web_template/discussions/discussions.html
new file mode 100644
index 00000000..4e4fd0bc
--- /dev/null
+++ b/community/community/web_template/discussions/discussions.html
@@ -0,0 +1,2 @@
+{% set docname = frappe.db.get_value("Web Page", {"route": ""}, ["name"])%}
+{{ widgets.DiscussionMessage(doctype="Web Page", docname=docname) }}
diff --git a/community/community/web_template/discussions/discussions.json b/community/community/web_template/discussions/discussions.json
new file mode 100644
index 00000000..d87fa90d
--- /dev/null
+++ b/community/community/web_template/discussions/discussions.json
@@ -0,0 +1,17 @@
+{
+ "__islocal": true,
+ "__unsaved": 1,
+ "creation": "2021-08-30 12:42:31.550200",
+ "docstatus": 0,
+ "doctype": "Web Template",
+ "fields": [],
+ "idx": 0,
+ "modified": "2021-08-30 12:42:31.550200",
+ "modified_by": "Administrator",
+ "module": "Community",
+ "name": "Discussions",
+ "owner": "Administrator",
+ "standard": 1,
+ "template": "",
+ "type": "Section"
+}
\ No newline at end of file
diff --git a/community/community/widgets/CommentBox.html b/community/community/widgets/CommentBox.html
new file mode 100644
index 00000000..04926a56
--- /dev/null
+++ b/community/community/widgets/CommentBox.html
@@ -0,0 +1,28 @@
+
diff --git a/community/community/widgets/DiscussionComment.html b/community/community/widgets/DiscussionComment.html
deleted file mode 100644
index d5c8e6b9..00000000
--- a/community/community/widgets/DiscussionComment.html
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
diff --git a/community/community/widgets/DiscussionMessage.html b/community/community/widgets/DiscussionMessage.html
index 7e16d966..e5bb3552 100644
--- a/community/community/widgets/DiscussionMessage.html
+++ b/community/community/widgets/DiscussionMessage.html
@@ -1,80 +1,54 @@
-{% if doctype and docname and not thread %}
+{% set topics = frappe.get_all("Discussion Topic",
+{"reference_doctype": doctype, "reference_docname": docname}, ["name", "title", "owner", "creation"]) %}
-{% set thread_info = frappe.get_all("Discussion Thread", {"reference_doctype": doctype, "reference_docname": docname},
-["name"]) %}
+{% include "community/templates/discussions/topic_modal.html" %}
-{% if thread_info | length %}
-{% set thread = thread_info[0].name %}
+
+
+
+ {% if topics %}
+
+
+
+
+
+ {% include "community/templates/discussions/reply_section.html" %}
+
+
+ {% else %}
+
+
+
+
No Discussions
+
There are no discussions for this {{ doctype | lower }}, why don't you start
+ one!
+ {% if frappe.session.user == "Guest" %}
+
Log In
+ {% elif not condition %}
+
+ {{ button_name }}
+
+ {% else %}
+ {% include "community/templates/discussions/button.html" %}
+ {% endif %}
+
+
+
{% endif %}
-
-{% endif %}
-
-{% if thread %}
-{% set messages = frappe.get_all("Discussion Message", {"thread": thread}, ["name", "message", "owner", "creation"],
-order_by="creation") %}
-{% endif %}
-
-{% if doctype %}
- Discussions
-{% endif %}
-
-
- {% for message in messages %}
- {% include "community/templates/message_card.html" %}
- {% endfor %}
-{% if frappe.session.user == "Guest" or (condition is defined and not condition) %}
-
- Want to join the discussion?
- {% if frappe.session.user == "Guest" %}
-
Log In
- {% elif not condition %}
-
{{ button_name }}
- {% endif %}
-
-{% else %}
-{{ widgets.DiscussionComment(doctype=doctype, docname=docname, title=title, thread=thread ) }}
-{% endif %}
-
-
+{% block script %}
+
+{% endblock %}
diff --git a/community/hooks.py b/community/hooks.py
index 31027f41..d3b0c798 100644
--- a/community/hooks.py
+++ b/community/hooks.py
@@ -141,9 +141,8 @@ website_route_rules = [
{"from_route": "/courses//learn/.", "to_route": "batch/learn"},
{"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": "/users/", "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/widgets/ChapterTeaser.html b/community/lms/widgets/ChapterTeaser.html
index 81fd0e6d..8edfa580 100644
--- a/community/lms/widgets/ChapterTeaser.html
+++ b/community/lms/widgets/ChapterTeaser.html
@@ -64,10 +64,11 @@
})
var expand_the_first_chapter = () => {
- var elements = $(".collapse");
+ var elements = $(".course-outline .collapse");
elements.each((i, element) => {
- if (i <= 1) {
+ if (i < 1) {
show_section(element);
+ return false;
}
});
}
diff --git a/community/patches.txt b/community/patches.txt
index 86c39f41..853dd9d0 100644
--- a/community/patches.txt
+++ b/community/patches.txt
@@ -9,3 +9,5 @@ community.patches.replace_member_with_user_in_mentor_request
community.patches.v0_0.chapter_lesson_index_table
execute:frappe.delete_doc("DocType", "LMS Message")
community.patches.v0_0.course_instructor_update
+execute:frappe.delete_doc("DocType", "Discussion Message")
+execute:frappe.delete_doc("DocType", "Discussion Thread")
diff --git a/community/public/css/style.css b/community/public/css/style.css
index 27175ca5..ef6b463a 100644
--- a/community/public/css/style.css
+++ b/community/public/css/style.css
@@ -20,7 +20,6 @@
--received-message: var(--c8);
--checkbox-size: 14px;
--control-bg: var(--gray-100);
- --muted-text: #4C5A67;
--button-background: #EEF0F2;
--text-xs: 11px;
--text-sm: 12px;
@@ -109,8 +108,6 @@ input[type=checkbox] {
.muted-text {
font-size: 12px;
line-height: 135%;
- color: var(--muted-text);
- height: 15px;
}
.course-card-meta {
@@ -146,12 +143,12 @@ input[type=checkbox] {
}
.card-divider {
- border: 1px solid #F4F5F6;
+ border: 1px solid #EEF0F2;
margin-bottom: 1rem;
}
.card-divider-dark {
- border: 1px solid #E2E6E9;
+ border: 1px solid #C8CFD5;
margin-bottom: 16px;
}
@@ -165,7 +162,6 @@ input[type=checkbox] {
.course-student-count {
font-size: 12px;
line-height: 135%;
- color: var(--muted-text);
float: right;
}
@@ -222,8 +218,13 @@ input[type=checkbox] {
}
}
+.button-links {
+ color: #4C5A67;
+}
+
.button-links:hover {
text-decoration: none;
+ color: #4C5A67;
}
.icon-background {
@@ -434,7 +435,7 @@ input[type=checkbox] {
.button {
box-shadow: var(--btn-shadow);
- border-radius: 8px;
+ border-radius: 4px;
cursor: pointer;
display: flex;
align-items: center;
@@ -1282,17 +1283,77 @@ pre {
.thread-card {
flex-direction: column;
- padding: 1.5rem;
+ padding: 1rem;
}
-textarea.form-control {
+.discussions-parent .form-control {
+ background-color: #FFFFFF;
+ font-size: inherit;
+ color: inherit;
+ padding: 0.75rem 1rem;
+}
+
+.discussion-on-page .comment-field {
+ height: 48px;
+ box-shadow: inset 0px 0px 4px rgba(0, 0, 0, 0.2);
+ border-radius: 4px;
+}
+
+.modal .comment-field {
height: 300px;
}
-.discussion-on-page textarea.form-control {
- background-color: #FFFFFF;
- color: inherit;
- height: 160px;
+.no-discussions {
+ width: 250px;
+ margin: 0 auto;
+ text-align: center;
+}
+
+.no-discussions .button {
+ margin: auto;
+}
+
+.discussions-header {
+ margin: 2.5rem 0 1.25rem;
+}
+
+.discussions-header .button {
+ float: right;
+}
+
+.discussions-parent .search-field {
+ background-color: #E2E6E9;
+ background-image: url(/assets/community/icons/search.svg);
+ background-repeat: no-repeat;
+ text-indent: 1.5rem;
+ background-position: 1rem 0.7rem;
+ height: 36px;
+ font-size: 12px;
+ padding: 0.65rem 0.9rem;
+}
+
+.discussions-sidebar {
+ background-color: #F4F5F6;
+ padding: 0.75rem;
+ border-radius: 4px;
+ max-height: 700px;
+ overflow-y: auto;
+}
+
+#discussion-group {
+ max-height: 700px;
+ overflow-y: auto;
+}
+
+.sidebar-topic {
+ padding: 0.75rem;
+ margin: 0.75rem 0;
+ cursor: pointer;
+}
+
+.sidebar-topic[aria-expanded="true"] {
+ background: #FFFFFF;
+ border-radius: 4px;
}
.comment-footer {
@@ -1300,17 +1361,24 @@ textarea.form-control {
justify-content: flex-end;
}
-.comment-field {
- font-size: inherit;
+.reply-card {
+ margin-bottom: 40px;
}
-.thread-title {
- font-size: inherit;
+.discussions-parent .collapsing {
+ transition: height 0s;
}
-.message-author {
- color: #192734;
- margin-left: 0.5rem;
+.discussion-topic-title {
+ color: var(--text-color);
+}
+
+.discussion-on-page .topic-title {
+ display: none;
+}
+
+.discussions-sidebar .sidebar-parent:last-child .card-divider {
+ display: none;
}
.certificate-page .common-card-style {
diff --git a/community/public/icons/message.svg b/community/public/icons/message.svg
index 09bab74d..0f46b786 100644
--- a/community/public/icons/message.svg
+++ b/community/public/icons/message.svg
@@ -1,5 +1,3 @@
-