refactor: set Student as default portal role for Education

This commit is contained in:
Shivam Mishra 2019-05-29 15:42:57 +05:30
parent 63d8cabb3d
commit 08425d46fa
3 changed files with 23 additions and 3 deletions

View File

@ -14,7 +14,7 @@ data = {
'Student Attendance Tool',
'Student Applicant'
],
'default_portal_role': 'LMS User',
'default_portal_role': 'Student',
'restricted_roles': [
'Student',
'Instructor',

View File

@ -54,7 +54,7 @@ class Student(Document):
'send_welcome_email': 1,
'user_type': 'Website User'
})
student_user.add_roles("Student", "LMS User")
student_user.add_roles("Student")
student_user.save()
update_password_link = student_user.reset_password()

View File

@ -9,7 +9,8 @@ from erpnext.setup.utils import insert_record
def setup_education():
if frappe.db.exists('Academic Year', '2015-16'):
disable_desk_access_for_student_role()
if frappe.db.exists("Academic Year", "2015-16"):
# already setup
return
create_academic_sessions()
@ -26,3 +27,22 @@ def create_academic_sessions():
{"doctype": "Academic Term", "academic_year": "2017-18", "term_name": "Semester 2"}
]
insert_record(data)
def disable_desk_access_for_student_role():
try:
student_role = frappe.get_doc("Role", "Student")
except frappe.DoesNotExistError:
create_student_role()
return
student_role.desk_access = 0
student_role.save()
def create_student_role():
student_role = frappe.get_doc({
"doctype": "Role",
"role_name": "Student",
"desk_access": 0,
"restrict_to_domain": "Education"
})
student.insert()