#NEWLINE# def get_acl_groups_forms( self , request , object_id , **kwargs ) : #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# try : #NEWLINE# #INDENT# exclude = kwargs [ 'exclude' ] #NEWLINE# ob_list = UserGroup . objects . exclude ( pk__in = exclude ) . order_by ( 'lft' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# ob_list = UserGroup . objects . all ( ) . order_by ( 'lft' ) #NEWLINE# #UNINDENT# template = 'acl/acl_groups.html' #NEWLINE# extra_context [ 'proto_perm' ] = None #NEWLINE# perm_object = obj #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# if ( 'bupdate' not in request . POST ) : #NEWLINE# #INDENT# pr = request . POST . get ( 'proto_perm' , None ) #NEWLINE# if pr : #NEWLINE# #INDENT# perm_object = self . model . objects . get ( pk = pr ) #NEWLINE# extra_context [ 'proto_perm' ] = perm_object . pk #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ACLPermission . objects . filter ( object_id = obj . pk , content_type = ct , group__isnull = False ) . delete ( ) #NEWLINE# temp = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ac in request . POST : #NEWLINE# #INDENT# if ( ( ac [ : 5 ] == 'perm_' ) and ( request . POST [ ac ] != '' ) ) : #NEWLINE# #INDENT# acc = ac . split ( '_' ) #NEWLINE# try : #NEWLINE# #INDENT# temp [ int ( acc [ 2 ] ) ] . append ( ( acc [ 1 ] , request . POST [ ac ] ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# temp [ int ( acc [ 2 ] ) ] = [ ] #NEWLINE# temp [ int ( acc [ 2 ] ) ] . append ( ( acc [ 1 ] , request . POST [ ac ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if len ( temp ) : #NEWLINE# #INDENT# grp = UserGroup . objects . in_bulk ( temp . keys ( ) ) #NEWLINE# for ( g_id , g ) in grp . iteritems ( ) : #NEWLINE# #INDENT# for c in temp [ g_id ] : #NEWLINE# #INDENT# self . add_perm ( c [ 0 ] , obj , g , c [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# perm_object = obj #NEWLINE# cache . delete ( ACL_USERS_PERMISSIONS_CACHE ) #NEWLINE# cache . delete ( ACL_GROUPS_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# #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# perm = ACLPermission . objects . select_related ( ) . filter ( object_id = perm_object . pk , content_type = ct , group__isnull = False ) #NEWLINE# parentsid = [ ] #NEWLINE# for ob in ob_list : #NEWLINE# #INDENT# if ( ob . pk > defines . ZORNA_GROUP_REGISTERED ) : #NEWLINE# #INDENT# ob . show_members = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ob . show_members = False #NEWLINE# #UNINDENT# 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 . group_id == ob . id ) and ( k == g . permission . codename ) ) : #NEWLINE# #INDENT# ob . verbs [ k ] = g . acltype #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ob . parent_id not in parentsid ) : #NEWLINE# #INDENT# ob . parent_id = 0 #NEWLINE# #UNINDENT# parentsid . append ( ob . pk ) #NEWLINE# #UNINDENT# extra_context [ 'perm_objects' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# perm = ACLPermission . objects . select_related ( ) . filter ( content_type = ct , group__isnull = False ) . exclude ( object_id = obj . pk ) #NEWLINE# for p in perm : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# extra_context [ 'perm_objects' ] [ p . content_object . pk ] = p . content_object #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# extra_context [ 'next' ] = request . REQUEST . get ( 'next' , '' ) #NEWLINE# extra_context [ 'object' ] = obj #NEWLINE# extra_context [ 'object_list' ] = v #NEWLINE# context = RequestContext ( request ) #NEWLINE# return render_to_response ( template , extra_context , context_instance = context )