Source code for uw.local.print_.db.cursor
"""Cursor class for Print.
Inherits from the usual cursor class with added methods for commonly-needed
queries.
"""
from uw.local.dbtools import Cursor
from uw.sql.dbapi import *
[docs]class Cursor (Cursor):
all_requisitions = make_execute_tuples ("select * from nms_requisition_received_plus order by requisition_num desc")
requisition_by_num = make_execute_optional_tuple ("select * from nms_requisition_received_plus where requisition_num = %(requisition_num)s")
all_jobs = make_execute_tuples ("select * from nms_requisition_plus order by job_id desc")
job_by_id = make_execute_optional_tuple ("select * from nms_requisition_plus where job_id = %(job_id)s")
orgunit_jobs = make_execute_tuples ("select * from nms_requisition_plus where requisition_orgunit = %(orgunit)s order by job_id desc")
file_query = "select job_id, file_code, file_contents, requisition_num, requisition_title from nms_requisition_file natural join nms_requisition_plus where %s"
files_by_job = make_execute_tuples (file_query % "job_id = %(job_id)s")
file_by_ids = make_execute_optional_tuple (file_query % "(job_id, file_code) = (%(job_id)s, %(file_code)s)")
check_perm_admin = make_execute_optional_value ("select is_admin from auth_user where person_id = %(person_id)s")
check_perm_orgunit = make_execute_required_value ("select exists (select * from auth_user_orgunit where (person_id, orgunit) = (%(person_id)s, %(orgunit)s))")
list_user_orgunits = make_execute_values ("select orgunit from auth_user_orgunit where person_id = %(person_id)s order by orgunit")