def addSubject(request): data = UIDataHelper(request).getData(page="is_add_subjects") data.__setitem__( "form", FORM_SubjectDetails(request.POST, request=request) if request.method == "POST" else FORM_SubjectDetails(request=request)) template = loader.get_template("sub_add_new_subject.html") return HttpResponse(template.render(data, request))
def create(request): template = loader.get_template("announcements_create.html") data = UIDataHelper(request).getData(page="is_create_announcement") data.__setitem__( "form", FORM_Announcements(request.POST, request=request) if request.method == "POST" else FORM_Announcements(request=request)) return HttpResponse(template.render(data, request))
def addSchoolTimings_Page1(request): data = UIDataHelper(request).getData(page="is_add_school_timings") form = FORM_AddModifySchoolTiming_Page1( request.POST, request=request ) if request.method == "POST" else FORM_AddModifySchoolTiming_Page1( request=request) template = loader.get_template("school_timings_page_1.html") data.__setitem__("form", form) messages.info(request, "You can create a new timing or modify an existing timing") return HttpResponse(template.render(data, request))
def addSchoolTimings_Page2(request): if "PAGE_1_DATA" in request.session: data = UIDataHelper(request).getData(page="is_add_school_timings") data.__setitem__( "form", FORM_SchoolTiming(request.POST, request=request) if request.method == "POST" else FORM_SchoolTiming(request=request)) template = loader.get_template("school_timings_page_2.html") return HttpResponse(template.render(data, request)) else: messages.warning(request, "Set/Select Timing Name First ") return HttpResponseRedirect("AddModifyTiming")
def index(request): data = UIDataHelper(request).getData(page="is_list_school_timings") user_id = request.session[SessionProperties.USER_ID_KEY] user_role = EN_UserRoles.objects.filter(approved=True, user_id=user_id, is_selected_role=True, role__code=Roles.SCHOOL_ADMIN) if user_role.exists(): user_role = user_role.first() timings = EN_SchoolTimings.objects.filter( organization=user_role.related_organization) dataList = [] for timing in timings: off_days = "" if timing.class_off_on_sunday: off_days += "Sunday, " if timing.class_off_on_monday: off_days += "Monday, " if timing.class_off_on_tuesday: off_days += "Tuesday, " if timing.class_off_on_wednesday: off_days += "Wednesday, " if timing.class_off_on_thursday: off_days += "Thursday, " if timing.class_off_on_friday: off_days += "Friday, " if timing.class_off_on_saturday: off_days += "Saturday, " off_days = off_days.strip() if off_days.__len__() > 0: if off_days[-1] == ",": off_days = off_days[:-1] dataList.append({ "name": timing.timing_name, "timing": "{} to {} ".format(timing.school_starting_time, timing.school_closing_time), "off_days": off_days, }) data.__setitem__("timings", dataList) template = loader.get_template("school_timings_list_all_timings.html") return HttpResponse(template.render(data, request)) else: messages.warning( request, DisplayKey.get("current_role_cannot_perform_this_action")) return HttpResponseRedirect("../Home")
def filterUser(request): form_data = FORM_ModifyUserRole(request.POST, request=request) if form_data.is_valid(): form_data.cleaned_data.get("product_id") form_data.cleaned_data.get("name") form_data.cleaned_data.get("role") data = UIDataHelper(request).getData(page="is_modify_user_roles") data.__setitem__("form", form_data) template = loader.get_template("roles_modify_user_roles.html") return HttpResponse(template.render(data, request)) else: return modifyUserRoles(request)
def index(request, is_add_new_class = False): data = UIDataHelper(request).getData(page="is_list_all_classes") user_id = request.session[SessionProperties.USER_ID_KEY] user_role = EN_UserRoles.objects.filter(Q(role__code=Roles.SCHOOL_ADMIN) | Q(role__code=Roles.PRINCIPAL), approved=True, user_id=user_id, is_selected_role=True) if user_role.exists(): user_role = user_role.first() classes = EN_Classes.objects.filter(organization=user_role.related_organization) if request.method == "POST": if "class_names" in request.POST: filter_class = request.POST["class_names"] if filter_class != "all": classes = classes.filter(class_name=filter_class) dataList = [] for classData in classes: dataList.append({ "name" : classData.class_name, "division":classData.class_division, "nickname":classData.batch_nick_name if(classData.batch_nick_name != None and classData.batch_nick_name != "") else " ", "start_date":classData.academic_starting_year, "end_date":classData.academic_ending_year, "batch":classData.batch_name, "class_teacher":classData.class_teacher.name if(classData.class_teacher != None) else "-", }) data.__setitem__("classes",dataList) data.__setitem__("is_add_new_class",is_add_new_class) if request.method == "POST": if "class_names" in request.POST: fd_cls_details = FORM_ClassDetails(request=request) fd_classes = FORM_ClassNames(request.POST,request=request) else: fd_cls_details = FORM_ClassDetails(request.POST,request=request) fd_classes = FORM_ClassNames(request.POST,request=request) else: fd_cls_details = FORM_ClassDetails(request=request) fd_classes = FORM_ClassNames(request=request) data.__setitem__("form",fd_cls_details) data.__setitem__("class_names",fd_classes) template = loader.get_template("classes_list_all_classes.html") return HttpResponse(template.render(data, request)) else: messages.warning(request, DisplayKey.get("current_role_cannot_perform_this_action")) return HttpResponseRedirect("../Home")
def modifyUserRoles(request): current_role = request.session[SessionProperties.USER_ACTIVE_ROLE_KEY] if not (current_role in [ Roles.SITE_ADMIN, Roles.INSTITUTION_SUPER_USER, Roles.SCHOOL_ADMIN ]): messages.warning( request, "Current role does not have privilege to perform this action") return HttpResponseRedirect("../Home") else: data = UIDataHelper(request).getData(page="is_modify_user_roles") data.__setitem__( "form", FORM_ModifyUserRole(request.POST, request=request) if request.method == "POST" else FORM_ModifyUserRole(request=request)) template = loader.get_template("roles_modify_user_roles.html") return HttpResponse(template.render(data, request))
def loadRoleSettingPage(request): data = UIDataHelper(request).getData(page="is_raise_role_request") user_id = request.session[SessionProperties.USER_ID_KEY] accepted_user_list = [ Roles.INSTITUTION_SUPER_USER, Roles.SCHOOL_ADMIN, Roles.TEACHER ] ur = EN_UserRoles.objects.filter(approved=True, user_id=user_id, role__code__in=accepted_user_list, is_selected_role=True) if ur.exists(): ur = ur[0] if ur.role.code == Roles.INSTITUTION_SUPER_USER: approvalList = RoleApprovalHierarchy.INSTITUTION_SU_APPROVAL_LIST elif ur.role.code == Roles.SCHOOL_ADMIN: approvalList = RoleApprovalHierarchy.SCHOOL_ADMIN_APPROVAL_LIST elif ur.role.code == Roles.TEACHER: approvalList = RoleApprovalHierarchy.TEACHER_APPROVAL_LIST else: approvalList = [] roles = [{ "code": role.code, "name": role.name } for role in TL_Roles.objects.filter(code__in=approvalList)] schools_list = [] if ur.related_organization_group != None: schools_list = [{ "org_id": org.id, "org_name": org.school_name + ", " + org.street } for org in EN_Organization.objects.filter( organization_group=ur.related_organization_group)] elif ur.related_organization != None: schools_list = [{ "org_id": ur.related_organization.id, "org_name": ur.related_organization.school_name + ", " + ur.related_organization.street }] data.__setitem__("roles", roles) data.__setitem__("schools_list", schools_list) data.__setitem__( "form", FORM_UserRoleAssignment(request.POST) if request.method == "POST" else FORM_UserRoleAssignment()) template = loader.get_template("roles_assign_roles_to_user.html") return HttpResponse(template.render(data, request)) else: messages.error( request, DisplayKey.get( "current_role_doesnot_have_permission_to_do_this_action")) return HttpResponseRedirect("../Home")
def addSchoolTimings_Page3(request): data = UIDataHelper(request).getData(page="is_add_school_timings") user_id = request.session[SessionProperties.USER_ID_KEY] user_role = EN_UserRoles.objects.filter(approved=True, user_id=user_id, is_selected_role=True, role__code=Roles.SCHOOL_ADMIN) if user_role.exists(): user_role = user_role.first() data.__setitem__("school_timings", [{ "id": st.id, "name": st.timing_name } for st in EN_SchoolTimings.objects.filter( organization=user_role.related_organization)]) template = loader.get_template("school_timings_page_3.html") return HttpResponse(template.render(data, request)) else: messages.warning( request, DisplayKey.get("current_role_cannot_perform_this_action")) return HttpResponseRedirect("../Home")
def timetable(request): data = UIDataHelper(request).getData(page="is_add_timetable") user_id = request.session[SessionProperties.USER_ID_KEY] user_role = EN_UserRoles.objects.filter(approved=True, user_id=user_id, is_selected_role=True, role__code=Roles.SCHOOL_ADMIN) if (user_role.exists()): user_role = user_role.first() timings = [{ "id": timing.id, "name": timing.timing_name, } for timing in EN_SchoolTimings.objects.filter( organization=user_role.related_organization)] data.__setitem__("timings", timings) template = loader.get_template("tt_add_modify_timetable.html") return HttpResponse(template.render(data, request)) else: messages.warning(request, "You don't have privilage to perform this action") return HttpResponseRedirect("../Home")
def addBook(request): data = UIDataHelper(request).getData(page="is_books") data.__setitem__("is_add_new_book", "active") data.__setitem__( "form", FORM_BookDetails(request.POST) if request.method == "POST" else FORM_BookDetails()) template = loader.get_template("books_add_new_book.html") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_books") data.__setitem__("is_add_new_book", "active") data.__setitem__("categories", [{ "code": category.code, "name": category.name, } for category in TL_BooksCategory.objects.all()]) template = loader.get_template("books_search_book.html") return HttpResponse(template.render(data, request))
def index(request): user_id = request.session[SessionProperties.USER_ID_KEY] data = UIDataHelper(request).getData(page="is_roles") rh = RolesViewHelper(user_id) roles = rh.getRolesToDisplayOnRolesScreen() if roles == None: messages.error(request, DisplayKey.get("invalid_table_name_on_user_role")) return HttpResponseRedirect("/Home/") else: data.__setitem__("user_roles", roles) data.__setitem__("system_roles", rh.getSystemRolesAsList()) template = loader.get_template("roles_list_all_roles_of_user.html") return HttpResponse(template.render(data, request))
def index(request): template = loader.get_template("doc_list_my_documenst.html") data = UIDataHelper(request).getData(page="is_list_my_documents") data.__setitem__( "form", FORM_Document(request.POST) if request.method == "POST" else FORM_Document()) folder_id = request.session[ "USED_DOCUMENT_FOLDER_ID"] if "USED_DOCUMENT_FOLDER_ID" in request.session else "ROOT" data.__setitem__("folder", folder_id) user_id = request.session[SessionProperties.USER_ID_KEY] if not EN_Documents.objects.filter( owner=user_id, name="ROOT", is_root=True).exists(): DocumentHelper().createRootEntry(user_id) return HttpResponse(template.render(data, request))
def listOrganizations(request): data = UIDataHelper(request).getData(page="is_list_all_organization_active") template = loader.get_template("org_list_all_organinzations.html") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_tasks") data.__setitem__("is_tasks", "active") template = loader.get_template("tasks_list_tasks.html") return HttpResponse(template.render(data, request))
def index(request): template = loader.get_template("home_homepage.html") data = UIDataHelper(request).getData(page="is_home") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_messaging") data.__setitem__("is_messages", "active") template = loader.get_template("msg_homepage.html") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_notifications") template = loader.get_template("notify_homepage.html") return HttpResponse(template.render(data, request))
def index(request): template = loader.get_template("class_calendar.html") data = UIDataHelper(request).getData(page="is_class_calendar") return HttpResponse(template.render(data, request))
def roleRequestsReceived(request): data = UIDataHelper(request).getData(page="is_role_requests_received") template = loader.get_template("roles_role_requests_received.html") return HttpResponse(template.render(data, request))
def listAllRaisedRoles(request): data = UIDataHelper(request).getData(page="is_raised_roles") template = loader.get_template( "roles_list_all_requested_and_approved_roles.html") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_organizations_home") template = loader.get_template("org_statics.html") return HttpResponse(template.render(data, request))
def validateAssignedRole(request): if request.method == "POST": user_id = request.session[SessionProperties.USER_ID_KEY] accepted_user_list = [ Roles.INSTITUTION_SUPER_USER, Roles.SCHOOL_ADMIN, Roles.TEACHER ] ur = EN_UserRoles.objects.filter(approved=True, user_id=user_id, role__code__in=accepted_user_list, is_selected_role=True) if ur.exists(): ur = ur[0] form_data = FORM_UserRoleAssignment(request.POST) try: selected_role = TL_Roles.objects.get( code=request.POST["role_selected"]) except: messages.error(request, "Invalid Role Selected") return loadRoleSettingPage(request) str = form_data["product_ids"].data prdIdListString = (str.replace(" ", "")).strip() productIdList = list(prdIdListString.split(",")) users = EN_Users.objects.filter(product_id__in=productIdList) retList = [] prodComparisonList = [] active_role = EN_UserRoles.objects.filter( approved=True, user_id=user_id, role__code__in=accepted_user_list, is_selected_role=True) if active_role.exists(): active_role = active_role.first() else: messages.error( request, DisplayKey.get( "selected_role_lacks_permission_to_send_or_approve_role_request" )) return loadRoleSettingPage(request) students_not_of_this_org = [] for user in users: if selected_role.code == Roles.PARENT: ur = EN_UserRoles.objects.filter( approved=True, related_organization=active_role.related_organization, user=user, role__code=Roles.STUDENT) if not ur.exists(): students_not_of_this_org.append(user.product_id) if students_not_of_this_org.__len__() > 0: messages.error( request, "User(s) {} are not approved students of {}".format( list(students_not_of_this_org).__str__(), active_role.related_organization.school_name)) return loadRoleSettingPage(request) for user in users: addr = EN_AddressBook.objects.get(user=user, is_permanent_address=True) permanent_adr = addr.house_name + ", " + addr.street retDict = { "id": user.id, "name": user.name, "gender": user.gender.code, "contact_no": user.contact.mobile_number, "address": permanent_adr, "dp": user.display_picture, "product_id": user.product_id } prodComparisonList.append(user.product_id) retList.append(retDict) diff = set(productIdList) - set(prodComparisonList) if diff.__len__() > 0: messages.warning( request, "Invalid Wokidz IDs found : {}".format( (", ".join(diff)))) return loadRoleSettingPage(request) data = UIDataHelper(request).getData(page="is_raise_role_request") data.__setitem__( "organization_id", 0 if "organization_id" not in request.POST else request.POST["organization_id"]) data.__setitem__("selected_role", selected_role.code) try: data.__setitem__("my_role", ur.role.code) except: data.__setitem__("my_role", ur[0].role.code) data.__setitem__("user_list", retList) template = "roles_parent_role_page.html" if selected_role.code == Roles.PARENT else "roles_user_list_page.html" template = loader.get_template(template) return HttpResponse(template.render(data, request)) else: return loadRoleSettingPage(request) else: messages.warning(request, DisplayKey.get("error_not_a_post_request")) return HttpResponseRedirect("../Home")
def registerOrgGroup(request): data = UIDataHelper(request).getData(page="is_new_organization_group_active") data.__setitem__("form", FORM_NewOrganizationGroup(request.POST) if request.method == "POST" else FORM_NewOrganizationGroup()) template = loader.get_template("org_group_registration.html") return HttpResponse(template.render(data, request))
def index(request): data = UIDataHelper(request).getData(page="is_list_all_subjects") user_id = request.session[SessionProperties.USER_ID_KEY] user_role = EN_UserRoles.objects.filter(approved=True, user_id=user_id, is_selected_role=True) if user_role.exists(): user_role = user_role.first() classes = EN_Classes.objects.filter( organization=user_role.related_organization) teachers = EN_UserRoles.objects.filter( related_organization=user_role.related_organization, role__code=Roles.TEACHER, approved=True) if not teachers.exists(): messages.warning(request, "No Teachers added to this Organization.") teacherList = None else: teacherList = [ { "id": teacher.id, #setting role_id, not user_id "name": teacher.user.name + " [" + teacher.user.product_id + "]" } for teacher in teachers ] data.__setitem__("teachersList", teacherList) if request.method == "POST": if "class_names" in request.POST and "class_div" in request.POST: filter_class = request.POST["class_names"] filter_div = request.POST["class_div"] if filter_class != "all" and filter_div == "all": classes = classes.filter(class_name=filter_class) elif filter_class == "all" and filter_div != "all": classes = classes.filter(class_division=filter_div) elif filter_class != "all" and filter_div != "all": classes = classes.filter(class_name=filter_class, class_division=filter_div) if not classes.exists(): messages.error( request, "The given combination of class and division does not exist" ) dataList = None dataList = [{ "id": cs.subject.id, "name": cs.subject.subject_name, "duration": cs.subject.duration, "assigned_to_class": cs.class_fk.class_name + "-" + cs.class_fk.class_division } for cs in EN_ClassSubjects.objects.filter(class_fk__in=list(classes)) ] data.__setitem__("subjects", dataList) fd_classes = FORM_ClassNamesForSubject( request.POST, request=request ) if request.method == "POST" else FORM_ClassNamesForSubject( request=request) data.__setitem__("class_names", fd_classes) template = loader.get_template("sub_list_all_subjects.html") return HttpResponse(template.render(data, request)) else: messages.warning( request, DisplayKey.get("current_role_cannot_perform_this_action")) return HttpResponseRedirect("../Home")