def assign_user_to_page(page, user, grant_on=ACCESS_PAGE_AND_DESCENDANTS, can_add=False, can_change=False, can_delete=False, can_change_advanced_settings=False, can_publish=False, can_change_permissions=False, can_move_page=False, can_recover_page=True, can_view=False, grant_all=False, global_permission=False):
 grant_all = (grant_all and (not global_permission))
 data = {'can_add': (can_add or grant_all), 'can_change': (can_change or grant_all), 'can_delete': (can_delete or grant_all), 'can_change_advanced_settings': (can_change_advanced_settings or grant_all), 'can_publish': (can_publish or grant_all), 'can_change_permissions': (can_change_permissions or grant_all), 'can_move_page': (can_move_page or grant_all), 'can_view': (can_view or grant_all)}
 page_permission = PagePermission(page=page, user=user, grant_on=grant_on, **data)
 page_permission.save()
 if global_permission:
  page_permission = GlobalPagePermission(user=user, can_recover_page=can_recover_page, **data)
  page_permission.save()
  page_permission.sites.add(Site.objects.get_current())
 return page_permission

def assign_user_to_page ( page , user , grant_on = ACCESS_PAGE_AND_DESCENDANTS , can_add = False , can_change = False , can_delete = False , can_change_advanced_settings = False , can_publish = False , can_change_permissions = False , can_move_page = False , can_recover_page = True , can_view = False , grant_all = False , global_permission = False ) : grant_all = ( grant_all and ( not global_permission ) ) data = { 'can_add' : ( can_add or grant_all ) , 'can_change' : ( can_change or grant_all ) , 'can_delete' : ( can_delete or grant_all ) , 'can_change_advanced_settings' : ( can_change_advanced_settings or grant_all ) , 'can_publish' : ( can_publish or grant_all ) , 'can_change_permissions' : ( can_change_permissions or grant_all ) , 'can_move_page' : ( can_move_page or grant_all ) , 'can_view' : ( can_view or grant_all ) } page_permission = PagePermission ( page = page , user = user , grant_on = grant_on , ** data ) page_permission . save ( ) if global_permission : page_permission = GlobalPagePermission ( user = user , can_recover_page = can_recover_page , ** data ) page_permission . save ( ) page_permission . sites . add ( Site . objects . get_current ( ) ) return page_permission
assigns given user to page .