Manas Solanki | 966f141 | 2017-11-23 15:22:10 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors |
| 3 | # For license information, please see license.txt |
| 4 | |
| 5 | from __future__ import unicode_literals |
| 6 | |
| 7 | import frappe |
| 8 | from erpnext.setup.utils import insert_record |
| 9 | |
| 10 | |
| 11 | def setup_education(): |
Shivam Mishra | 08425d4 | 2019-05-29 15:42:57 +0530 | [diff] [blame] | 12 | disable_desk_access_for_student_role() |
| 13 | if frappe.db.exists("Academic Year", "2015-16"): |
Manas Solanki | 966f141 | 2017-11-23 15:22:10 +0530 | [diff] [blame] | 14 | # already setup |
| 15 | return |
| 16 | create_academic_sessions() |
| 17 | |
| 18 | def create_academic_sessions(): |
| 19 | data = [ |
| 20 | {"doctype": "Academic Year", "academic_year_name": "2015-16"}, |
| 21 | {"doctype": "Academic Year", "academic_year_name": "2016-17"}, |
| 22 | {"doctype": "Academic Year", "academic_year_name": "2017-18"}, |
| 23 | {"doctype": "Academic Year", "academic_year_name": "2018-19"}, |
| 24 | {"doctype": "Academic Term", "academic_year": "2016-17", "term_name": "Semester 1"}, |
| 25 | {"doctype": "Academic Term", "academic_year": "2016-17", "term_name": "Semester 2"}, |
| 26 | {"doctype": "Academic Term", "academic_year": "2017-18", "term_name": "Semester 1"}, |
| 27 | {"doctype": "Academic Term", "academic_year": "2017-18", "term_name": "Semester 2"} |
| 28 | ] |
| 29 | insert_record(data) |
Shivam Mishra | 08425d4 | 2019-05-29 15:42:57 +0530 | [diff] [blame] | 30 | |
| 31 | def disable_desk_access_for_student_role(): |
| 32 | try: |
| 33 | student_role = frappe.get_doc("Role", "Student") |
| 34 | except frappe.DoesNotExistError: |
| 35 | create_student_role() |
| 36 | return |
| 37 | |
| 38 | student_role.desk_access = 0 |
| 39 | student_role.save() |
| 40 | |
| 41 | def create_student_role(): |
| 42 | student_role = frappe.get_doc({ |
| 43 | "doctype": "Role", |
| 44 | "role_name": "Student", |
| 45 | "desk_access": 0, |
| 46 | "restrict_to_domain": "Education" |
| 47 | }) |
Shivam Mishra | 9cad943 | 2019-06-05 17:52:21 +0530 | [diff] [blame] | 48 | student_role.insert() |