Move model event related functions to events.py.