Modified program and index view

Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
scmmishra 2018-10-16 17:54:18 +05:30 committed by Aditya Hase
parent fa2db3c41b
commit 3757a4eab8
4 changed files with 12 additions and 19 deletions

View File

@ -162,8 +162,9 @@ def get_program():
else:
return None
def get_featured_program():
featured_list = frappe.get_list("Program", filters={"is_published": True, "is_featured": True})
def get_featured_programs():
featured_programs_name = frappe.get_list("Program", filters={"is_published": True, "is_featured": True})
featured_list = [frappe.get_doc("Program", program["name"]) for program in featured_programs_name]
if featured_list:
return featured_list
else:

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import frappe
import erpnext.education.utils as utils
def get_context(context):
context.featured = frappe.get_all('Program', filters={'is_featured': 1}, fields=['program_name', 'program_code', 'description', 'hero_image'])
context.featured = utils.get_featured_programs()

View File

@ -6,23 +6,23 @@
<meta name="keywords" content="ERP Software, Cloud ERP, Open Source ERP, Accounting Software, Online ERP, Online Accounting, ERP for small business, Learn ERP, ERPNext Academy, Learn ERPNext, Learn Accounting" />
{% endblock %}
{% macro course_card(name) %}
{% macro course_card(course) %}
<div class="card mt-3" data-list="getting-started">
<div class='card-body'>
<div class="row">
<div class="course-details col-xs-8 col-sm-9 col-md-10">
<h5>{{ name }}</h5>
<h5>{{ course.name }}</h5>
<span class="course-list text-muted" id="getting-started">
Course Content
<ul class="mb-0 mt-1">
{% for content in course_data[name] %}
<li>{{ content }}</li>
{% for content in course.course_content %}
<li>{{ content.content }}</li>
{% endfor %}
</ul>
</span>
</div>
<div class='text-center col-xs-4 col-sm-3 col-md-2'>
<a class='btn btn-primary btn-sm btn-block' href="/lms/course?program={{ program.program_code }}&course={{ name }}&content={{ course_data[name][0] }}">Start Course</a>
<a class='btn btn-primary btn-sm btn-block' href="/lms/course?program={{ program.program_code }}&course={{ course.name }}&content={{ course.course_content[0].content }}">Start Course</a>
</div>
</div>
</div>

View File

@ -1,17 +1,8 @@
from __future__ import unicode_literals
from erpnext.education.utils import get_student_name
import erpnext.education.utils as utils
import frappe
def get_context(context):
print(get_student_name(frappe.session.user))
context.program = frappe.get_doc("Program", frappe.form_dict["program"])
context.course_list, context.course_data = get_courses(context)
def get_courses(context):
course_data = {}
course_names = [program.course_name for program in context.program.courses]
program_courses = [frappe.get_doc('Course', name) for name in course_names]
for course_item in program_courses:
course_data[course_item.name] = [content_item.content for content_item in course_item.course_content if content_item.content_type in ('Video', 'Article')]
return course_names, course_data
context.course_list = utils.get_courses_in_program(frappe.form_dict["program"])