refactor: fixed the course page

This commit is contained in:
Anand Chitipothu
2021-05-06 06:47:09 +05:30
parent da902d23f7
commit dc5b637ada
11 changed files with 191 additions and 141 deletions

View File

@@ -2,7 +2,7 @@
"actions": [],
"allow_guest_to_view": 1,
"allow_rename": 1,
"autoname": "field:title",
"autoname": "field:slug",
"creation": "2021-03-01 16:49:33.622422",
"doctype": "DocType",
"editable_grid": 1,
@@ -89,7 +89,7 @@
"link_fieldname": "course"
}
],
"modified": "2021-05-03 05:52:30.396824",
"modified": "2021-05-06 06:06:08.760597",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",

View File

@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from ...utils import slugify
from community.query import find, find_all
class LMSCourse(Document):
@staticmethod
@@ -139,24 +140,8 @@ class LMSCourse(Document):
now = frappe.utils.nowdate()
batches = find_all("LMS Batch",
course=self.name,
start_date=[">", now])
start_date=[">", now],
status="Active",
visibility="Public")
return batches
def find_all(doctype, order_by=None, **filters):
"""Queries the database for documents of a doctype matching given filters.
"""
rows = frappe.db.get_all(doctype,
filters=filters,
fields='*',
order_by=order_by)
return [frappe.get_doc(dict(row, doctype=doctype)) for row in rows]
def find(doctype, **filters):
"""Queries the database for a document of given doctype matching given filters.
"""
rows = frappe.db.get_all(doctype,
filters=filters,
fields='*')
if rows:
row = rows[0]
return frappe.get_doc(dict(row, doctype=doctype))

View File

@@ -1,6 +1,6 @@
<div class="chapter-teaser">
<div class="teaser-body">
<h3 class="chapter-title">{{ chapter.title }}</h3>
<h3 class="chapter-title"><span class="chapter-number">{{index}}</span> {{ chapter.title }}</h3>
<div class="chapter-description">
{{ chapter.description or "" }}
</div>