<s> from django . utils . translation import ugettext_lazy as _ <EOL> from django . utils . translation import ungettext_lazy <EOL> from horizon import tables <EOL> from openstack_dashboard import api <EOL> class CreateRoleLink ( tables . LinkAction ) : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> url = "<STR_LIT>" <EOL> classes = ( "<STR_LIT>" , ) <EOL> icon = "<STR_LIT>" <EOL> policy_rules = ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) <EOL> def allowed ( self , request , role ) : <EOL> return api . keystone . keystone_can_edit_role ( ) <EOL> class EditRoleLink ( tables . LinkAction ) : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> url = "<STR_LIT>" <EOL> classes = ( "<STR_LIT>" , ) <EOL> icon = "<STR_LIT>" <EOL> policy_rules = ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) <EOL> def allowed ( self , request , role ) : <EOL> return api . keystone . keystone_can_edit_role ( ) <EOL> class DeleteRolesAction ( tables . DeleteAction ) : <EOL> @ staticmethod <EOL> def action_present ( count ) : <EOL> return ungettext_lazy ( <EOL> u"<STR_LIT>" , <EOL> u"<STR_LIT>" , <EOL> count <EOL> ) <EOL> @ staticmethod <EOL> def action_past ( count ) : <EOL> return ungettext_lazy ( <EOL> u"<STR_LIT>" , <EOL> u"<STR_LIT>" , <EOL> count <EOL> ) <EOL> policy_rules = ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) <EOL> def allowed ( self , request , role ) : <EOL> return api . keystone . keystone_can_edit_role ( ) <EOL> def delete ( self , request , obj_id ) : <EOL> api . keystone . role_delete ( request , obj_id ) <EOL> class RoleFilterAction ( tables . FilterAction ) : <EOL> def filter ( self , table , roles , filter_string ) : <EOL> """<STR_LIT>""" <EOL> q = filter_string . lower ( ) <EOL> return [ role for role in roles <EOL> if q in role . name . lower ( ) ] <EOL> class RolesTable ( tables . DataTable ) : <EOL> name = tables . Column ( '<STR_LIT:name>' , verbose_name = _ ( '<STR_LIT>' ) ) <EOL> id = tables . Column ( '<STR_LIT:id>' , verbose_name = _ ( '<STR_LIT>' ) ) <EOL> class Meta : <EOL> name = "<STR_LIT>" <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> row_actions = ( EditRoleLink , DeleteRolesAction ) <EOL> table_actions = ( RoleFilterAction , CreateRoleLink , DeleteRolesAction ) </s>
