#NEWLINE# def reset_settings( self , old_obj ) : #NEWLINE# #INDENT# for option in Option . objects . filter ( server = self ) : #NEWLINE# #INDENT# option . delete ( ) #NEWLINE# #UNINDENT# for tune in Tune . objects . filter ( server = self ) : #NEWLINE# #INDENT# tune . delete ( ) #NEWLINE# #UNINDENT# for vote in Vote . objects . filter ( server = self ) : #NEWLINE# #INDENT# vote . delete ( ) #NEWLINE# #UNINDENT# for rcon_command in RconCommand . objects . filter ( server = self ) : #NEWLINE# #INDENT# rcon_command . delete ( ) #NEWLINE# #UNINDENT# for available_rcon_command in AvailableRconCommand . objects . filter ( server = self ) : #NEWLINE# #INDENT# available_rcon_command . delete ( ) #NEWLINE# #UNINDENT# config_path = os . path . join ( MEDIA_ROOT , 'mods' , self . mod . title , 'config.cfg' ) #NEWLINE# config = TwConfig ( config_path ) #NEWLINE# config . read ( ) #NEWLINE# for ( key , value ) in config . options . iteritems ( ) : #NEWLINE# #INDENT# widget = 1 #NEWLINE# for widget_type in Option . WIDGET_CHOICES : #NEWLINE# #INDENT# if ( widget_type [ 1 ] == self [ 1 ] ) : #NEWLINE# #INDENT# widget = widget_type [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# data = Option ( server = self , command = key , value = value [ 0 ] , widget = widget ) #NEWLINE# data . save ( ) #NEWLINE# #UNINDENT# for tune in config . tunes : #NEWLINE# #INDENT# data = Tune ( server = self , command = tune [ 'command' ] , value = tune [ 'value' ] ) #NEWLINE# data . save ( ) #NEWLINE# #UNINDENT# for vote in config . votes : #NEWLINE# #INDENT# data = Vote ( server = self , command = vote [ 'command' ] , title = vote [ 'title' ] ) #NEWLINE# data . save ( ) #NEWLINE# #UNINDENT# for rcon_command in config . available_rcon_commands : #NEWLINE# #INDENT# data = AvailableRconCommand ( server = self , command = rcon_command ) #NEWLINE# data . save ( ) #NEWLINE# #UNINDENT# if old_obj : #NEWLINE# #INDENT# server_maps_path = os . path . join ( MEDIA_ROOT , 'mods' , old_obj . mod . title , 'servers' , old_obj . owner . username , '{0}' . format ( old_obj . id ) , old_obj . random_key , 'maps' ) #NEWLINE# if os . path . exists ( server_maps_path ) : #NEWLINE# #INDENT# maps = [ _file for _file in os . listdir ( server_maps_path ) if ( os . path . splitext ( _file ) [ 1 ] . lower ( ) == '.map' ) ] #NEWLINE# for _map in maps : #NEWLINE# #INDENT# new_server_maps_path = os . path . join ( MEDIA_ROOT , 'mods' , self . mod . title , 'servers' , self . owner . username , '{0}' . format ( self . id ) , self . random_key , 'maps' ) #NEWLINE# if ( not os . path . exists ( new_server_maps_path ) ) : #NEWLINE# #INDENT# os . makedirs ( new_server_maps_path ) #NEWLINE# #UNINDENT# copyfile ( os . path . join ( server_maps_path , _map ) , os . path . join ( new_server_maps_path , _map ) ) #NEWLINE# #UNINDENT# rmtree ( os . path . join ( MEDIA_ROOT , 'mods' , old_obj . mod . title , 'servers' , old_obj . owner . username ) ) #NEWLINE# #UNINDENT# #UNINDENT# maps_path = os . path . join ( MEDIA_ROOT , 'mods' , self . mod . title , 'data' , 'maps' ) #NEWLINE# if os . path . exists ( maps_path ) : #NEWLINE# #INDENT# maps = [ _file for _file in os . listdir ( maps_path ) if ( os . path . splitext ( _file ) [ 1 ] . lower ( ) == '.map' ) ] #NEWLINE# for _map in maps : #NEWLINE# #INDENT# map_obj = Map . objects . filter ( server = self , name = os . path . splitext ( _map ) [ 0 ] ) #NEWLINE# if ( not map_obj ) : #NEWLINE# #INDENT# map_obj = Map ( server = self , name = os . path . splitext ( _map ) [ 0 ] ) #NEWLINE# map_obj . save ( ) #NEWLINE# server_maps_path = os . path . join ( MEDIA_ROOT , 'mods' , self . mod . title , 'servers' , self . owner . username , '{0}' . format ( self . id ) , self . random_key , 'maps' ) #NEWLINE# if ( not os . path . exists ( server_maps_path ) ) : #NEWLINE# #INDENT# os . makedirs ( server_maps_path ) #NEWLINE# #UNINDENT# copyfile ( os . path . join ( maps_path , _map ) , os . path . join ( server_maps_path , _map ) )