refactor: added enrolled status to program card

This commit is contained in:
Shivam Mishra 2019-05-30 17:19:11 +05:30
parent 4991fca5cc
commit 12579617f3
5 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -42,7 +42,7 @@
<div class='container'>
<div class="row mt-5">
{% for program in all_programs %}
{{ program_card(program) }}
{{ program_card(program.program, program.has_access) }}
{% endfor %}
</div>
</div>

View File

@ -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']

View File

@ -46,7 +46,7 @@
<div class='container'>
<div class="row mt-5">
{% for program in featured_programs %}
{{ program_card(program) }}
{{ program_card(program.program, program.has_access) }}
{% endfor %}
</div>
<p class='mt-4'>

View File

@ -1,4 +1,4 @@
{% macro program_card(program) %}
{% macro program_card(program, has_access) %}
<div class="col-sm mb-4 text-left">
<a href="/lms/program?program={{ program.name }}" class="no-decoration no-underline">
<div class="card h-100">
@ -14,7 +14,9 @@
<div>{{ program.description }}</div>
</div>
<div class='card-footer'>
<span class='small'>Watch Intro</span>
{% if has_access %} <span class="indicator green">Enrolled</span>
{% else %} <span>Watch Intro</span>
{% endif %}
</div>
</div>
</a>