fix: miscellaneous
This commit is contained in:
@@ -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 %}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) %}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
import frappe
|
||||
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
|
||||
from community.lms.models import Sketch
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
context.member = frappe.get_all("Community Member", {"email": frappe.session.user}, ["name", "email", "photo", "full_name", "abbr"])[0]
|
||||
context.memberships = get_memberships(context.member.name)
|
||||
context.courses = get_courses(context.memberships)
|
||||
context.activity = get_activity(context.memberships)
|
||||
context.sketches = list(filter(lambda x: x.owner == frappe.session.user, get_recent_sketches()))
|
||||
context.no_cache = 1
|
||||
if frappe.session.user == "Guest":
|
||||
frappe.local.flags.redirect_location = "/login"
|
||||
raise frappe.Redirect
|
||||
context.member = frappe.get_all("Community Member", {"email": frappe.session.user}, ["name", "email", "photo", "full_name", "abbr"])[0]
|
||||
context.memberships = get_memberships(context.member.name)
|
||||
context.courses = get_courses(context.memberships)
|
||||
context.activity = get_activity(context.memberships)
|
||||
context.sketches = list(filter(lambda x: x.owner == frappe.session.user, Sketch.get_recent_sketches(owner=context.member.email)))
|
||||
|
||||
def get_memberships(member):
|
||||
return frappe.get_all("LMS Batch Membership", {"member": member}, ["batch", "member_type", "creation"])
|
||||
return frappe.get_all("LMS Batch Membership", {"member": member}, ["batch", "member_type", "creation"])
|
||||
|
||||
def get_courses(memberships):
|
||||
courses = []
|
||||
for membership in memberships:
|
||||
course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
||||
course_details = frappe.get_doc("LMS Course", course)
|
||||
course_in_list = list(filter(lambda x: x.name == course_details.name, courses))
|
||||
if not len(course_in_list):
|
||||
course_details.description = course_details.description[0:100] + "..."
|
||||
course_details.joining = membership.creation
|
||||
if membership.member_type != "Student":
|
||||
course_details.member_type = membership.member_type
|
||||
courses.append(course_details)
|
||||
return courses
|
||||
courses = []
|
||||
for membership in memberships:
|
||||
course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
||||
course_details = frappe.get_doc("LMS Course", course)
|
||||
course_in_list = list(filter(lambda x: x.name == course_details.name, courses))
|
||||
if not len(course_in_list):
|
||||
course_details.description = course_details.description[0:100] + "..."
|
||||
course_details.joining = membership.creation
|
||||
if membership.member_type != "Student":
|
||||
course_details.member_type = membership.member_type
|
||||
courses.append(course_details)
|
||||
return courses
|
||||
|
||||
def get_activity(memberships):
|
||||
messages, courses = [], {}
|
||||
batches = [x.batch for x in memberships]
|
||||
for batch in batches:
|
||||
courses[batch] = frappe.db.get_value("LMS Batch", batch, "course")
|
||||
messages = frappe.get_all("LMS Message", {"batch": ["in", ",".join(batches)]}, ["message", "author", "creation", "batch"], order_by='creation desc')
|
||||
for message in messages:
|
||||
message.course = courses[message.batch]
|
||||
message.profile, message.full_name, message.abbr = frappe.db.get_value("Community Member", message.author, ["photo", "full_name", "abbr"])
|
||||
return messages
|
||||
messages, courses = [], {}
|
||||
batches = [x.batch for x in memberships]
|
||||
for batch in batches:
|
||||
courses[batch] = frappe.db.get_value("LMS Batch", batch, "course")
|
||||
messages = frappe.get_all("LMS Message", {"batch": ["in", ",".join(batches)]}, ["message", "author", "creation", "batch"], order_by='creation desc')
|
||||
for message in messages:
|
||||
message.course = courses[message.batch]
|
||||
message.profile, message.full_name, message.abbr = frappe.db.get_value("Community Member", message.author, ["photo", "full_name", "abbr"])
|
||||
return messages
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro MentorsSection(mentors, is_mentor) %}
|
||||
{% macro MentorsSection(mentors, is_mentor, course_name) %}
|
||||
<h3>Mentors</h3>
|
||||
{% for m in mentors %}
|
||||
<div class="instructor">
|
||||
@@ -15,10 +15,15 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not is_mentor %}
|
||||
<div class="notice">
|
||||
<div id="mentor-request" class="notice">
|
||||
Interested to become a mentor?
|
||||
|
||||
<div><a href="#">Apply Now!</a></div>
|
||||
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
|
||||
</div>
|
||||
<div id="already-applied" class="notice hide">
|
||||
You've applied to become a mentor for this course. Your request is currently under review.
|
||||
|
||||
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -26,7 +31,7 @@
|
||||
|
||||
{% macro BatchHearder(course_name, member_count) %}
|
||||
<div class="border p-3">
|
||||
<h3>{{course_name}}</h3>
|
||||
<div class="text-muted">{{member_count}} members</div>
|
||||
<h3>{{course_name}}</h3>
|
||||
<div class="text-muted">{{member_count}} members</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -8,7 +8,7 @@ def get_context(context):
|
||||
if not context.member:
|
||||
context.template = "www/404.html"
|
||||
else:
|
||||
context.sketches = Sketch.get_recent_sketches(context.member.email)
|
||||
context.sketches = Sketch.get_recent_sketches(owner=context.member.email)
|
||||
|
||||
def get_member(username):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user