refactor: refactored the about page
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"autoname": "field:title",
|
|
||||||
"creation": "2021-03-18 19:37:34.614796",
|
"creation": "2021-03-18 19:37:34.614796",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@@ -51,10 +50,12 @@
|
|||||||
"label": "Description"
|
"label": "Description"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Public",
|
||||||
"fieldname": "visibility",
|
"fieldname": "visibility",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Visibility",
|
"label": "Visibility",
|
||||||
"options": "\nPublic\nUnlisted\nPrivate"
|
"options": "Public\nUnlisted\nPrivate"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "membership",
|
"fieldname": "membership",
|
||||||
@@ -63,16 +64,19 @@
|
|||||||
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Active",
|
||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "\nActive\nInactive"
|
"options": "Active\nInactive"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Ready",
|
||||||
"fieldname": "stage",
|
"fieldname": "stage",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Stage",
|
"label": "Stage",
|
||||||
"options": "\nReady\nIn Progress\nCompleted\nCancelled"
|
"options": "Ready\nIn Progress\nCompleted\nCancelled"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
@@ -122,7 +126,7 @@
|
|||||||
"link_fieldname": "batch"
|
"link_fieldname": "batch"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-04-30 09:52:18.941276",
|
"modified": "2021-05-06 05:46:38.469120",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from community.www.courses.utils import get_member_with_email
|
from community.www.courses.utils import get_member_with_email
|
||||||
|
from community.query import find, find_all
|
||||||
|
|
||||||
class LMSBatch(Document):
|
class LMSBatch(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -23,10 +24,16 @@ class LMSBatch(Document):
|
|||||||
"LMS Batch Membership",
|
"LMS Batch Membership",
|
||||||
{"batch": self.name, "member_type": "Mentor"},
|
{"batch": self.name, "member_type": "Mentor"},
|
||||||
["member"])
|
["member"])
|
||||||
for membership in memberships:
|
member_names = [m['member'] for m in memberships]
|
||||||
member = frappe.db.get_value("Community Member", membership.member, ["full_name", "photo", "abbr"], as_dict=1)
|
return find_all("Community Member", name=["IN", member_names])
|
||||||
mentors.append(member)
|
|
||||||
return mentors
|
def is_member(self, email):
|
||||||
|
"""Checks if a person is part of a batch.
|
||||||
|
"""
|
||||||
|
member = find("Community Member", email=email)
|
||||||
|
return member and frappe.db.exists(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
{"batch": self.name, "member": member.name})
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_messages(batch):
|
def get_messages(batch):
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ class LMSCourse(Document):
|
|||||||
# TODO: chapters should have a way to specify the order
|
# TODO: chapters should have a way to specify the order
|
||||||
return find_all("Chapter", course=self.name, order_by="creation")
|
return find_all("Chapter", course=self.name, order_by="creation")
|
||||||
|
|
||||||
|
def get_batch(self, batch_name):
|
||||||
|
return find("LMS Batch", name=batch_name, course=self.name)
|
||||||
|
|
||||||
def get_batches(self, mentor=None):
|
def get_batches(self, mentor=None):
|
||||||
batches = find_all("LMS Batch", course=self.name)
|
batches = find_all("LMS Batch", course=self.name)
|
||||||
if mentor:
|
if mentor:
|
||||||
|
|||||||
@@ -12,16 +12,13 @@
|
|||||||
{{ Sidebar(course_slug, batch_code) }}
|
{{ Sidebar(course_slug, batch_code) }}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{ CourseBasicDetail(course)}}
|
{{ CourseBasicDetail(course)}}
|
||||||
{{ InstructorsSection(instructor) }}
|
{{ InstructorsSection(course.get_instructor()) }}
|
||||||
{% if batch.description %}
|
{{ BatchDetails(batch)}}
|
||||||
{{ BatchDetails(batch.description) }}
|
|
||||||
{% endif %}
|
|
||||||
{{ MentorsSection(mentors, True, course.name) }}
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro CourseBasicDetail(course) %}
|
{% macro CourseBasicDetail(course) %}
|
||||||
<h2>{{course.name}}</h2>
|
<h2>{{course.title}}</h2>
|
||||||
<div class="course-description">
|
<div class="course-description">
|
||||||
{{course.short_introduction}}
|
{{course.short_introduction}}
|
||||||
</div>
|
</div>
|
||||||
@@ -36,11 +33,25 @@
|
|||||||
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro BatchDetails(description) %}
|
{% macro BatchDetails(batch) %}
|
||||||
<div class="mt-5">
|
<h2>About the Batch</h2>
|
||||||
<h3>About the Batch</h3>
|
|
||||||
<div>
|
<div class="batch">
|
||||||
{{ frappe.utils.md_to_html(description) }}
|
<div class="batch-details">
|
||||||
</div>
|
<div>Session every {{batch.sessions_on}}</div>
|
||||||
|
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
|
||||||
|
{{frappe.utils.format_time(batch.end_time, "short")}}</div>
|
||||||
|
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||||
|
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||||
|
|
||||||
|
{% for m in batch.get_mentors() %}
|
||||||
|
<div>
|
||||||
|
{% if m.photo_url %}
|
||||||
|
<img class="profile-photo" src="{{m.photo_url}}">
|
||||||
|
{% endif %}
|
||||||
|
<span class="instructor-title">{{m.full_name}}</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from community.www.courses.utils import redirect_if_not_a_member, get_course, get_instructor, get_batch
|
from community.lms.models import Course
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
context.course_slug = frappe.form_dict["course"]
|
|
||||||
context.course = get_course(context.course_slug)
|
|
||||||
context.batch_code = frappe.form_dict["batch"]
|
|
||||||
redirect_if_not_a_member(context.course_slug, context.batch_code)
|
|
||||||
|
|
||||||
context.instructor = get_instructor(context.course.owner)
|
course_name = frappe.form_dict["course"]
|
||||||
context.batch = get_batch(context.batch_code)
|
batch_name = frappe.form_dict["batch"]
|
||||||
context.mentors = get_mentors(context.batch.name)
|
|
||||||
|
|
||||||
def get_mentors(batch):
|
course = Course.find(course_name)
|
||||||
mentors = []
|
if not course:
|
||||||
memberships = frappe.get_all("LMS Batch Membership", {"batch": batch, "member_type": "Mentor"}, ["member"])
|
context.template = "www/404.html"
|
||||||
for membership in memberships:
|
return
|
||||||
member = frappe.get_doc("Community Member", membership.member)
|
|
||||||
mentors.append(member)
|
batch = course.get_batch(batch_name)
|
||||||
return mentors
|
if not batch:
|
||||||
|
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||||
|
raise frappe.Redirect
|
||||||
|
|
||||||
|
context.course = course
|
||||||
|
context.batch = batch
|
||||||
|
|||||||
Reference in New Issue
Block a user