#NEWLINE# def get_acl_users_forms( self , request , object_id , template = 'acl/user_acl_users.html' ) : #NEWLINE# #INDENT# extra_context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# obj = self . model . objects . get ( pk = object_id ) #NEWLINE# ct = ContentType . objects . get_for_model ( obj ) #NEWLINE# extra_context [ 'object_name' ] = unicode ( obj ) #NEWLINE# acl_template = 'acl/acl_users.html' #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# selected = request . POST . getlist ( '_selected_action' ) #NEWLINE# selected_verbs = request . POST . getlist ( '_selected_verbs' ) #NEWLINE# ACLPermission . objects . filter ( object_id = obj . pk , content_type = ct , user__isnull = False ) . delete ( ) #NEWLINE# ol = User . objects . filter ( pk__in = selected ) #NEWLINE# for u in ol : #NEWLINE# #INDENT# for ac in request . POST : #NEWLINE# #INDENT# if ( ( ac [ : 5 ] == 'perm_' ) and ( request . POST [ ac ] != '' ) ) : #NEWLINE# #INDENT# acc = ac . split ( '_' ) #NEWLINE# if ( ( acc [ 2 ] in selected ) and ( long ( acc [ 2 ] ) == u . pk ) ) : #NEWLINE# #INDENT# self . add_perm ( acc [ 1 ] , obj , u , request . POST [ ac ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# u = request . POST . get ( 'u' , '' ) #NEWLINE# if u : #NEWLINE# #INDENT# u = User . objects . get ( pk = u ) #NEWLINE# check = get_acl_for_model ( obj ) #NEWLINE# for v in selected_verbs : #NEWLINE# #INDENT# check . add_perm ( v , obj , u , defines . ZORNA_PERMISSIONS_ALLOW ) #NEWLINE# #UNINDENT# #UNINDENT# cache . delete ( ACL_USERS_PERMISSIONS_CACHE ) #NEWLINE# redirect = request . POST . get ( 'next' , None ) #NEWLINE# if redirect : #NEWLINE# #INDENT# if ( '?' not in redirect ) : #NEWLINE# #INDENT# redirect = ( ( redirect + '?object_id=' ) + str ( object_id ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redirect = ( ( redirect + '&object_id=' ) + str ( object_id ) ) #NEWLINE# #UNINDENT# return HttpResponseRedirect ( redirect ) #NEWLINE# #UNINDENT# #UNINDENT# extra_context [ 'verbs' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in self . perms . iteritems ( ) : #NEWLINE# #INDENT# extra_context [ 'verbs' ] [ k ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# extra_context [ 'verbs' ] [ k ] [ 'text' ] = _ ( v . name ) #NEWLINE# #UNINDENT# ob_list = User . objects . filter ( aclpermission__user__isnull = False , aclpermission__object_id = obj . pk , aclpermission__content_type = ct ) . distinct ( ) #NEWLINE# perm = ACLPermission . objects . select_related ( ) . filter ( object_id = obj . pk , content_type = ct , user__isnull = False ) #NEWLINE# dummy = ob_list #NEWLINE# for ob in dummy : #NEWLINE# #INDENT# ob . verbs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in self . perms . iteritems ( ) : #NEWLINE# #INDENT# ob . verbs [ k ] = '' #NEWLINE# for g in perm : #NEWLINE# #INDENT# if ( ( g . user_id == ob . id ) and ( k == g . permission . codename ) ) : #NEWLINE# #INDENT# ob . verbs [ k ] = g . acltype #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# extra_context [ 'users_list' ] = dummy #NEWLINE# extra_context [ 'object' ] = obj #NEWLINE# extra_context [ 'next' ] = request . REQUEST . get ( 'next' , '' ) #NEWLINE# paginate_by = 20 #NEWLINE# paginator = Paginator ( ob_list . _clone ( ) , paginate_by , allow_empty_first_page = True ) #NEWLINE# page = request . GET . get ( 'page' , 1 ) #NEWLINE# try : #NEWLINE# #INDENT# page_number = int ( page ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# if ( page == 'last' ) : #NEWLINE# #INDENT# page_number = paginator . num_pages #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# page_obj = paginator . page ( page_number ) #NEWLINE# #UNINDENT# except InvalidPage : #NEWLINE# #INDENT# raise Http404 #NEWLINE# #UNINDENT# extra_context [ 'paginator' ] = paginator #NEWLINE# extra_context [ 'page_obj' ] = page_obj #NEWLINE# extra_context [ 'acl_form' ] = render_to_string ( acl_template , extra_context , context_instance = RequestContext ( request ) ) #NEWLINE# context = RequestContext ( request ) #NEWLINE# if template : #NEWLINE# #INDENT# return render_to_response ( template , extra_context , context_instance = context ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return extra_context