diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index 0019f743..5989f9d1 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -15,6 +15,7 @@ from ...utils import generate_slug, validate_image class LMSCourse(Document): def validate(self): self.validate_instructors() + self.validate_video_link() self.validate_status() self.image = validate_image(self.image) @@ -30,6 +31,10 @@ class LMSCourse(Document): } ).save(ignore_permissions=True) + def validate_video_link(self): + if self.video_link and "/" in self.video_link: + self.video_link = self.video_link.split("/")[-1] + def validate_status(self): if self.published: self.status = "Approved" diff --git a/lms/patches.txt b/lms/patches.txt index b33979c2..ef8606d3 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -46,3 +46,4 @@ lms.patches.v0_0.check_onboarding_status #21-12-2022 lms.patches.v0_0.assignment_file_type lms.patches.v0_0.user_singles_issue #23-11-2022 lms.patches.v0_0.rename_community_to_users #06-01-2023 +lms.patches.v0_0.video_embed_link diff --git a/lms/patches/v0_0/video_embed_link.py b/lms/patches/v0_0/video_embed_link.py new file mode 100644 index 00000000..f57db816 --- /dev/null +++ b/lms/patches/v0_0/video_embed_link.py @@ -0,0 +1,11 @@ +import frappe + + +def execute(): + courses = frappe.get_all( + "LMS Course", {"video_link": ["is", "set"]}, ["name", "video_link"] + ) + for course in courses: + if course.video_link: + link = course.video_link.split("/")[-1] + frappe.db.set_value("LMS Course", course.name, "video_link", link) diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index b57655be..87fe4c31 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -151,7 +151,7 @@
{% if course.video_link %} - {% endif %}