#NEWLINE# @ csrf_protect_m #NEWLINE# def changelist_view( self , request , extra_context = None ) : #NEWLINE# #INDENT# if ( not self . has_change_permission ( request , None ) ) : #NEWLINE# #INDENT# raise PermissionDenied #NEWLINE# #UNINDENT# default_initial = ( ( name , options [ 0 ] ) for ( name , options ) in settings . CONFIG . items ( ) ) #NEWLINE# initial = dict ( default_initial , ** dict ( config . _backend . mget ( settings . CONFIG . keys ( ) ) ) ) #NEWLINE# form = self . change_list_form ( initial = initial ) #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = self . change_list_form ( data = request . POST , initial = initial ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# form . save ( ) #NEWLINE# messages . add_message ( request , messages . SUCCESS , _ ( 'Live settings updated successfully.' ) ) #NEWLINE# return HttpResponseRedirect ( '.' ) #NEWLINE# #UNINDENT# #UNINDENT# context = { #NEWLINE# #INDENT# 'config_values' : [ ] , #NEWLINE# 'title' : _ ( 'Constance config' ) , #NEWLINE# 'app_label' : 'constance' , #NEWLINE# 'opts' : Config . _meta , #NEWLINE# 'form' : form , #NEWLINE# 'media' : ( self . media + form . media ) , #NEWLINE# 'icon_type' : ( 'gif' if ( VERSION < ( 1 , 9 ) ) else 'svg' ) , #NEWLINE# #UNINDENT# } #NEWLINE# for ( name , options ) in settings . CONFIG . items ( ) : #NEWLINE# #INDENT# ( default , help_text ) = ( options [ 0 ] , options [ 1 ] ) #NEWLINE# value = initial . get ( name ) #NEWLINE# if ( value is None ) : #NEWLINE# #INDENT# value = getattr ( config , name ) #NEWLINE# #UNINDENT# context [ 'config_values' ] . append ( { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'default' : localize ( default ) , #NEWLINE# 'help_text' : _ ( request ) , #NEWLINE# 'value' : localize ( value ) , #NEWLINE# 'modified' : ( value != default ) , #NEWLINE# 'form_field' : form [ name ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# context [ 'config_values' ] . sort ( key = itemgetter ( 'name' ) ) #NEWLINE# request . current_app = self . admin_site . name #NEWLINE# extra = ( { #NEWLINE# #INDENT# 'current_app' : self . admin_site . name , #NEWLINE# #UNINDENT# } if ( VERSION < ( 1 , 8 ) ) else { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# return TemplateResponse ( request , self . change_list_template , context , ** extra )