<s> from collections import OrderedDict <EOL> from django . utils . html import escapejs <EOL> from django . utils . translation import ugettext as _ <EOL> from freenasUI . api . resources import ( <EOL> BsdUserResourceMixin , BsdGroupResourceMixin <EOL> ) <EOL> from freenasUI . freeadmin . options import BaseFreeAdmin <EOL> from freenasUI . freeadmin . site import site <EOL> from freenasUI . account import models <EOL> class BsdUserFAdmin ( BaseFreeAdmin ) : <EOL> create_modelform = "<STR_LIT>" <EOL> edit_modelform = "<STR_LIT>" <EOL> object_filters = { '<STR_LIT>' : False } <EOL> object_num = - <NUM_LIT:1> <EOL> icon_object = u"<STR_LIT>" <EOL> icon_model = u"<STR_LIT>" <EOL> icon_add = u"<STR_LIT>" <EOL> icon_view = u"<STR_LIT>" <EOL> resource_mixin = BsdUserResourceMixin <EOL> resource_name = '<STR_LIT>' <EOL> exclude_fields = ( <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def _action_builder ( self , name , label = None , url = None , builtin = None ) : <EOL> func = "<STR_LIT>" <EOL> if url is None : <EOL> url = "<STR_LIT>" % ( name , ) <EOL> if builtin is False : <EOL> hide = "<STR_LIT>" <EOL> elif builtin is True : <EOL> hide = "<STR_LIT>" <EOL> else : <EOL> hide = "<STR_LIT:false>" <EOL> on_select_after = """<STR_LIT>""" % { <EOL> '<STR_LIT>' : hide , <EOL> } <EOL> on_click = """<STR_LIT>""" % { <EOL> '<STR_LIT>' : func , <EOL> '<STR_LIT:label>' : escapejs ( label ) , <EOL> '<STR_LIT:url>' : url , <EOL> } <EOL> data = { <EOL> '<STR_LIT>' : label , <EOL> '<STR_LIT>' : on_select_after , <EOL> '<STR_LIT>' : on_click , <EOL> } <EOL> return data <EOL> def get_actions ( self ) : <EOL> actions = OrderedDict ( ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> builtin = False , <EOL> ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT:email>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> builtin = True , <EOL> ) <EOL> return actions <EOL> class BsdGroupFAdmin ( BaseFreeAdmin ) : <EOL> delete_form = "<STR_LIT>" <EOL> object_filters = { '<STR_LIT>' : False } <EOL> object_num = - <NUM_LIT:1> <EOL> icon_object = u"<STR_LIT>" <EOL> icon_model = u"<STR_LIT>" <EOL> icon_add = u"<STR_LIT>" <EOL> icon_view = u"<STR_LIT>" <EOL> resource_mixin = BsdGroupResourceMixin <EOL> resource_name = '<STR_LIT>' <EOL> def _action_builder ( self , name , label = None , url = None , builtin = None ) : <EOL> func = "<STR_LIT>" <EOL> if url is None : <EOL> url = "<STR_LIT>" % ( name , ) <EOL> if builtin is False : <EOL> hide = "<STR_LIT>" <EOL> elif builtin is True : <EOL> hide = "<STR_LIT>" <EOL> else : <EOL> hide = "<STR_LIT:false>" <EOL> on_select_after = """<STR_LIT>""" % { <EOL> '<STR_LIT>' : hide , <EOL> } <EOL> on_click = """<STR_LIT>""" % { <EOL> '<STR_LIT>' : func , <EOL> '<STR_LIT:label>' : escapejs ( label ) , <EOL> '<STR_LIT:url>' : url , <EOL> } <EOL> data = { <EOL> '<STR_LIT>' : label , <EOL> '<STR_LIT>' : on_select_after , <EOL> '<STR_LIT>' : on_click , <EOL> } <EOL> return data <EOL> def get_actions ( self ) : <EOL> actions = OrderedDict ( ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> builtin = False , <EOL> ) <EOL> actions [ '<STR_LIT>' ] = self . _action_builder ( <EOL> "<STR_LIT>" , <EOL> label = _ ( '<STR_LIT>' ) , <EOL> builtin = False , <EOL> ) <EOL> return actions <EOL> site . register ( models . bsdUsers , BsdUserFAdmin ) <EOL> site . register ( models . bsdGroups , BsdGroupFAdmin ) </s>
