Added portal pages for courses and topics.

This commit is contained in:
Anand Chitipothu
2021-03-02 07:00:14 +00:00
parent 972399d72f
commit 5ab4f86f90
7 changed files with 173 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import frappe
def get_context(context):
context.no_cache = 1
course_name = get_queryparam("course", '/courses')
context.course = get_course(course_name)
topic_name = get_queryparam("topic", '/courses?course=' + course_name)
context.topic = get_topic(course_name, topic_name)
print("topic", context.topic)
def get_queryparam(name, redirect_when_not_found):
try:
return frappe.form_dict[name]
except KeyError:
frappe.local.flags.redirect_location = redirect_when_not_found
raise frappe.Redirect
def get_course(name):
try:
course = frappe.get_doc('Community Course', name)
except frappe.exceptions.DoesNotExistError:
raise frappe.NotFound
return course
def get_topic(course_name, topic_name):
try:
topic = frappe.get_doc('Community Course Topic', topic_name)
except frappe.exceptions.DoesNotExistError:
raise frappe.NotFound
if topic.course != course_name:
raise frappe.NotFound
return topic