fix: accept only embed id for preview video
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
11
lms/patches/v0_0/video_embed_link.py
Normal file
11
lms/patches/v0_0/video_embed_link.py
Normal file
@@ -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)
|
||||
@@ -151,7 +151,7 @@
|
||||
<div class="course-overlay-card">
|
||||
|
||||
{% if course.video_link %}
|
||||
<iframe class="preview-video" frameborder="0" allowfullscreen src="{{ course.video_link }}"
|
||||
<iframe class="preview-video" frameborder="0" allowfullscreen src="https://www.youtube.com/embed/{{ course.video_link }}"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user