Skip to content

Commit

Permalink
Merge pull request #14 from ONE-F-M/186579971
Browse files Browse the repository at this point in the history
BUG:UPON COURSE CREATION
  • Loading branch information
mymi14s authored Dec 5, 2023
2 parents 67c0d6a + d3c0ed0 commit 129d550
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions one_lms/www/courses/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
redirect_to_courses_list,
can_create_courses,
has_course_moderator_role,
has_course_instructor_role
)
from frappe import _

Expand All @@ -15,14 +16,14 @@ def get_context(context):
except KeyError:
redirect_to_courses_list()

if not can_create_courses():
if not can_create_courses(course_name) and course_name != "new-course":
message = "You do not have permission to access this page."
if frappe.session.user == "Guest":
message = "Please login to access this page."

raise frappe.PermissionError(_(message))

if course_name == "new-course":
if course_name == "new-course" and has_course_instructor_role():
context.course = frappe._dict()
context.course.edit_mode = True
context.membership = None
Expand Down
12 changes: 11 additions & 1 deletion one_lms/www/courses/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
has_course_moderator_role,
get_courses_under_review,
get_average_rating,
has_course_instructor_role,
)
from lms.overrides.user import get_enrolled_courses, get_authored_courses

Expand All @@ -20,7 +21,16 @@ def get_context(context):
context.created_courses = get_authored_courses(None, False)
context.review_courses = get_courses_under_review()
context.restriction = check_profile_restriction()
context.show_creators_section = can_create_courses()
portal_course_creation = frappe.db.get_single_value(
"LMS Settings", "portal_course_creation"
)
context.show_creators_section = (
True
if portal_course_creation == "Anyone"
or has_course_moderator_role()
or has_course_instructor_role()
else False
)
context.show_review_section = (
has_course_moderator_role() and frappe.session.user != "Guest"
)
Expand Down

0 comments on commit 129d550

Please sign in to comment.