fix: misc fixes

This commit is contained in:
Jannat Patel
2024-04-30 10:52:35 +05:30
parent e7d7cffbc5
commit d9ad642a31
7 changed files with 39 additions and 6 deletions

View File

@@ -97,7 +97,13 @@ def create_certificate(course):
},
"value",
)
if not default_certificate_template:
default_certificate_template = frappe.db.get_value(
"Print Format",
{
"doc_type": "LMS Certificate",
},
)
certificate = frappe.get_doc(
{
"doctype": "LMS Certificate",

View File

@@ -5,7 +5,7 @@ import json
import random
import frappe
from frappe.model.document import Document
from frappe.utils import cint
from frappe.utils import cint, today
from frappe.utils.telemetry import capture
from lms.lms.utils import get_chapters, can_create_courses
from ...utils import generate_slug, validate_image
@@ -14,11 +14,16 @@ from frappe import _
class LMSCourse(Document):
def validate(self):
self.validate_published()
self.validate_instructors()
self.validate_video_link()
self.validate_status()
self.image = validate_image(self.image)
def validate_published(self):
if self.published and not self.published_on:
self.published_on = today()
def validate_instructors(self):
if self.is_new() and not self.instructors:
frappe.get_doc(

View File

@@ -72,6 +72,8 @@ def new_course(title, additional_filters=None):
"title": title,
"short_introduction": title,
"description": title,
"video_link": "https://youtu.be/pEbIhUySqbk",
"image": "/assets/lms/images/course-home.png",
}
if additional_filters:

View File

@@ -32,6 +32,14 @@ def get_meta(app_path):
}
if re.match(r"^courses/.*$", app_path):
if "new/edit" in app_path:
return {
"title": _("New Course"),
"image": frappe.db.get_single_value("Website Settings", "banner_image"),
"description": "Create a new course",
"keywords": "New Course, Create Course",
"link": "/lms/courses/new/edit",
}
course_name = app_path.split("/")[1]
course = frappe.db.get_value(
"LMS Course",
@@ -56,7 +64,6 @@ def get_meta(app_path):
"link": "/batches",
}
if re.match(r"^batches/details/.*$", app_path):
print(app_path, "app_path")
batch_name = app_path.split("/")[2]
batch = frappe.db.get_value(
"LMS Batch",