From a99d3a844f1194c6a6f7ac12f0df4103c74f5b60 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 14:32:27 +0530 Subject: [PATCH 1/6] test: fix fixtures for program and course --- erpnext/education/doctype/course/test_records.json | 9 +++------ erpnext/education/doctype/program/test_records.json | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/erpnext/education/doctype/course/test_records.json b/erpnext/education/doctype/course/test_records.json index ec57dc73a1..1e7467aed2 100644 --- a/erpnext/education/doctype/course/test_records.json +++ b/erpnext/education/doctype/course/test_records.json @@ -1,17 +1,14 @@ [ { - "course_name": "_Test Course", - "course_code": "TC100", + "course_name": "TC100", "course_abbreviation": "TC" }, { - "course_name": "_Test Course 1", - "course_code": "TC101", + "course_name": "TC101", "course_abbreviation": "TC1" }, { - "course_name": "_Test Course 2", - "course_code": "TC102", + "course_name": "TC102", "course_abbreviation": "TC2" } ] \ No newline at end of file diff --git a/erpnext/education/doctype/program/test_records.json b/erpnext/education/doctype/program/test_records.json index 7901db3225..4013695896 100644 --- a/erpnext/education/doctype/program/test_records.json +++ b/erpnext/education/doctype/program/test_records.json @@ -1,13 +1,11 @@ [ { - "program_name": "_Test Program 1", - "program_code": "_TP1", + "program_name": "_TP1", "description": "Test Description", "program_abbreviation": "TP1" }, { - "program_name": "_Test Program 2", - "program_code": "_TP2", + "program_name": "_TP2", "description": "Test Description", "program_abbreviation": "TP2" } From 278ef4bf732d339d904082da0ecd7dc0da2e18ee Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 14:53:00 +0530 Subject: [PATCH 2/6] fix: template fix for null_card --- erpnext/www/lms/course.html | 2 +- erpnext/www/lms/index.html | 2 +- erpnext/www/lms/program.html | 2 +- erpnext/www/lms/topic.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html index 250c39d498..c86ac9c11f 100644 --- a/erpnext/www/lms/course.html +++ b/erpnext/www/lms/course.html @@ -96,7 +96,7 @@ {{ card(topic) }} {% endfor %} {% if topics %} - {% for n in range(((topics|length)%3)) %} + {% for n in range( (3 - (topics|length)) %3) %} {{ null_card() }} {% endfor %} {% endif %} diff --git a/erpnext/www/lms/index.html b/erpnext/www/lms/index.html index 0114235370..ffb4419f36 100644 --- a/erpnext/www/lms/index.html +++ b/erpnext/www/lms/index.html @@ -55,7 +55,7 @@ {{ program_card(program.program, program.has_access) }} {% endfor %} {% if featured_programs %} - {% for n in range((featured_programs|length)%3) %} + {% for n in range( (3 - (featured_programs|length)) %3) %} {{ null_card() }} {% endfor %} {% endif %} diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html index 6c144d4641..271b7813bb 100644 --- a/erpnext/www/lms/program.html +++ b/erpnext/www/lms/program.html @@ -77,7 +77,7 @@ {{ card(course) }} {% endfor %} {% if courses %} - {% for n in range((courses|length)%3) %} + {% for n in range( (3 - (courses|length)) %3) %} {{ null_card() }} {% endfor %} {% endif %} diff --git a/erpnext/www/lms/topic.html b/erpnext/www/lms/topic.html index 3e439fca23..1f0d187664 100644 --- a/erpnext/www/lms/topic.html +++ b/erpnext/www/lms/topic.html @@ -48,7 +48,7 @@ {{ card(content, loop.index, topic.contents|length) }} {% endfor %} {% if contents %} - {% for n in range((contents|length)%3) %} + {% for n in range( (3 - (contents|length)) %3) %} {{ null_card() }} {% endfor %} {% endif %} From 8af1e87e838be79a803cbfea117e6ff1ec31bdd4 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 15:16:26 +0530 Subject: [PATCH 3/6] fix: card imqge not visible for courses --- erpnext/www/lms/course.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html index c86ac9c11f..7f7a31128a 100644 --- a/erpnext/www/lms/course.html +++ b/erpnext/www/lms/course.html @@ -45,7 +45,7 @@
{% endif %} {% if topic.hero_image %} -
+
{% else %}
From 44f98a9a4beab52a0ab112028dbcc66c2c40da66 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 15:22:42 +0530 Subject: [PATCH 4/6] fix: back to course button --- erpnext/www/lms/content.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/www/lms/content.html b/erpnext/www/lms/content.html index 9b8c45cb9b..5607c0814d 100644 --- a/erpnext/www/lms/content.html +++ b/erpnext/www/lms/content.html @@ -58,7 +58,7 @@ {% macro title() %} From 3264822c1c4eead89f6824fb853ca67222c72765 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 15:43:36 +0530 Subject: [PATCH 5/6] test: fixed unknown column course_name --- .../education/doctype/program_enrollment/program_enrollment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.py b/erpnext/education/doctype/program_enrollment/program_enrollment.py index d232e47245..d5348ffd06 100644 --- a/erpnext/education/doctype/program_enrollment/program_enrollment.py +++ b/erpnext/education/doctype/program_enrollment/program_enrollment.py @@ -66,7 +66,7 @@ class ProgramEnrollment(Document): msgprint(_("Fee Records Created - {0}").format(comma_and(fee_list))) def get_courses(self): - return frappe.db.sql('''select course, course_name from `tabProgram Course` where parent = %s and required = 1''', (self.program), as_dict=1) + return frappe.db.sql('''select course from `tabProgram Course` where parent = %s and required = 1''', (self.program), as_dict=1) def create_course_enrollments(self): student = frappe.get_doc("Student", self.student) From 147d5d9bf2128291d46fa539e81d3f4e8d8c178b Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 12 Jun 2019 16:01:02 +0530 Subject: [PATCH 6/6] fix: redirect to lms home if query params not set --- erpnext/www/lms/course.py | 11 +++++++++-- erpnext/www/lms/program.py | 10 ++++++++-- erpnext/www/lms/topic.py | 10 +++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py index e7ed2e3ed6..c18d64e507 100644 --- a/erpnext/www/lms/course.py +++ b/erpnext/www/lms/course.py @@ -5,9 +5,16 @@ import frappe no_cache = 1 def get_context(context): + try: + program = frappe.form_dict['program'] + course_name = frappe.form_dict['name'] + except KeyError: + frappe.local.flags.redirect_location = '/lms' + raise frappe.Redirect + context.education_settings = frappe.get_single("Education Settings") - course = frappe.get_doc('Course', frappe.form_dict['name']) - context.program = frappe.form_dict['program'] + course = frappe.get_doc('Course', course_name) + context.program = program context.course = course context.topics = course.get_topics() diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py index 1fcb3d3028..7badedcc85 100644 --- a/erpnext/www/lms/program.py +++ b/erpnext/www/lms/program.py @@ -6,10 +6,16 @@ from frappe import _ no_cache = 1 def get_context(context): + try: + program = frappe.form_dict['program'] + except KeyError: + frappe.local.flags.redirect_location = '/lms' + raise frappe.Redirect + context.education_settings = frappe.get_single("Education Settings") - context.program = get_program(frappe.form_dict['program']) + context.program = get_program(program) context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses] - context.has_access = utils.allowed_program_access(frappe.form_dict['program']) + context.has_access = utils.allowed_program_access(program) context.progress = get_course_progress(context.courses, context.program) def get_program(program_name): diff --git a/erpnext/www/lms/topic.py b/erpnext/www/lms/topic.py index 0af0778312..f75ae8e9b6 100644 --- a/erpnext/www/lms/topic.py +++ b/erpnext/www/lms/topic.py @@ -5,9 +5,13 @@ import frappe no_cache = 1 def get_context(context): - course = frappe.form_dict['course'] - program = frappe.form_dict['program'] - topic = frappe.form_dict['topic'] + try: + course = frappe.form_dict['course'] + program = frappe.form_dict['program'] + topic = frappe.form_dict['topic'] + except KeyError: + frappe.local.flags.redirect_location = '/lms' + raise frappe.Redirect context.program = program context.course = course