From 913bf553ae765de7be98b7ae3a197dd8b0c1d438 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 29 Apr 2025 11:03:58 +0530 Subject: [PATCH] refactor: simplified the condition to check is user is instructor --- lms/lms/utils.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lms/lms/utils.py b/lms/lms/utils.py index d5d2651f..6fff64f8 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -421,16 +421,11 @@ def get_initial_members(course): def is_instructor(course): - return ( - len( - list( - filter( - lambda x: x.name == frappe.session.user, get_instructors("LMS Course", course) - ) - ) - ) - > 0 - ) + instructors = get_instructors("LMS Course", course) + for instructor in instructors: + if instructor.name == frappe.session.user: + return True + return False def convert_number_to_character(number):