def test_completer(self): completer = self._enumerator( ('x', ), data=(('Apple', ), ('Bananas', ), ('Basil', ), ('Bacardi', ), ('Cinamon', )), ) fields = ( pp.Field('a', type=pd.Integer(not_null=True)), pp.Field('x0', type=pd.String(enumerator=pd.FixedEnumerator(('a', 'b', 'c')))), pp.Field('x1', type=pd.String(), completer=('yes', 'no', 'maybe')), pp.Field('x2', type=pd.String(), completer=completer, runtime_filter=pp.computer(lambda r, a: pd.NE( 'x', pd.sval('Bacardi')) if a == 1 else None)), ) row = self._row(fields, new=True) assert not row.has_completer('a') assert row.has_completer('x0') assert row.has_completer('x1', static=True) assert row.has_completer('x2') assert not row.has_completer('x2', static=True) assert row.completions('a') == [] assert row.completions('x0') == ['a', 'b', 'c'] assert row.completions('x1') == ['maybe', 'no', 'yes'] assert row.completions('x1', prefix='y') == ['yes'] assert row.completions('x2') == ('Apple', 'Bananas', 'Basil', 'Bacardi', 'Cinamon') assert row.completions('x2', prefix='ba') == ('Bananas', 'Basil', 'Bacardi') row['a'] = 1 assert row.completions('x2', prefix='ba') == ('Bananas', 'Basil')
class SystemRoles(Roles): title = _("Systémové role") help = _("Systémové role jsou uživatelům přiřazeny automaticky.") layout = columns = ('name', 'system_role', 'description') condition = pd.NE('system_role', pd.Value(pd.String(), None)) bindings = () access_rights = pd.AccessRights((None, ('cms_admin', pd.Permission.ALL)), (None, ('cms_user', pd.Permission.VIEW)))
def _check_menu_order_condition(self, record): # Return a list of 'pd.Operator' instances to find menu items with duplicate order at the # same level. The returned operators will be applied in conjunction. Designed to allow # overriding in a derived class with more complicated menu structure. return [ pd.EQ('parent', record['parent']), pd.EQ('ord', record['ord']), pd.NE('menu_item_id', record['menu_item_id']) ]
def __init__(self): try: data = pytis.data.dbtable('ev_pytis_user_help', ('help_id', 'fullname', 'spec_name', 'page_id', 'position', 'title', 'description', 'menu_help', 'content',)) except pd.DBException: log(OPERATIONAL, "Not using DMP help: DMP help tables not found in database.") raise self.NotAvailable() count = data.select(condition=pd.NE('help_id', pd.sval('menu/'))) data.close() if count == 0: log(OPERATIONAL, "Not using DMP help: DMP help tables are empty.") raise self.NotAvailable() self._data = data self._cached_descriptions = {} super(DmpHelpGenerator, self).__init__()
def __init__(self, spec_name_prefix=None): """ Arguments: spec_name_prefix -- if not None then only specification with given prefix (basestring) are tested """ import pytis.output self._output_resolver = pytis.output.OutputResolver( pytis.config.print_spec_dir, pytis.config.resolver) data = pd.dbtable('e_pytis_roles', ('name', 'purposeid')) condition = pd.NE('purposeid', pd.Value(pd.String(), 'user')) self._application_roles = [ row[0].value() for row in data.select_map(identity, condition=condition) ] self._spec_name_prefix = spec_name_prefix
def _parent_filter(self, page_id): return pd.NE('page_id', pd.ival(None))
class FormProfiles(Specification): public = True table = 'ev_pytis_form_profiles' title = _("Profily formulářů") fields = ( Field('id', _("Identifier"), width=25, editable=Editable.NEVER), Field('title', _("Title"), width=25, editable=Editable.NEVER), Field('username', _("User"), not_null=True, codebook='statistics.FormUserList', value_column='login', editable=Editable.NEVER), Field('fullname', _("Fullname"), not_null=True, codebook='menu.ApplicationMenuM', width=80, column_width=30, editable=Editable.NEVER), Field('spec_name', _("Specification Name"), width=50, column_width=30, editable=Editable.NEVER), Field('form_name', _("Form Class"), width=50, column_width=30, editable=Editable.NEVER), Field('profile_id', _("Id profilu"), width=25, editable=Editable.NEVER), Field('pickled_filter', editable=Editable.NEVER), Field('pickled_params', editable=Editable.NEVER), Field('dump', _("Content"), width=80, height=8, editable=Editable.NEVER), Field('errors', _("Chyby"), width=80, height=8, editable=Editable.NEVER), Field('invalid', _("Neplatný"), type=pd.Boolean, virtual=True, width=1, computer=computer(lambda r, errors: errors is not None), editable=Editable.NEVER), ) cb = CodebookSpec(display='title') columns = ('title', 'profile_id', 'username', 'spec_name', 'form_name', 'invalid') layout = HGroup(('title', 'profile_id', 'username'), ('spec_name', 'form_name', 'dump', 'errors')) profiles = ( Profile('invalid-profiles', _("Neplatné profily"), filter=pd.NE('errors', pd.sval(None))), Profile('user-profiles', _("Uživatelské profily"), filter=pd.WM('profile_id', pd.WMValue(pd.String(), '_user_profile_*'))), Profile('system-profiles', _("Systémové profily"), filter=pd.NW('profile_id', pd.WMValue(pd.String(), '_user_profile_*'))), )
def _new_uid_filter(self, row, name): assigned_users = wiking.module(self._resolver).assigned_users( row['name']) return pd.AND(*[pd.NE('uid', u) for u in assigned_users])