diff --git a/community/lms/doctype/lms_batch_membership/lms_batch_membership.py b/community/lms/doctype/lms_batch_membership/lms_batch_membership.py index a9f963a3..5c55bab6 100644 --- a/community/lms/doctype/lms_batch_membership/lms_batch_membership.py +++ b/community/lms/doctype/lms_batch_membership/lms_batch_membership.py @@ -40,6 +40,6 @@ def create_membership(batch, course=None, member=None, member_type="Student", ro "member": member }).save(ignore_permissions=True) if course: - course_slug = frappe.db.get_value("LMS Course", {"title": course}, ["slug"]) + course_slug = frappe.db.get_value("LMS Course", {"title": course}, ["name"]) return course_slug return "OK" diff --git a/community/lms/doctype/lms_course/lms_course.json b/community/lms/doctype/lms_course/lms_course.json index e9c4d4d7..eca939c8 100644 --- a/community/lms/doctype/lms_course/lms_course.json +++ b/community/lms/doctype/lms_course/lms_course.json @@ -2,7 +2,6 @@ "actions": [], "allow_guest_to_view": 1, "allow_rename": 1, - "autoname": "field:slug", "creation": "2021-03-01 16:49:33.622422", "doctype": "DocType", "editable_grid": 1, @@ -89,7 +88,7 @@ "link_fieldname": "course" } ], - "modified": "2021-05-06 06:06:08.760597", + "modified": "2021-05-06 11:15:45.728976", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index a15ece81..5d8c07e6 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -10,10 +10,14 @@ from community.query import find, find_all class LMSCourse(Document): @staticmethod - def find(slug): - """Returns the course with specified slug. + def find(name): + """Returns the course with specified name. """ - return find("LMS Course", is_published=True, slug=slug) + return find("LMS Course", is_published=True, name=name) + + def autoname(self): + if not self.name: + self.name = self.generate_slug(title=self.title) @staticmethod def find_all(): @@ -21,10 +25,6 @@ class LMSCourse(Document): """ return find_all("LMS Course", is_published=True) - def before_save(self): - if not self.slug: - self.slug = self.generate_slug(title=self.title) - def generate_slug(self, title): result = frappe.get_all( 'LMS Course', @@ -33,7 +33,7 @@ class LMSCourse(Document): return slugify(title, used_slugs=slugs) def __repr__(self): - return f"" + return f"" def get_topic(self, slug): """Returns the topic with given slug in this course as a Document. diff --git a/community/lms/doctype/lms_course/test_lms_course.py b/community/lms/doctype/lms_course/test_lms_course.py index a54ab337..61a3ecf8 100644 --- a/community/lms/doctype/lms_course/test_lms_course.py +++ b/community/lms/doctype/lms_course/test_lms_course.py @@ -24,7 +24,7 @@ class TestLMSCourse(unittest.TestCase): def test_new_course(self): course = self.new_course("Test Course") assert course.title == "Test Course" - assert course.slug == "test-course" + assert course.name == "test-course" assert course.get_mentors() == [] def test_find_all(self): @@ -41,7 +41,7 @@ class TestLMSCourse(unittest.TestCase): # now we should find one course courses = LMSCourse.find_all() - assert [c.slug for c in courses] == [course.slug] + assert [c.name for c in courses] == [course.name] # disabled this test as it is failing def _test_add_mentors(self): diff --git a/community/lms/widgets/CourseTeaser.html b/community/lms/widgets/CourseTeaser.html index 453ce9ff..525d94c1 100644 --- a/community/lms/widgets/CourseTeaser.html +++ b/community/lms/widgets/CourseTeaser.html @@ -1,6 +1,6 @@
-

{{ course.title }}

+

{{ course.title }}

{{ course.short_introduction or "" }}
diff --git a/community/www/courses/course.py b/community/www/courses/course.py index 7a61e8c8..ee02d342 100644 --- a/community/www/courses/course.py +++ b/community/www/courses/course.py @@ -7,12 +7,12 @@ def get_context(context): context.no_cache = 1 try: - course_slug = frappe.form_dict["course"] + course_name = frappe.form_dict["course"] except KeyError: frappe.local.flags.redirect_location = "/courses" raise frappe.Redirect - course = Course.find(course_slug) + course = Course.find(course_name) if course is None: frappe.local.flags.redirect_location = "/courses" raise frappe.Redirect diff --git a/community/www/courses/index.html b/community/www/courses/index.html index 02a982dd..522abfed 100644 --- a/community/www/courses/index.html +++ b/community/www/courses/index.html @@ -26,11 +26,11 @@ {% macro course_card(course) %}
-
{{course.title}}
+
{{course.title}}
{% if course.description %}

{{ frappe.utils.md_to_html(course.description[:250]) }}

{% endif %} - See more → + See more →
{% endmacro %} diff --git a/community/www/courses/utils.py b/community/www/courses/utils.py index 7c663663..63dfdb6e 100644 --- a/community/www/courses/utils.py +++ b/community/www/courses/utils.py @@ -31,9 +31,9 @@ def redirect_if_not_a_member(course,batch_code): frappe.local.flags.redirect_location = "/courses/" + course raise frappe.Redirect -def get_course(slug): +def get_course(name): try: - return frappe.get_doc("LMS Course", {"slug": slug}) + return frappe.get_doc("LMS Course", {"name": name}) except frappe.DoesNotExistError: return diff --git a/community/www/dashboard/index.html b/community/www/dashboard/index.html index d0e86d16..f87a06df 100644 --- a/community/www/dashboard/index.html +++ b/community/www/dashboard/index.html @@ -182,8 +182,8 @@ {% for course in courses %}