|
|
@ -21,6 +21,7 @@ from calculate.ldap.variables.helpers import (LdapSearchHelper, LdapMaxHelper)
|
|
|
|
from calculate.unix.variables.helpers import (UnixUserHelper, UnixGroupHelper,
|
|
|
|
from calculate.unix.variables.helpers import (UnixUserHelper, UnixGroupHelper,
|
|
|
|
UnixActionHelper)
|
|
|
|
UnixActionHelper)
|
|
|
|
from .action import Actions
|
|
|
|
from .action import Actions
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
_ = lambda x: x
|
|
|
|
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate)
|
|
|
|
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate)
|
|
|
@ -53,6 +54,8 @@ class VariableUrUnixGroupName(LdapSearchHelper, UnixActionHelper, Variable):
|
|
|
|
def check(self, value):
|
|
|
|
def check(self, value):
|
|
|
|
if not value:
|
|
|
|
if not value:
|
|
|
|
raise VariableError(_("You should specify group name"))
|
|
|
|
raise VariableError(_("You should specify group name"))
|
|
|
|
|
|
|
|
if not re.match("^[a-zA-Z_]([a-zA-Z0-9_ -]*[a-zA-Z0-9_-])?$", value):
|
|
|
|
|
|
|
|
raise VariableError(_("Wrong group name"))
|
|
|
|
if self.check_name(value):
|
|
|
|
if self.check_name(value):
|
|
|
|
raise VariableError(_("Group name already exists"))
|
|
|
|
raise VariableError(_("Group name already exists"))
|
|
|
|
|
|
|
|
|
|
|
@ -117,12 +120,16 @@ class VariableUrUnixGroupNameExists(UnixUserHelper, UnixGroupHelper, Variable):
|
|
|
|
raise VariableError(_("Choice group"))
|
|
|
|
raise VariableError(_("Choice group"))
|
|
|
|
raise VariableError(_("Group %s not found") % value)
|
|
|
|
raise VariableError(_("Group %s not found") % value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClUnixGroupCommentDefault(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Комментарий для новой группы по умолчанию
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
value_format = "{ldap.ld_base_root.capitalize()} group"
|
|
|
|
|
|
|
|
|
|
|
|
class VariableUrUnixGroupComment(UnixGroupHelper, UnixActionHelper, Variable):
|
|
|
|
class VariableUrUnixGroupComment(UnixGroupHelper, UnixActionHelper, Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Комментарий к группе
|
|
|
|
Комментарий к группе
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
value_format = "{ldap.ld_base_root.capitalize()} group"
|
|
|
|
|
|
|
|
opt = ('-c', '--comment')
|
|
|
|
opt = ('-c', '--comment')
|
|
|
|
metavalue = "COMMENT"
|
|
|
|
metavalue = "COMMENT"
|
|
|
|
|
|
|
|
|
|
|
@ -131,7 +138,7 @@ class VariableUrUnixGroupComment(UnixGroupHelper, UnixActionHelper, Variable):
|
|
|
|
self.help = _("set comment of the group")
|
|
|
|
self.help = _("set comment of the group")
|
|
|
|
|
|
|
|
|
|
|
|
def get_new(self):
|
|
|
|
def get_new(self):
|
|
|
|
return self._value_formatter.format(self.value_format, self.Get)
|
|
|
|
return self.Get('unix.cl_unix_group_comment_default')
|
|
|
|
|
|
|
|
|
|
|
|
def get_exists(self):
|
|
|
|
def get_exists(self):
|
|
|
|
return self.Get('ur_unix_group_comment_exists')
|
|
|
|
return self.Get('ur_unix_group_comment_exists')
|
|
|
@ -415,7 +422,7 @@ class VariableClUnixGroupAliases(ReadonlyVariable):
|
|
|
|
Алиасы для переменных
|
|
|
|
Алиасы для переменных
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
type = "table"
|
|
|
|
type = "table"
|
|
|
|
value = [#('name', 'ur_unix_group_name'),
|
|
|
|
value = [ # ('name', 'ur_unix_group_name'),
|
|
|
|
('id', 'ur_unix_group_id'),
|
|
|
|
('id', 'ur_unix_group_id'),
|
|
|
|
('comment', 'ur_unix_group_comment'),
|
|
|
|
('comment', 'ur_unix_group_comment'),
|
|
|
|
('users', 'ur_unix_group_users')]
|
|
|
|
('users', 'ur_unix_group_users')]
|
|
|
@ -468,11 +475,9 @@ class VariableUrUnixGroupShow(UnixGroupHelper,
|
|
|
|
self.help = _("show group")
|
|
|
|
self.help = _("show group")
|
|
|
|
|
|
|
|
|
|
|
|
def choice_exists(self):
|
|
|
|
def choice_exists(self):
|
|
|
|
return [("","")] + self.ldap_group_list()
|
|
|
|
return [("", "")] + self.ldap_group_list()
|
|
|
|
|
|
|
|
|
|
|
|
def check_exists(self, value):
|
|
|
|
def check_exists(self, value):
|
|
|
|
if value:
|
|
|
|
if value:
|
|
|
|
if not self.search_ldap_group_name(value):
|
|
|
|
if not self.search_ldap_group_name(value):
|
|
|
|
raise VariableError(_("%s group not found") % value)
|
|
|
|
raise VariableError(_("%s group not found") % value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|