feat: meta for batches
This commit is contained in:
@@ -61,7 +61,7 @@ const props = defineProps({
|
||||
const { logout, user } = sessionStore()
|
||||
let { isLoggedIn } = sessionStore()
|
||||
const userDropdownOptions = [
|
||||
{
|
||||
/* {
|
||||
icon: User,
|
||||
label: 'My Profile',
|
||||
onClick: () => {
|
||||
@@ -70,7 +70,7 @@ const userDropdownOptions = [
|
||||
condition: () => {
|
||||
return isLoggedIn
|
||||
},
|
||||
},
|
||||
}, */
|
||||
{
|
||||
icon: LogOut,
|
||||
label: 'Log out',
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
:buttonLabel="
|
||||
type == 'course' ? 'Checkout Courses' : 'Checkout Batches'
|
||||
"
|
||||
:buttonLink="type == 'course' ? '/courses' : '/batches'"
|
||||
:buttonLink="type == 'course' ? '/lms/courses' : '/lms/batches'"
|
||||
/>
|
||||
</div>
|
||||
<div v-else-if="!user.data?.name">
|
||||
|
||||
@@ -315,10 +315,6 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
const redirectToLogin = () => {
|
||||
window.location.href = `/login?redirect_to=/courses/${props.courseName}/learn/${route.params.chapterNumber}-${route.params.lessonNumber}`
|
||||
}
|
||||
|
||||
const allowDiscussions = () => {
|
||||
return (
|
||||
lesson.data?.membership ||
|
||||
|
||||
21
lms/hooks.py
21
lms/hooks.py
@@ -140,8 +140,25 @@ website_route_rules = [
|
||||
|
||||
website_redirects = [
|
||||
{"source": "/update-profile", "target": "/edit-profile"},
|
||||
{"source": "/dashboard", "target": "/courses"},
|
||||
{"source": "/community", "target": "/people"},
|
||||
{"source": "/courses", "target": "/lms/courses"},
|
||||
{
|
||||
"source": r"/courses/(.*)",
|
||||
"target": "/lms/courses",
|
||||
"match_with_query_string": True,
|
||||
},
|
||||
{"source": "/batches", "target": "/lms/batches"},
|
||||
{
|
||||
"source": r"/batches/(.*)",
|
||||
"target": "/lms/batches",
|
||||
"match_with_query_string": True,
|
||||
},
|
||||
{"source": "/job-openings", "target": "/lms/job-openings"},
|
||||
{
|
||||
"source": r"/job-openings/(.*)",
|
||||
"target": "/lms/job-openings",
|
||||
"match_with_query_string": True,
|
||||
},
|
||||
{"source": "/statistics", "target": "/lms/statistics"},
|
||||
]
|
||||
|
||||
update_website_context = [
|
||||
|
||||
@@ -16,11 +16,10 @@ def after_sync():
|
||||
def add_pages_to_nav():
|
||||
pages = [
|
||||
{"label": "Explore", "idx": 1},
|
||||
{"label": "Courses", "url": "/courses", "parent": "Explore", "idx": 2},
|
||||
{"label": "Batches", "url": "/batches", "parent": "Explore", "idx": 3},
|
||||
{"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 4},
|
||||
{"label": "Jobs", "url": "/job-openings", "parent": "Explore", "idx": 5},
|
||||
{"label": "People", "url": "/community", "parent": "Explore", "idx": 6},
|
||||
{"label": "Courses", "url": "/lms/courses", "parent": "Explore", "idx": 2},
|
||||
{"label": "Batches", "url": "/lms/batches", "parent": "Explore", "idx": 3},
|
||||
{"label": "Statistics", "url": "/lms/statistics", "parent": "Explore", "idx": 4},
|
||||
{"label": "Jobs", "url": "/lms/job-openings", "parent": "Explore", "idx": 5},
|
||||
]
|
||||
|
||||
for page in pages:
|
||||
|
||||
@@ -7,7 +7,7 @@ from frappe.model.document import Document
|
||||
|
||||
class Cohort(Document):
|
||||
def get_url(self):
|
||||
return f"{frappe.utils.get_url()}/courses/{self.course}/cohorts/{self.slug}"
|
||||
return f"{frappe.utils.get_url()}/lms/courses/{self.course}/cohorts/{self.slug}"
|
||||
|
||||
def get_subgroups(self, include_counts=False, sort_by=None):
|
||||
names = frappe.get_all("Cohort Subgroup", filters={"cohort": self.name}, pluck="name")
|
||||
|
||||
@@ -13,13 +13,11 @@ class CohortSubgroup(Document):
|
||||
|
||||
def get_url(self):
|
||||
cohort = frappe.get_doc("Cohort", self.cohort)
|
||||
return (
|
||||
f"{frappe.utils.get_url()}/courses/{self.course}/subgroups/{cohort.slug}/{self.slug}"
|
||||
)
|
||||
return f"{frappe.utils.get_url()}/lms/courses/{self.course}/subgroups/{cohort.slug}/{self.slug}"
|
||||
|
||||
def get_invite_link(self):
|
||||
cohort = frappe.get_doc("Cohort", self.cohort)
|
||||
return f"{frappe.utils.get_url()}/courses/{self.course}/join/{cohort.slug}/{self.slug}/{self.invite_code}"
|
||||
return f"{frappe.utils.get_url()}/lms/courses/{self.course}/join/{cohort.slug}/{self.slug}/{self.invite_code}"
|
||||
|
||||
def has_student(self, email):
|
||||
"""Check if given user is a student of this subgroup."""
|
||||
|
||||
@@ -22,7 +22,7 @@ frappe.ui.form.on("LMS Certificate", {
|
||||
refresh: (frm) => {
|
||||
if (frm.doc.name)
|
||||
frm.add_web_link(
|
||||
`/courses/${frm.doc.course}/${frm.doc.name}`,
|
||||
`/lms/courses/${frm.doc.course}/${frm.doc.name}`,
|
||||
"See on Website"
|
||||
);
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ frappe.ui.form.on("LMS Course", {
|
||||
});
|
||||
},
|
||||
refresh: (frm) => {
|
||||
frm.add_web_link(`/courses/${frm.doc.name}`, "See on Website");
|
||||
frm.add_web_link(`/lms/courses/${frm.doc.name}`, "See on Website");
|
||||
|
||||
if (!frm.doc.currency)
|
||||
frappe.db
|
||||
|
||||
@@ -53,7 +53,7 @@ class LMSCourse(Document):
|
||||
subject = self.title + " is available!"
|
||||
args = {
|
||||
"title": self.title,
|
||||
"course_link": f"/courses/{self.name}",
|
||||
"course_link": f"/lms/courses/{self.name}",
|
||||
"app_name": frappe.db.get_single_value("System Settings", "app_name"),
|
||||
"site_url": frappe.utils.get_url(),
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class LMSMentorRequest(Document):
|
||||
email_template.response,
|
||||
{
|
||||
"member_name": frappe.db.get_value("User", frappe.session.user, "full_name"),
|
||||
"course_url": "/courses/" + course_details.slug,
|
||||
"course_url": "/lms/courses/" + course_details.slug,
|
||||
"course": course_details.title,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
frappe.pages["lms-home"].on_page_load = function (wrapper) {
|
||||
window.location.href = "/courses";
|
||||
window.location.href = "/lms/courses";
|
||||
};
|
||||
|
||||
@@ -290,7 +290,7 @@ def get_lesson_index(lesson_name):
|
||||
def get_lesson_url(course, lesson_number):
|
||||
if not lesson_number:
|
||||
return
|
||||
return f"/courses/{course}/learn/{lesson_number}"
|
||||
return f"/lms/courses/{course}/learn/{lesson_number}"
|
||||
|
||||
|
||||
def get_batch(course, batch_name):
|
||||
@@ -519,7 +519,7 @@ def first_lesson_exists(course):
|
||||
|
||||
|
||||
def redirect_to_courses_list():
|
||||
frappe.local.flags.redirect_location = "/courses"
|
||||
frappe.local.flags.redirect_location = "/lms/courses"
|
||||
raise frappe.Redirect
|
||||
|
||||
|
||||
@@ -1138,7 +1138,7 @@ def create_membership(course, payment):
|
||||
{"member": frappe.session.user, "course": course, "payment": payment.name}
|
||||
)
|
||||
membership.save(ignore_permissions=True)
|
||||
return f"/courses/{course}/learn/1-1"
|
||||
return f"/lms/courses/{course}/learn/1-1"
|
||||
|
||||
|
||||
def add_student_to_batch(batchname, payment):
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{{ widgets.CourseCard(course=course, read_only=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<a class="d-flex justify-content-center align-items-center mt-12" href="/courses">
|
||||
<a class="d-flex justify-content-center align-items-center mt-12" href="/lms/courses">
|
||||
<span>{{ _("Explore More") }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -84,4 +84,5 @@ lms.patches.v1_0.batch_tabs_settings
|
||||
execute:frappe.delete_doc("Notification", "Assignment Submission Notification")
|
||||
lms.patches.v1_0.change_jobs_url #19-01-2024
|
||||
lms.patches.v1_0.custom_perm_for_discussions #14-01-2024
|
||||
lms.patches.v1_0.rename_evaluator_role
|
||||
lms.patches.v1_0.rename_evaluator_role
|
||||
lms.patches.v1_0.change_navbar_urls
|
||||
23
lms/patches/v1_0/change_navbar_urls.py
Normal file
23
lms/patches/v1_0/change_navbar_urls.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
rename_link("/courses", "/lms/courses")
|
||||
rename_link("/batches", "/lms/batches")
|
||||
rename_link("/statistics", "/lms/statistics")
|
||||
rename_link("/job-openings", "/lms/job-openings")
|
||||
delete_link("/people")
|
||||
|
||||
|
||||
def rename_link(source, target):
|
||||
link = frappe.db.exists("Top Bar Item", {"url": source})
|
||||
|
||||
if link:
|
||||
frappe.db.set_value("Top Bar Item", link, "url", target)
|
||||
|
||||
|
||||
def delete_link(source):
|
||||
link = frappe.db.exists("Top Bar Item", {"url": source})
|
||||
|
||||
if link:
|
||||
frappe.delete_doc("Top Bar Item", link)
|
||||
@@ -1,15 +1,18 @@
|
||||
import frappe
|
||||
from frappe.utils.telemetry import capture
|
||||
from frappe import _
|
||||
import re
|
||||
|
||||
no_cache = 1
|
||||
|
||||
|
||||
def get_context():
|
||||
app_path = frappe.form_dict.get("app_path")
|
||||
print(app_path)
|
||||
context = frappe._dict()
|
||||
context.meta = get_meta(app_path)
|
||||
if app_path:
|
||||
context.meta = get_meta(app_path)
|
||||
else:
|
||||
context.meta = {}
|
||||
csrf_token = frappe.sessions.get_csrf_token()
|
||||
frappe.db.commit()
|
||||
context.csrf_token = csrf_token
|
||||
@@ -26,6 +29,45 @@ def get_meta(app_path):
|
||||
"description": "This page lists all the courses published on our website",
|
||||
"keywords": "All Courses, Courses, Learn",
|
||||
}
|
||||
|
||||
if re.match(r"^courses/.*$", app_path):
|
||||
course_name = app_path.split("/")[1]
|
||||
course = frappe.db.get_value(
|
||||
"LMS Course",
|
||||
course_name,
|
||||
["title", "image", "short_introduction", "tags"],
|
||||
as_dict=True,
|
||||
)
|
||||
return {
|
||||
"title": course.title,
|
||||
"image": course.image,
|
||||
"description": course.short_introduction,
|
||||
"keywords": course.tags,
|
||||
}
|
||||
|
||||
if app_path == "batches":
|
||||
return {
|
||||
"title": _("Batches"),
|
||||
"image": frappe.db.get_single_value("Website Settings", "banner_image"),
|
||||
"description": "This page lists all the batches published on our website",
|
||||
"keywords": "All Batches, Batches, Learn",
|
||||
}
|
||||
|
||||
if re.match(r"^batches/.*$", app_path):
|
||||
batch_name = app_path.split("/")[2]
|
||||
batch = frappe.db.get_value(
|
||||
"LMS Batch",
|
||||
batch_name,
|
||||
["title", "meta_image", "description", "category", "medium"],
|
||||
as_dict=True,
|
||||
)
|
||||
return {
|
||||
"title": batch.title,
|
||||
"image": batch.meta_image,
|
||||
"description": batch.description,
|
||||
"keywords": f"{batch.category} {batch.medium}",
|
||||
}
|
||||
|
||||
if app_path == "job-openings":
|
||||
return {
|
||||
"title": _("Job Openings"),
|
||||
@@ -33,3 +75,25 @@ def get_meta(app_path):
|
||||
"description": "This page lists all the job openings published on our website",
|
||||
"keywords": "Job Openings, Jobs, Vacancies",
|
||||
}
|
||||
|
||||
if re.match(r"^job-openings/.*$", app_path):
|
||||
job_opening_name = app_path.split("/")[1]
|
||||
job_opening = frappe.db.get_value(
|
||||
"Job Opportunity",
|
||||
job_opening_name,
|
||||
["job_title", "company_logo", "company_name"],
|
||||
as_dict=True,
|
||||
)
|
||||
return {
|
||||
"title": job_opening.title,
|
||||
"image": job_opening.company_logo,
|
||||
"description": job_opening.company_name,
|
||||
}
|
||||
|
||||
if app_path == "statistics":
|
||||
return {
|
||||
"title": _("Statistics"),
|
||||
"image": frappe.db.get_single_value("Website Settings", "banner_image"),
|
||||
"description": "This page lists all the statistics of this platform",
|
||||
"keywords": "Enrollment Count, Completion, Signups",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user