#NEWLINE# def modal_permissions( request , group_id ) : #NEWLINE# #INDENT# group = get_object_or_404 ( DepartmentGroup , pk = group_id ) #NEWLINE# department = Department . objects . get ( pk = request . current_department_id ) #NEWLINE# if ( group . department_id != department . id ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not request . user . has_perm ( 'core.change_department' , department ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# data [ 'group' ] = group #NEWLINE# data [ 'form_template' ] = 'partial/permissions_form.html' #NEWLINE# data [ 'model_name' ] = ( '%s group permissions' % group . local_name ) #NEWLINE# data [ 'is_new' ] = False #NEWLINE# data [ 'no_delete' ] = True #NEWLINE# data [ 'request_path' ] = request . path #NEWLINE# data [ 'applications' ] = department . applications #NEWLINE# from core.models import Application , Environment #NEWLINE# from task.models import Task #NEWLINE# models = { #NEWLINE# #INDENT# 'department' : Department , #NEWLINE# 'application' : Application , #NEWLINE# 'environment' : Environment , #NEWLINE# 'task' : Task , #NEWLINE# #UNINDENT# } #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# from guardian.models import GroupObjectPermission #NEWLINE# from guardian.shortcuts import assign_perm #NEWLINE# GroupObjectPermission . objects . filter ( group_id = group . id ) . delete ( ) #NEWLINE# assign_perm ( 'core.view_department' , group , group . department ) #NEWLINE# for ( name , value ) in request . POST . items ( ) : #NEWLINE# #INDENT# key = name . split ( '_' ) #NEWLINE# if ( ( len ( key ) == 3 ) and ( value == 'on' ) ) : #NEWLINE# #INDENT# ( action , model , pk ) = key #NEWLINE# assign_perm ( ( '%s_%s' % ( action , model ) ) , group , models [ model ] . objects . get ( pk = pk ) ) #NEWLINE# #UNINDENT# #UNINDENT# return HttpResponse ( json . dumps ( { #NEWLINE# #INDENT# 'status' : True , #NEWLINE# #UNINDENT# } ) , content_type = 'application/json' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return render ( request , 'partial/modal_form.html' , data )