#NEWLINE# def facebook_channel( ) : #NEWLINE# #INDENT# '\n        RESTful CRUD controller for Facebook channels\n            - appears in the administration menu\n    ' #NEWLINE# if ( not auth . s3_has_role ( ADMIN ) ) : #NEWLINE# #INDENT# session . error = ERROR . UNAUTHORISED #NEWLINE# redirect ( URL ( f = 'index' ) ) #NEWLINE# #UNINDENT# tablename = 'msg_facebook_channel' #NEWLINE# table = s3db [ tablename ] #NEWLINE# s3 . crud_strings [ tablename ] = Storage ( title_display = T ( 'Facebook Settings' ) , title_list = T ( 'Facebook Accounts' ) , label_create = T ( 'Add Facebook Account' ) , title_update = T ( 'Edit Facebook Settings' ) , label_list_button = T ( 'View Facebook Accounts' ) , msg_record_created = T ( 'Account added' ) , msg_record_deleted = T ( 'Facebook Account deleted' ) , msg_list_empty = T ( 'No Accounts currently defined' ) , msg_record_modified = T ( 'Facebook Settings updated' ) ) #NEWLINE# def postp( r , output ) : #NEWLINE# #INDENT# if r . interactive : #NEWLINE# #INDENT# s3_action_buttons ( r ) #NEWLINE# table = r . table #NEWLINE# query = ( table . deleted == False ) #NEWLINE# rows = db ( query ) . select ( table . id , table . enabled ) #NEWLINE# restrict_e = [ str ( row . id ) for row in rows if ( not row . enabled ) ] #NEWLINE# restrict_d = [ str ( row . id ) for row in rows if row . enabled ] #NEWLINE# from s3 import s3_str #NEWLINE# s3 . actions += [ dict ( label = s3_str ( T ( 'Enable' ) ) , _class = 'action-btn' , url = URL ( args = [ '[id]' , 'enable' ] ) , restrict = restrict_e ) , dict ( label = s3_str ( T ( 'Disable' ) ) , _class = 'action-btn' , url = URL ( args = [ '[id]' , 'disable' ] ) , restrict = restrict_d ) ] #NEWLINE# #UNINDENT# return output #NEWLINE# #UNINDENT# s3 . postp = postp #NEWLINE# return s3_rest_controller ( )