Move apply_filter_query function to models.util module for easy sharing between model classes.