fix: miscellaneous

This commit is contained in:
pateljannat
2021-05-04 12:47:45 +05:30
parent 8933ca9ac9
commit e931ead270
12 changed files with 101 additions and 72 deletions

View File

@@ -16,7 +16,7 @@
{% if batch.description %}
{{ BatchDetails(batch.description) }}
{% endif %}
{{ MentorsSection(mentors, True) }}
{{ MentorsSection(mentors, True, course.name) }}
</div>
{% endblock %}
@@ -43,4 +43,4 @@
{{ frappe.utils.md_to_html(description) }}
</div>
</div>
{% endmacro %}
{% endmacro %}

View File

@@ -11,13 +11,11 @@ def get_context(context):
context.instructor = get_instructor(context.course.owner)
context.batch = get_batch(context.batch_code)
context.mentors = get_mentors(context.batch.name)
print(context.mentors)
def get_mentors(batch):
mentors = []
memberships = frappe.get_all("LMS Batch Membership", {"batch": batch, "member_type": "Mentor"}, ["member"])
for membership in memberships:
member = frappe.db.get_value("Community Member", membership.member, ["name","full_name"], as_dict=True)
member.batch_count = len(frappe.get_all("LMS Batch Membership", {"member": member.name, "member_type": "Mentor"}))
member = frappe.get_doc("Community Member", membership.member)
mentors.append(member)
return mentors
return mentors

View File

@@ -10,7 +10,7 @@
<div class="container">
<div class="course-header">
<div class="course-type">course</div>
<h1>{{course.title}}</h1>
<h1 id="course-title" data-course="{{course.name}}">{{course.title}}</h1>
</div>
<div class="row">
@@ -28,7 +28,7 @@
</div>
<div class="sidebar">
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user)) }}
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user), course.name) }}
</div>
</div>
</div>
@@ -86,9 +86,9 @@
<div class="cta">
<div class="">
{% if can_manage %}
<button type="button">Manage</button>
<button >Manage</button>
{% else %}
<button type="button">Join this Batch</button>
<button class="join-batch" data-batch="{{ batch.name | urlencode }}">Join this Batch</button>
{% endif %}
</div>
</div>
@@ -123,11 +123,13 @@
{% macro BatchSectionForStudents(course, upcoming_batches) %}
<h2>Upcoming Batches</h2>
{% for batch in upcoming_batches %}
<div class="col-lg-4 col-md-6">
{{ RenderBatch(batch, can_manage=False) }}
<div class="row">
{% for batch in upcoming_batches %}
<div class="col-lg-4 col-md-6">
{{ RenderBatch(batch, can_manage=False) }}
</div>
{% endfor %}
</div>
{% endfor %}
{% endmacro %}
{% macro CourseOutline(course) %}

View File

@@ -3,18 +3,19 @@ frappe.ready(() => {
frappe.call({
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
'args': {
course: decodeURIComponent($(".course-title").attr("data-course")),
course: decodeURIComponent($("#course-title").attr("data-course")),
},
'callback': (data) => {
if (data.message) {
$(".mentor-request").addClass("hide");
$(".already-applied").removeClass("hide")
$("#mentor-request").addClass("hide");
$("#already-applied").removeClass("hide")
}
}
})
}
$(".apply-now").click((e) => {
$("#apply-now").click((e) => {
e.preventDefault();
if (frappe.session.user == "Guest") {
window.location.href = "/login";
return;
@@ -26,14 +27,15 @@ frappe.ready(() => {
},
"callback": (data) => {
if (data.message == "OK") {
$(".mentor-request").addClass("hide");
$(".already-applied").removeClass("hide")
$("#mentor-request").addClass("hide");
$("#already-applied").removeClass("hide")
}
}
})
})
$(".cancel-request").click((e) => {
$("#cancel-request").click((e) => {
e.preventDefault()
frappe.call({
"method": "community.lms.doctype.lms_mentor_request.lms_mentor_request.cancel_request",
"args": {
@@ -41,14 +43,15 @@ frappe.ready(() => {
},
"callback": (data) => {
if (data.message == "OK") {
$(".mentor-request").removeClass("hide");
$(".already-applied").addClass("hide")
$("#mentor-request").removeClass("hide");
$("#already-applied").addClass("hide")
}
}
})
})
$(".join-batch").click((e) => {
e.preventDefault()
if (frappe.session.user == "Guest") {
window.location.href = "/login";
return;
@@ -62,7 +65,6 @@ frappe.ready(() => {
"callback": (data) => {
if (data.message == "OK") {
frappe.msgprint(__("You are now a student of this course."))
$(".upcoming-batches").addClass("hide")
}
}
})