#NEWLINE# def _render_admin_panel( self , req , cat , page , component ) : #NEWLINE# #INDENT# if component : #NEWLINE# #INDENT# comp = model . Component ( self . env , component ) #NEWLINE# if ( req . method == 'POST' ) : #NEWLINE# #INDENT# if req . args . get ( 'save' ) : #NEWLINE# #INDENT# comp . name = name = req . args . get ( 'name' ) #NEWLINE# comp . owner = req . args . get ( 'owner' ) #NEWLINE# comp . description = req . args . get ( 'description' ) #NEWLINE# try : #NEWLINE# #INDENT# comp . update ( ) #NEWLINE# #UNINDENT# except self . env . db_exc . IntegrityError : #NEWLINE# #INDENT# raise TracError ( _ ( 'Component "%(name)s" already exists.' , name = name ) ) #NEWLINE# #UNINDENT# add_notice ( req , _ ( 'Your changes have been saved.' ) ) #NEWLINE# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if req . args . get ( 'cancel' ) : #NEWLINE# #INDENT# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# Chrome ( self . env ) . add_wiki_toolbars ( req ) #NEWLINE# data = { #NEWLINE# #INDENT# 'view' : 'detail' , #NEWLINE# 'component' : comp , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# default = self . config . get ( 'ticket' , 'default_component' ) #NEWLINE# if ( req . method == 'POST' ) : #NEWLINE# #INDENT# if ( req . args . get ( 'add' ) and req . args . get ( 'name' ) ) : #NEWLINE# #INDENT# name = req . args . get ( 'name' ) #NEWLINE# try : #NEWLINE# #INDENT# comp = model . Component ( self . env , name = name ) #NEWLINE# #UNINDENT# except ResourceNotFound : #NEWLINE# #INDENT# comp = model . Component ( self . env ) #NEWLINE# comp . name = name #NEWLINE# if req . args . get ( 'owner' ) : #NEWLINE# #INDENT# comp . owner = req . args . get ( 'owner' ) #NEWLINE# #UNINDENT# comp . insert ( ) #NEWLINE# add_notice ( req , _ ( 'The component "%(name)s" has been added.' , name = name ) ) #NEWLINE# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( comp . name is None ) : #NEWLINE# #INDENT# raise TracError ( _ ( 'Invalid component name.' ) ) #NEWLINE# #UNINDENT# raise TracError ( _ ( 'Component "%(name)s" already exists.' , name = name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if req . args . get ( 'remove' ) : #NEWLINE# #INDENT# sel = req . args . getlist ( 'sel' ) #NEWLINE# if ( not sel ) : #NEWLINE# #INDENT# raise TracError ( _ ( 'No component selected' ) ) #NEWLINE# #UNINDENT# with self . env . db_transaction : #NEWLINE# #INDENT# for name in sel : #NEWLINE# #INDENT# model . Component ( self . env , name ) . delete ( ) #NEWLINE# if ( name == default ) : #NEWLINE# #INDENT# self . config . set ( 'ticket' , 'default_component' , '' ) #NEWLINE# self . _save_config ( req ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# add_notice ( req , _ ( 'The selected components have been removed.' ) ) #NEWLINE# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if req . args . get ( 'apply' ) : #NEWLINE# #INDENT# name = req . args . get ( 'default' ) #NEWLINE# if ( name and ( name != default ) ) : #NEWLINE# #INDENT# self . log . info ( 'Setting default component to %s' , name ) #NEWLINE# self . config . set ( 'ticket' , 'default_component' , name ) #NEWLINE# self . _save_config ( req ) #NEWLINE# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if req . args . get ( 'clear' ) : #NEWLINE# #INDENT# self . log . info ( 'Clearing default component' ) #NEWLINE# self . config . set ( 'ticket' , 'default_component' , '' ) #NEWLINE# self . _save_config ( req ) #NEWLINE# req . redirect ( req . href . admin ( cat , page ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# data = { #NEWLINE# #INDENT# 'view' : 'list' , #NEWLINE# 'components' : list ( model . Component . select ( self . env ) ) , #NEWLINE# 'default' : default , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# owners = TicketSystem ( self . env ) . get_allowed_owners ( ) #NEWLINE# if ( owners is not None ) : #NEWLINE# #INDENT# owners . insert ( 0 , '' ) #NEWLINE# #UNINDENT# data . update ( { #NEWLINE# #INDENT# 'owners' : owners , #NEWLINE# #UNINDENT# } ) #NEWLINE# return ( 'admin_components.html' , data )