feat: discussions tab and web form for messages
This commit is contained in:
0
community/lms/doctype/lms_batch/__init__.py
Normal file
0
community/lms/doctype/lms_batch/__init__.py
Normal file
8
community/lms/doctype/lms_batch/lms_batch.js
Normal file
8
community/lms/doctype/lms_batch/lms_batch.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Batch', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
113
community/lms/doctype/lms_batch/lms_batch.json
Normal file
113
community/lms/doctype/lms_batch/lms_batch.json
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"actions": [],
|
||||
"autoname": "field:title",
|
||||
"creation": "2021-03-18 19:37:34.614796",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"course",
|
||||
"title",
|
||||
"column_break_3",
|
||||
"code",
|
||||
"section_break_5",
|
||||
"description",
|
||||
"section_break_7",
|
||||
"visibility",
|
||||
"membership",
|
||||
"column_break_9",
|
||||
"status",
|
||||
"stage"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"label": "Course",
|
||||
"options": "LMS Course"
|
||||
},
|
||||
{
|
||||
"fieldname": "code",
|
||||
"fieldtype": "Data",
|
||||
"label": "Code",
|
||||
"read_only": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Title",
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "visibility",
|
||||
"fieldtype": "Select",
|
||||
"label": "Visibility",
|
||||
"options": "\nPublic\nUnlisted\nPrivate"
|
||||
},
|
||||
{
|
||||
"fieldname": "membership",
|
||||
"fieldtype": "Select",
|
||||
"label": "Membership",
|
||||
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
||||
},
|
||||
{
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"label": "Status",
|
||||
"options": "\nActive\nInactive"
|
||||
},
|
||||
{
|
||||
"fieldname": "stage",
|
||||
"fieldtype": "Select",
|
||||
"label": "Stage",
|
||||
"options": "\nReady\nIn Progress\nCompleted\nCancelled"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_5",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-03-19 12:56:33.054884",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
17
community/lms/doctype/lms_batch/lms_batch.py
Normal file
17
community/lms/doctype/lms_batch/lms_batch.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LMSBatch(Document):
|
||||
def validate(self):
|
||||
if not self.code:
|
||||
self.generate_code()
|
||||
|
||||
def generate_code(self):
|
||||
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)
|
||||
10
community/lms/doctype/lms_batch/test_lms_batch.py
Normal file
10
community/lms/doctype/lms_batch/test_lms_batch.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSBatch(unittest.TestCase):
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Batch Membership', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-03-18 19:52:10.673835",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"batch",
|
||||
"member",
|
||||
"member_type",
|
||||
"role"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "batch",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Batch",
|
||||
"options": "LMS Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "member",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Member",
|
||||
"options": "Community Member"
|
||||
},
|
||||
{
|
||||
"fieldname": "member_type",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Member Type",
|
||||
"options": "\nStudent\nMentor\nStaff"
|
||||
},
|
||||
{
|
||||
"fieldname": "role",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Role",
|
||||
"options": "\nMember\nAdmin"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-03-19 15:06:21.374601",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch Membership",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
|
||||
class LMSBatchMembership(Document):
|
||||
|
||||
def validate(self):
|
||||
self.validate_membership_in_same_batch()
|
||||
self.validate_membership_in_different_batch_same_course()
|
||||
|
||||
def validate_membership_in_same_batch(self):
|
||||
previous_membership = frappe.db.get_value("LMS Batch Membership", {"member": self.member, "batch": self.batch}, ["member_type","member"], as_dict=1)
|
||||
if previous_membership:
|
||||
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
||||
frappe.throw(_("{0} is already a {1} of {2}").format(member_name, previous_membership.member_type, self.batch))
|
||||
|
||||
def validate_membership_in_different_batch_same_course(self):
|
||||
course = frappe.db.get_value("LMS Batch", self.batch, "course")
|
||||
previous_membership = frappe.get_all("LMS Batch Membership", {"member": self.member}, ["batch", "member_type"])
|
||||
for membership in previous_membership:
|
||||
batch_course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
||||
if batch_course == course and (membership.member_type == "Student" or self.member_type == "Student"):
|
||||
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
||||
frappe.throw(_("{0} is already a {1} of {2} course through {3} batch").format(member_name, membership.member_type, course, membership.batch))
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSBatchMembership(unittest.TestCase):
|
||||
pass
|
||||
@@ -10,7 +10,10 @@
|
||||
"field_order": [
|
||||
"title",
|
||||
"description",
|
||||
"is_published"
|
||||
"section_break_3",
|
||||
"is_published",
|
||||
"column_break_5",
|
||||
"short_code"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -31,12 +34,25 @@
|
||||
"fieldname": "is_published",
|
||||
"fieldtype": "Check",
|
||||
"label": "Published"
|
||||
},
|
||||
{
|
||||
"fieldname": "short_code",
|
||||
"fieldtype": "Data",
|
||||
"label": "Short Code"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_3",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_5",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_published_field": "is_published",
|
||||
"links": [],
|
||||
"modified": "2021-03-05 11:01:09.327111",
|
||||
"modified": "2021-03-19 15:44:47.411705",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
0
community/lms/doctype/lms_message/__init__.py
Normal file
0
community/lms/doctype/lms_message/__init__.py
Normal file
8
community/lms/doctype/lms_message/lms_message.js
Normal file
8
community/lms/doctype/lms_message/lms_message.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Message', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
63
community/lms/doctype/lms_message/lms_message.json
Normal file
63
community/lms/doctype/lms_message/lms_message.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-03-19 12:19:32.355307",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"batch",
|
||||
"author",
|
||||
"message",
|
||||
"pin"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "batch",
|
||||
"fieldtype": "Link",
|
||||
"label": "Batch",
|
||||
"options": "LMS Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "author",
|
||||
"fieldtype": "Link",
|
||||
"label": "Author",
|
||||
"options": "Community Member"
|
||||
},
|
||||
{
|
||||
"fieldname": "message",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"label": "Message"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "pin",
|
||||
"fieldtype": "Check",
|
||||
"label": "Pin"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-03-22 13:57:50.500746",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Message",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
10
community/lms/doctype/lms_message/lms_message.py
Normal file
10
community/lms/doctype/lms_message/lms_message.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LMSMessage(Document):
|
||||
pass
|
||||
10
community/lms/doctype/lms_message/test_lms_message.py
Normal file
10
community/lms/doctype/lms_message/test_lms_message.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSMessage(unittest.TestCase):
|
||||
pass
|
||||
0
community/lms/web_form/__init__.py
Normal file
0
community/lms/web_form/__init__.py
Normal file
0
community/lms/web_form/add_messages/__init__.py
Normal file
0
community/lms/web_form/add_messages/__init__.py
Normal file
12
community/lms/web_form/add_messages/add_messages.js
Normal file
12
community/lms/web_form/add_messages/add_messages.js
Normal file
@@ -0,0 +1,12 @@
|
||||
frappe.ready(function() {
|
||||
// bind events here
|
||||
frappe.web_form.after_load = () => {
|
||||
frappe.web_form.set_value(["batch"], [frappe.utils.get_url_arg('batch')]);
|
||||
frappe.web_form.set_value(["author"], [frappe.utils.get_url_arg('author')]);
|
||||
}
|
||||
frappe.web_form.success_url = `courses/course?course=${frappe.utils.get_url_arg('course')}`;
|
||||
|
||||
$('.breadcrumb-container')
|
||||
.html(`<a href="${frappe.web_form.success_url}">Back to my course</a>`)
|
||||
.addClass('py-4');
|
||||
})
|
||||
77
community/lms/web_form/add_messages/add_messages.json
Normal file
77
community/lms/web_form/add_messages/add_messages.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"accept_payment": 0,
|
||||
"allow_comments": 0,
|
||||
"allow_delete": 0,
|
||||
"allow_edit": 0,
|
||||
"allow_incomplete": 0,
|
||||
"allow_multiple": 0,
|
||||
"allow_print": 0,
|
||||
"amount": 0.0,
|
||||
"amount_based_on_field": 0,
|
||||
"apply_document_permissions": 0,
|
||||
"button_label": "Send",
|
||||
"client_script": "",
|
||||
"creation": "2021-03-23 13:10:16.814983",
|
||||
"doc_type": "LMS Message",
|
||||
"docstatus": 0,
|
||||
"doctype": "Web Form",
|
||||
"idx": 0,
|
||||
"is_standard": 1,
|
||||
"login_required": 1,
|
||||
"max_attachment_size": 0,
|
||||
"modified": "2021-03-23 15:10:24.681090",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "add-messages",
|
||||
"owner": "Administrator",
|
||||
"payment_button_label": "Buy Now",
|
||||
"published": 1,
|
||||
"route": "add-messages",
|
||||
"route_to_success_link": 0,
|
||||
"show_attachments": 0,
|
||||
"show_in_grid": 0,
|
||||
"show_sidebar": 0,
|
||||
"sidebar_items": [],
|
||||
"success_url": "",
|
||||
"title": "Add Messages",
|
||||
"web_form_fields": [
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "batch",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Batch",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"options": "LMS Batch",
|
||||
"read_only": 1,
|
||||
"reqd": 0,
|
||||
"show_in_filter": 0
|
||||
},
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "message",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"label": "Message",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"show_in_filter": 0
|
||||
},
|
||||
{
|
||||
"allow_read_on_all_link_options": 0,
|
||||
"fieldname": "author",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"label": "Author",
|
||||
"max_length": 0,
|
||||
"max_value": 0,
|
||||
"options": "Community Member",
|
||||
"read_only": 1,
|
||||
"reqd": 0,
|
||||
"show_in_filter": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
7
community/lms/web_form/add_messages/add_messages.py
Normal file
7
community/lms/web_form/add_messages/add_messages.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
Reference in New Issue
Block a user