refactor: refactored the about page

This commit is contained in:
Anand Chitipothu
2021-05-06 06:48:37 +05:30
parent dc5b637ada
commit 761f36519e
5 changed files with 61 additions and 36 deletions

View File

@@ -1,6 +1,5 @@
{
"actions": [],
"autoname": "field:title",
"creation": "2021-03-18 19:37:34.614796",
"doctype": "DocType",
"editable_grid": 1,
@@ -51,10 +50,12 @@
"label": "Description"
},
{
"default": "Public",
"fieldname": "visibility",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Visibility",
"options": "\nPublic\nUnlisted\nPrivate"
"options": "Public\nUnlisted\nPrivate"
},
{
"fieldname": "membership",
@@ -63,16 +64,19 @@
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
},
{
"default": "Active",
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Status",
"options": "\nActive\nInactive"
"options": "Active\nInactive"
},
{
"default": "Ready",
"fieldname": "stage",
"fieldtype": "Select",
"label": "Stage",
"options": "\nReady\nIn Progress\nCompleted\nCancelled"
"options": "Ready\nIn Progress\nCompleted\nCancelled"
},
{
"fieldname": "column_break_3",
@@ -122,7 +126,7 @@
"link_fieldname": "batch"
}
],
"modified": "2021-04-30 09:52:18.941276",
"modified": "2021-05-06 05:46:38.469120",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch",

View File

@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from community.www.courses.utils import get_member_with_email
from community.query import find, find_all
class LMSBatch(Document):
def validate(self):
@@ -23,10 +24,16 @@ class LMSBatch(Document):
"LMS Batch Membership",
{"batch": self.name, "member_type": "Mentor"},
["member"])
for membership in memberships:
member = frappe.db.get_value("Community Member", membership.member, ["full_name", "photo", "abbr"], as_dict=1)
mentors.append(member)
return mentors
member_names = [m['member'] for m in memberships]
return find_all("Community Member", name=["IN", member_names])
def is_member(self, email):
"""Checks if a person is part of a batch.
"""
member = find("Community Member", email=email)
return member and frappe.db.exists(
"LMS Batch Membership",
{"batch": self.name, "member": member.name})
@frappe.whitelist()
def get_messages(batch):

View File

@@ -124,6 +124,9 @@ class LMSCourse(Document):
# TODO: chapters should have a way to specify the order
return find_all("Chapter", course=self.name, order_by="creation")
def get_batch(self, batch_name):
return find("LMS Batch", name=batch_name, course=self.name)
def get_batches(self, mentor=None):
batches = find_all("LMS Batch", course=self.name)
if mentor: