Source code for uw.local.grad.bin.auto_update_states

"""Automatic status update process.

Python process meant to be run automatically after Quest data load to update
application states to match changes in GSO application decisions.
"""

from uw.sql.wrap import open_psycopg2_db_service_cursor

from ..db.status import change_state
from ..db.unitapp import UnitApplication
from ..db.cursor import Cursor

[docs]def main (): """Program entry point to update application states. Uses the view work_application_state_change_update to determine what needs to be done, and calls :func:`uw.local.grad.db.status.change_state` to do the work. """ # need GrAd cursor, not generic one cursor = open_psycopg2_db_service_cursor (cursor_class=Cursor) for update in cursor.execute_tuples ("select * from work_application_state_change_update where admit_term_id >= '1121'"): unitapp = UnitApplication (cursor, cursor.unitapp_by_id (appl_id=update.appl_id)) change_state (unitapp, None, update.new_status_code, use_default=True) cursor.connection.commit ()