def view_packages_self(): """View packages designated or assigned to user. Args: Returns: Render template for viewing packages. """ db_session = Session() base_query = db_session.query(Package) if account.get_current_role() == STUDENT_ROLE: student_id = account.student.student_info packages = base_query.filter_by(student_id=student_id).all() return render_template('parcels.html', packages=packages) elif account.get_current_role() == EMPLOYEE_ROLE: packages = base_query.filter_by(received_by=account.employee.id).all() return render_template('parcels.html', packages=packages) else: abort(404)
def view_package_details(package_id): """View package details of package with id ``package_id``. Args: package_id (int): Id of package to view details of. Returns: Render template for viewing packages details. """ db_session = Session() package = db_session.query(Package).filter_by(id=package_id).first() if not package: abort(404) package_form = EditPackageForm(obj=package) if (account.get_current_role() == EMPLOYEE_ROLE or (account.get_current_role() == STUDENT_ROLE and package.student_id == account.student.student_info)): return render_template('parcels.html', package=package_form) else: abort(404)
def view_notifications(package_id): """View notifications of package with package id ``package_id``. Args: package_id (int): Id of package to view an e-mail notifications of. Returns: Redirect to :func:`view_notifications_self` if requested by student role. Render template to display notifications otherwise. """ db_session = Session() if account.get_current_role() == STUDENT_ROLE: return redirect( url_for('.view_notifications_self', package_id=package_id)) notifications = db_session.query(Notification).filter_by( package_id=package_id).all() return render_template('owls.html', notifications=notifications)
def view_notifications(package_id): """View notifications of package with package id ``package_id``. Args: package_id (int): Id of package to view an e-mail notifications of. Returns: Redirect to :func:`view_notifications_self` if requested by student role. Render template to display notifications otherwise. """ db_session = Session() if account.get_current_role() == STUDENT_ROLE: return redirect( url_for('.view_notifications_self', package_id=package_id) ) notifications = db_session.query( Notification ).filter_by(package_id=package_id).all() return render_template('owls.html', notifications=notifications)
def wizards_index(): if account.get_current_role() == STUDENT_ROLE: return redirect(url_for(".view_student_self"), 303) else: return redirect(url_for(".search_students"), 303)
def parcels_index(): if account.get_current_role() == STUDENT_ROLE: return redirect(url_for('.view_packages_self'), 303) else: # return render_template('parcels.html') return redirect(url_for('.view_packages_self'), 303)
def wizards_index(): if account.get_current_role() == STUDENT_ROLE: return redirect(url_for('.view_student_self'), 303) else: return redirect(url_for('.search_students'), 303)
def wrapped(*args, **kwargs): if current_user.get_current_role() not in roles: abort(403) return f(*args, **kwargs)