From 12579617f3079e925ad0d1dca73ea580adbfbea1 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 30 May 2019 17:19:11 +0530 Subject: [PATCH] refactor: added enrolled status to program card --- erpnext/education/utils.py | 2 +- erpnext/www/lms/all-programs.html | 2 +- erpnext/www/lms/content.py | 2 +- erpnext/www/lms/index.html | 2 +- erpnext/www/lms/macros/card.html | 6 ++++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 09ac22ca27..c19bd19879 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -84,7 +84,7 @@ def get_portal_programs(): return None program_list = [frappe.get_doc("Program", program) for program in published_programs] - portal_programs = [program for program in program_list if allowed_program_access(program.name) or program.allow_self_enroll] + portal_programs = [{'program': program, 'has_access': allowed_program_access(program.name)} for program in program_list if allowed_program_access(program.name) or program.allow_self_enroll] return portal_programs diff --git a/erpnext/www/lms/all-programs.html b/erpnext/www/lms/all-programs.html index 088498b4a9..02df51acdf 100644 --- a/erpnext/www/lms/all-programs.html +++ b/erpnext/www/lms/all-programs.html @@ -42,7 +42,7 @@
{% for program in all_programs %} - {{ program_card(program) }} + {{ program_card(program.program, program.has_access) }} {% endfor %}
diff --git a/erpnext/www/lms/content.py b/erpnext/www/lms/content.py index 67e3508df5..25d5bc7e7f 100644 --- a/erpnext/www/lms/content.py +++ b/erpnext/www/lms/content.py @@ -16,7 +16,7 @@ def get_context(context): frappe.local.flags.redirect_location = '/lms' raise frappe.Redirect - context.content = frappe.get_doc(content_type, content).as_dict() + context.content = frappe.get_doc(content_type, content) context.content_type = content_type context.course = frappe.form_dict['course'] diff --git a/erpnext/www/lms/index.html b/erpnext/www/lms/index.html index ba3034c79e..6661e22ce3 100644 --- a/erpnext/www/lms/index.html +++ b/erpnext/www/lms/index.html @@ -46,7 +46,7 @@
{% for program in featured_programs %} - {{ program_card(program) }} + {{ program_card(program.program, program.has_access) }} {% endfor %}

diff --git a/erpnext/www/lms/macros/card.html b/erpnext/www/lms/macros/card.html index 8cf8a78e56..a0e4dab349 100644 --- a/erpnext/www/lms/macros/card.html +++ b/erpnext/www/lms/macros/card.html @@ -1,4 +1,4 @@ -{% macro program_card(program) %} +{% macro program_card(program, has_access) %}