<s> from cms . cache . permissions import clear_user_permission_cache <EOL> from cms . models import PageUser , PageUserGroup <EOL> from menus . menu_pool import menu_pool <EOL> def post_save_user ( instance , raw , created , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> from cms . utils . permissions import get_current_user <EOL> creator = get_current_user ( ) <EOL> if not creator or not created or creator . is_anonymous ( ) : <EOL> return <EOL> page_user = PageUser ( user_ptr_id = instance . pk , created_by = creator ) <EOL> page_user . __dict__ . update ( instance . __dict__ ) <EOL> page_user . save ( ) <EOL> def post_save_user_group ( instance , raw , created , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> from cms . utils . permissions import get_current_user <EOL> creator = get_current_user ( ) <EOL> if not creator or not created or creator . is_anonymous ( ) : <EOL> return <EOL> page_user = PageUserGroup ( group_ptr_id = instance . pk , created_by = creator ) <EOL> page_user . __dict__ . update ( instance . __dict__ ) <EOL> page_user . save ( ) <EOL> def pre_save_user ( instance , raw , ** kwargs ) : <EOL> clear_user_permission_cache ( instance ) <EOL> def pre_delete_user ( instance , ** kwargs ) : <EOL> clear_user_permission_cache ( instance ) <EOL> def pre_save_group ( instance , raw , ** kwargs ) : <EOL> if instance . pk : <EOL> user_set = getattr ( instance , '<STR_LIT>' ) <EOL> for user in user_set . all ( ) : <EOL> clear_user_permission_cache ( user ) <EOL> def pre_delete_group ( instance , ** kwargs ) : <EOL> user_set = getattr ( instance , '<STR_LIT>' ) <EOL> for user in user_set . all ( ) : <EOL> clear_user_permission_cache ( user ) <EOL> def _clear_users_permissions ( instance ) : <EOL> if instance . user : <EOL> clear_user_permission_cache ( instance . user ) <EOL> if instance . group : <EOL> user_set = getattr ( instance . group , '<STR_LIT>' ) <EOL> for user in user_set . all ( ) : <EOL> clear_user_permission_cache ( user ) <EOL> def pre_save_pagepermission ( instance , raw , ** kwargs ) : <EOL> _clear_users_permissions ( instance ) <EOL> def pre_delete_pagepermission ( instance , ** kwargs ) : <EOL> _clear_users_permissions ( instance ) <EOL> def pre_save_globalpagepermission ( instance , raw , ** kwargs ) : <EOL> _clear_users_permissions ( instance ) <EOL> menu_pool . clear ( all = True ) <EOL> def pre_delete_globalpagepermission ( instance , ** kwargs ) : <EOL> _clear_users_permissions ( instance ) </s>
