feat: #28 info page, #27 discussion page initial structure, add batch webform change

This commit is contained in:
pateljannat
2021-04-27 10:33:49 +05:30
parent 44dc42d7dd
commit 424967b03e
18 changed files with 372 additions and 185 deletions

View File

@@ -5,6 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from community.www.courses.utils import get_member_with_email
class LMSBatch(Document):
def validate(self):
@@ -15,3 +16,25 @@ class LMSBatch(Document):
short_code = frappe.db.get_value("LMS Course", self.course, "short_code")
course_batches = frappe.get_all("LMS Batch",{"course":self.course})
self.code = short_code + str(len(course_batches) + 1)
@frappe.whitelist()
def get_messages(batch):
messages = frappe.get_all("LMS Message", {"batch": batch}, ["*"], order_by="creation")
for message in messages:
message.message = frappe.utils.md_to_html(message.message)
member_email = frappe.db.get_value("Community Member", message.author, ["email"])
if member_email == frappe.session.user:
message.author_name = "You"
message.is_author = True
return messages
@frappe.whitelist()
def save_message(message, batch):
doc = frappe.get_doc({
"doctype": "LMS Message",
"batch": batch,
"author": get_member_with_email(),
"message": message
})
doc.save(ignore_permissions=True)
return doc

View File

@@ -39,7 +39,6 @@
{
"fieldname": "role",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Role",
"options": "\nMember\nAdmin"
@@ -59,7 +58,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-04-22 15:30:00.069946",
"modified": "2021-04-26 12:52:59.826509",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch Membership",

View File

@@ -5,10 +5,13 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"batch",
"author",
"message",
"pin"
"batch",
"column_break_3",
"author_name",
"pin",
"section_break_6",
"message"
],
"fields": [
{
@@ -36,11 +39,26 @@
"fieldname": "pin",
"fieldtype": "Check",
"label": "Pin"
},
{
"fetch_from": "author.full_name",
"fieldname": "author_name",
"fieldtype": "Data",
"label": "Author Name",
"read_only": 1
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_6",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-03-23 18:06:25.086377",
"modified": "2021-04-26 16:11:20.142164",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Message",

View File

@@ -9,9 +9,7 @@ from frappe import _
from frappe.utils import add_days, nowdate
class LMSMessage(Document):
def after_insert(self):
message = self.as_dict()
message['broadcast'] = True
frappe.publish_realtime('new_lms_message', message, after_commit=True)
frappe.publish_realtime("new_lms_message", {"message":"JJannat"}, user="Administrator")
self.send_email()
def send_email(self):

View File

@@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2021-04-21 16:39:09.457653",
"modified": "2021-04-26 11:08:00.026388",
"modified_by": "Administrator",
"module": "LMS",
"name": "add-a-new-batch",
@@ -47,41 +47,6 @@
"reqd": 0,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "start_date",
"fieldtype": "Date",
"hidden": 0,
"label": "Start Date",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "start_time",
"fieldtype": "Data",
"hidden": 0,
"label": "Start Time (HH:MM:SS)",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "",
"fieldtype": "Column Break",
"hidden": 0,
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "title",
@@ -94,6 +59,18 @@
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "start_date",
"fieldtype": "Date",
"hidden": 0,
"label": "Start Date",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"description": "",
@@ -108,6 +85,18 @@
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "start_time",
"fieldtype": "Data",
"hidden": 0,
"label": "Start Time (HH:MM:SS)",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "end_time",