Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle case when student is not enrolled in any program #209

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions education/education/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,7 @@ def update_email_group(doctype, name):

@frappe.whitelist()
def get_current_enrollment(student, academic_year=None):
current_academic_year = (
academic_year
or frappe.defaults.get_defaults().academic_year
or frappe.get_all("Academic Year", pluck="name")[0]
)
current_academic_year = academic_year or frappe.defaults.get_defaults().academic_year
if not current_academic_year:
frappe.throw(_("Please set default Academic Year in Education Settings"))
program_enrollment_list = frappe.db.sql(
Expand Down Expand Up @@ -529,9 +525,10 @@ def get_student_info():
)[0]

current_program = get_current_enrollment(student_info.name)
student_groups = get_student_groups(student_info.name, current_program.program)
student_info["student_groups"] = student_groups
student_info["current_program"] = current_program
if current_program:
student_groups = get_student_groups(student_info.name, current_program.program)
student_info["student_groups"] = student_groups
student_info["current_program"] = current_program
return student_info


Expand Down
3 changes: 2 additions & 1 deletion education/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ education.patches.v14_0.create_parent_assessment_group #01-01-2022
education.patches.v14_0.lms_deprecation_message #22-12-2022
education.patches.v14_0.student_name
education.patches.v14_0.delete_lms_user_role
education.patches.v15_0.fees_student_email
education.patches.v15_0.fees_student_email
education.patches.v15_0.student_role_desk_access
7 changes: 7 additions & 0 deletions education/patches/v15_0/student_role_desk_access.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import frappe


def execute():
if frappe.db.exists("Role", "Student"):
frappe.db.set_value("Role", "Student", "desk_access", 0)
frappe.db.commit()
2 changes: 1 addition & 1 deletion frontend/src/stores/student.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const studentStore = defineStore('education-student', () => {
if (!info) {
window.location.href = "/app"
}
currentProgram.value = info.current_program
currentProgram.value = info.current_program
// remove current_program from info
delete info.current_program
studentGroups.value = info.student_groups
Expand Down
Loading