chore: removed obsolete doctype LMS Topic
It has been replaced by Chapter and Lesson. Moved the section_parser from lms_topic directory to the lms.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from ..lms_topic.section_parser import SectionParser
|
||||
from ...section_parser import SectionParser
|
||||
|
||||
class Lesson(Document):
|
||||
def before_save(self):
|
||||
|
||||
@@ -35,17 +35,6 @@ class LMSCourse(Document):
|
||||
def __repr__(self):
|
||||
return f"<Course#{self.name}>"
|
||||
|
||||
def get_topic(self, slug):
|
||||
"""Returns the topic with given slug in this course as a Document.
|
||||
"""
|
||||
result = frappe.get_all(
|
||||
"LMS Topic",
|
||||
filters={"course": self.name, "slug": slug})
|
||||
|
||||
if result:
|
||||
row = result[0]
|
||||
return frappe.get_doc('LMS Topic', row['name'])
|
||||
|
||||
def has_mentor(self, email):
|
||||
"""Checks if this course has a mentor with given email.
|
||||
"""
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Topic', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -1,89 +0,0 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_guest_to_view": 1,
|
||||
"creation": "2021-03-02 07:20:41.686573",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"course",
|
||||
"title",
|
||||
"slug",
|
||||
"preview",
|
||||
"description",
|
||||
"order",
|
||||
"sections"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Course",
|
||||
"options": "LMS Course",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "order",
|
||||
"fieldtype": "Int",
|
||||
"label": "Order"
|
||||
},
|
||||
{
|
||||
"fieldname": "preview",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"label": "Preview"
|
||||
},
|
||||
{
|
||||
"fieldname": "sections",
|
||||
"fieldtype": "Table",
|
||||
"label": "Sections",
|
||||
"options": "LMS Section"
|
||||
},
|
||||
{
|
||||
"description": "The slug of the topic. Autogenerated from the title if not specified.",
|
||||
"fieldname": "slug",
|
||||
"fieldtype": "Data",
|
||||
"label": "Slug"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-04-06 14:12:48.514062",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Topic",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"search_fields": "title",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "ASC",
|
||||
"title_field": "title",
|
||||
"track_changes": 1,
|
||||
"track_seen": 1,
|
||||
"track_views": 1
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
# -*- 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 .section_parser import SectionParser
|
||||
from ...utils import slugify
|
||||
|
||||
class LMSTopic(Document):
|
||||
def before_save(self):
|
||||
course = self.get_course()
|
||||
if not self.slug:
|
||||
self.slug = self.generate_slug(title=self.title)
|
||||
|
||||
sections = SectionParser().parse(self.description or "")
|
||||
self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)]
|
||||
|
||||
def get_course(self):
|
||||
return frappe.get_doc("LMS Course", self.course)
|
||||
|
||||
def generate_slug(self, title):
|
||||
result = frappe.get_all(
|
||||
'LMS Topic',
|
||||
filters={'course': self.course},
|
||||
fields=['slug'])
|
||||
slugs = set([row['slug'] for row in result])
|
||||
return slugify(title, used_slugs=slugs)
|
||||
|
||||
def get_sections(self):
|
||||
return sorted(self.sections, key=lambda s: s.index)
|
||||
|
||||
def make_lms_section(self, index, section):
|
||||
s = frappe.new_doc('LMS Section', parent_doc=self, parentfield='sections')
|
||||
s.type = section.type
|
||||
s.label = section.label
|
||||
s.contents = section.contents
|
||||
s.index = index
|
||||
return s
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSTopic(unittest.TestCase):
|
||||
pass
|
||||
Reference in New Issue
Block a user