mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 08:00:02 -06:00
Add Object.label class attribute, enable in webUI
This commit is contained in:
parent
338578d10a
commit
069763c5c6
@ -1110,6 +1110,9 @@ class Property(Attribute):
|
||||
|
||||
def __init__(self):
|
||||
super(Property, self).__init__()
|
||||
# FIXME: This is a hack till Param.label is updated to require a
|
||||
# LazyText instance:
|
||||
self.label = None
|
||||
self.rules = tuple(
|
||||
sorted(self.__rules_iter(), key=lambda f: getattr(f, '__name__'))
|
||||
)
|
||||
|
@ -37,9 +37,13 @@ import optparse
|
||||
import errors
|
||||
from config import Env
|
||||
import util
|
||||
import text
|
||||
from base import ReadOnly, NameSpace, lock, islocked, check_name
|
||||
from constants import DEFAULT_CONFIG, FORMAT_STDERR, FORMAT_FILE
|
||||
|
||||
# FIXME: Updated constants.TYPE_ERROR to use this clearer format from wehjit:
|
||||
TYPE_ERROR = '%s: need a %r; got a %r: %r'
|
||||
|
||||
|
||||
class SetProxy(ReadOnly):
|
||||
"""
|
||||
@ -155,6 +159,8 @@ class Plugin(ReadOnly):
|
||||
Base class for all plugins.
|
||||
"""
|
||||
|
||||
label = None
|
||||
|
||||
def __init__(self):
|
||||
self.__api = None
|
||||
cls = self.__class__
|
||||
@ -177,6 +183,17 @@ class Plugin(ReadOnly):
|
||||
self.name, name, getattr(self, name))
|
||||
)
|
||||
setattr(self, name, getattr(log, name))
|
||||
if self.label is None:
|
||||
self.label = text.FixMe(self.name + '.label')
|
||||
if not isinstance(self.label, text.LazyText):
|
||||
raise TypeError(
|
||||
TYPE_ERROR % (
|
||||
self.fullname + '.label',
|
||||
text.LazyText,
|
||||
type(self.label),
|
||||
self.label
|
||||
)
|
||||
)
|
||||
|
||||
def __get_api(self):
|
||||
"""
|
||||
|
@ -197,6 +197,9 @@ class aci(Object):
|
||||
"""
|
||||
ACI object.
|
||||
"""
|
||||
|
||||
label = _('ACIs')
|
||||
|
||||
takes_params = (
|
||||
Str('aciname',
|
||||
cli_name='name',
|
||||
|
@ -88,6 +88,7 @@ from ipalib import api, errors
|
||||
from ipalib import Object, Command
|
||||
from ipalib import Flag, Str
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib import _, ngettext
|
||||
|
||||
|
||||
class automountlocation(LDAPObject):
|
||||
@ -227,6 +228,8 @@ class automountmap(LDAPObject):
|
||||
),
|
||||
)
|
||||
|
||||
label = _('Automount Maps')
|
||||
|
||||
api.register(automountmap)
|
||||
|
||||
|
||||
@ -315,6 +318,8 @@ class automountkey(LDAPObject):
|
||||
),
|
||||
)
|
||||
|
||||
label = _('Automount Keys')
|
||||
|
||||
api.register(automountkey)
|
||||
|
||||
|
||||
@ -384,4 +389,3 @@ class automountkey_show(LDAPRetrieve):
|
||||
"""
|
||||
|
||||
api.register(automountkey_show)
|
||||
|
||||
|
@ -66,6 +66,7 @@ import time
|
||||
from ipalib import api, crud, errors, output
|
||||
from ipalib import Object, Command
|
||||
from ipalib import Flag, Int, Str, StrEnum
|
||||
from ipalib import _, ngettext
|
||||
|
||||
# parent DN
|
||||
_zone_container_dn = api.env.container_dns
|
||||
@ -110,6 +111,8 @@ def _get_record_dn(ldap, zone, idnsname):
|
||||
class dns(Object):
|
||||
"""DNS zone/SOA record object."""
|
||||
|
||||
label = _('DNS')
|
||||
|
||||
takes_params = (
|
||||
Str('idnsname',
|
||||
cli_name='name',
|
||||
@ -857,4 +860,3 @@ class dns_show_rr(Command):
|
||||
textui.print_entry(entry_attrs)
|
||||
|
||||
api.register(dns_show_rr)
|
||||
|
||||
|
@ -55,6 +55,8 @@ class group(LDAPObject):
|
||||
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
|
||||
}
|
||||
|
||||
label = _('User Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
|
@ -23,6 +23,7 @@ Host based access control
|
||||
from ipalib import api, errors
|
||||
from ipalib import AccessTime, Password, Str, StrEnum
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib import _, ngettext
|
||||
|
||||
class hbac(LDAPObject):
|
||||
"""
|
||||
@ -58,6 +59,8 @@ class hbac(LDAPObject):
|
||||
'sourcehost': ['host', 'hostgroup'],
|
||||
}
|
||||
|
||||
label = _('HBAC')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
|
@ -79,6 +79,8 @@ class host(LDAPObject):
|
||||
'memberof': ['hostgroup', 'netgroup', 'rolegroup'],
|
||||
}
|
||||
|
||||
label = _('Hosts')
|
||||
|
||||
takes_params = (
|
||||
Str('fqdn', validate_host,
|
||||
cli_name='hostname',
|
||||
|
@ -46,6 +46,8 @@ class hostgroup(LDAPObject):
|
||||
'memberof': ['hostgroup'],
|
||||
}
|
||||
|
||||
label = _('Host Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
|
@ -23,6 +23,7 @@ Netgroups
|
||||
|
||||
from ipalib import api, errors
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib import _, ngettext
|
||||
|
||||
|
||||
class netgroup(LDAPObject):
|
||||
@ -51,6 +52,8 @@ class netgroup(LDAPObject):
|
||||
'externalhost': [],
|
||||
}
|
||||
|
||||
label = _('Net Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
@ -200,4 +203,3 @@ class netgroup_remove_member(LDAPRemoveMember):
|
||||
return (completed + completed_external, dn)
|
||||
|
||||
api.register(netgroup_remove_member)
|
||||
|
||||
|
@ -47,6 +47,8 @@ class rolegroup(LDAPObject):
|
||||
'memberof': ['taskgroup'],
|
||||
}
|
||||
|
||||
label = _('Role Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
|
@ -119,6 +119,8 @@ class service(LDAPObject):
|
||||
'managedby': ['host'],
|
||||
}
|
||||
|
||||
label = _('Services')
|
||||
|
||||
takes_params = (
|
||||
Str('krbprincipalname', validate_principal,
|
||||
cli_name='principal',
|
||||
|
@ -47,6 +47,8 @@ class taskgroup(LDAPObject):
|
||||
# FIXME: taskgroup can be member of ???
|
||||
}
|
||||
|
||||
label = _('Task Groups')
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
cli_name='name',
|
||||
|
@ -68,6 +68,8 @@ class user(LDAPObject):
|
||||
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
|
||||
}
|
||||
|
||||
label = _('Users')
|
||||
|
||||
takes_params = (
|
||||
Str('uid',
|
||||
cli_name='login',
|
||||
|
@ -26,10 +26,25 @@ placeholders for the rest of the code.
|
||||
|
||||
|
||||
class LazyText(object):
|
||||
def __init__(self, domain, localedir):
|
||||
def __init__(self, domain=None, localedir=None):
|
||||
self.domain = domain
|
||||
self.localedir = localedir
|
||||
|
||||
def __mod__(self, kw):
|
||||
return self.__unicode__() % kw
|
||||
|
||||
|
||||
class FixMe(LazyText):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
super(FixMe, self).__init__()
|
||||
|
||||
def __repr__(self):
|
||||
return '%s(%r)' % (self.__class__.__name__, self.msg)
|
||||
|
||||
def __unicode__(self):
|
||||
return u'<%s>' % self.msg
|
||||
|
||||
|
||||
class Gettext(LazyText):
|
||||
def __init__(self, msg, domain, localedir):
|
||||
@ -39,8 +54,7 @@ class Gettext(LazyText):
|
||||
def __unicode__(self):
|
||||
return self.msg.decode('utf-8')
|
||||
|
||||
def __mod__(self, value):
|
||||
return self.__unicode__() % value
|
||||
|
||||
|
||||
|
||||
class NGettext(LazyText):
|
||||
|
@ -131,7 +131,7 @@ class Engine(object):
|
||||
)
|
||||
|
||||
def build_cruds_page(self, obj):
|
||||
page = self.app.new('PageGrid', title=obj.name, id=obj.name)
|
||||
page = self.app.new('PageGrid', title=obj.label, id=obj.name)
|
||||
|
||||
# Setup CRUDS widget:
|
||||
page.cruds.autoload = True
|
||||
|
@ -39,6 +39,25 @@ class test_LazyText(object):
|
||||
assert inst.localedir == 'bar'
|
||||
|
||||
|
||||
class test_FixMe(object):
|
||||
klass = text.FixMe
|
||||
|
||||
def test_init(self):
|
||||
inst = self.klass('user.label')
|
||||
assert inst.msg == 'user.label'
|
||||
assert inst.domain is None
|
||||
assert inst.localedir is None
|
||||
|
||||
def test_repr(self):
|
||||
inst = self.klass('user.label')
|
||||
assert repr(inst) == "FixMe('user.label')"
|
||||
|
||||
def test_unicode(self):
|
||||
inst = self.klass('user.label')
|
||||
assert unicode(inst) == u'<user.label>'
|
||||
assert type(unicode(inst)) is unicode
|
||||
|
||||
|
||||
class test_Gettext(object):
|
||||
|
||||
klass = text.Gettext
|
||||
|
Loading…
Reference in New Issue
Block a user