#NEWLINE# def render_preference_panel( self , req , panel , path_info = None ) : #NEWLINE# #INDENT# if ( req . method == 'POST' ) : #NEWLINE# #INDENT# action_arg = req . args . get ( 'action' , '' ) #NEWLINE# m = re . match ( '^([^_]+)_(.+)' , action_arg ) #NEWLINE# if m : #NEWLINE# #INDENT# ( action , arg ) = m . groups ( ) #NEWLINE# handler = self . post_handlers . get ( action ) #NEWLINE# if handler : #NEWLINE# #INDENT# handler ( arg , req ) #NEWLINE# add_notice ( req , _ ( 'Your preferences have been saved.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# req . redirect ( req . href . prefs ( 'notification' ) ) #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'rules' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'subscribers' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# desc_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# defaults = [ ] #NEWLINE# data [ 'formatters' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# data [ 'selected_format' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# data [ 'adverbs' ] = ( 'always' , 'never' ) #NEWLINE# data [ 'adverb_labels' ] = dict ( always = _ ( 'Notify' ) , never = _ ( 'Never notify' ) ) #NEWLINE# for i in self . subscribers : #NEWLINE# #INDENT# if ( not i . description ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( not req . session . authenticated ) and i . requires_authentication ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# data [ 'subscribers' ] . append ( { #NEWLINE# #INDENT# 'class' : i . __class__ . __name__ , #NEWLINE# 'description' : i . description ( ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# desc_map [ i . __class__ . __name__ ] = i . description ( ) #NEWLINE# if hasattr ( i , 'default_subscriptions' ) : #NEWLINE# #INDENT# defaults . extend ( i . default_subscriptions ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# for t in self . _iter_transports ( ) : #NEWLINE# #INDENT# data [ 'rules' ] [ t ] = [ ] #NEWLINE# styles = self . _get_supported_styles ( t ) #NEWLINE# data [ 'formatters' ] [ t ] = styles #NEWLINE# data [ 'selected_format' ] [ t ] = styles [ 0 ] #NEWLINE# for r in Subscription . find_by_sid_and_distributor ( self . env , req . session . sid , req . session . authenticated , t ) : #NEWLINE# #INDENT# if desc_map . get ( r [ 'class' ] ) : #NEWLINE# #INDENT# data [ 'rules' ] [ t ] . append ( { #NEWLINE# #INDENT# 'id' : r [ 'id' ] , #NEWLINE# 'adverb' : r [ 'adverb' ] , #NEWLINE# 'class' : r [ 'class' ] , #NEWLINE# 'description' : desc_map [ r [ 'class' ] ] , #NEWLINE# 'priority' : r [ 'priority' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# data [ 'selected_format' ] [ adverb ] = r [ 'format' ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# data [ 'default_rules' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for r in sorted ( defaults , key = itemgetter ( 3 ) ) : #NEWLINE# #INDENT# ( klass , dist , format , priority , adverb ) = r #NEWLINE# if ( not data [ 'default_rules' ] . get ( dist ) ) : #NEWLINE# #INDENT# data [ 'default_rules' ] [ dist ] = [ ] #NEWLINE# #UNINDENT# if desc_map . get ( klass ) : #NEWLINE# #INDENT# data [ 'default_rules' ] [ dist ] . append ( { #NEWLINE# #INDENT# 'adverb' : adverb , #NEWLINE# 'description' : desc_map . get ( klass ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# Chrome ( self . env ) . add_jquery_ui ( req ) #NEWLINE# return ( 'prefs_notification.html' , dict ( data = data ) )