def fields(self): return ( Field('old_password', _(u'Stávající heslo'), width=20, type=pytis.data.Password, md5=False, verify=False), Field('new_password', _(u'Nové heslo'), width=20, type=pytis.data.Password, maxlen=32, minlen=8, md5=False, strength=self._check_strength), )
def fields(self): return (Field('action_id', default=nextval('cms_actions_action_id_seq')), Field('mod_id', _("Modul"), not_null=True, codebook=self._spec_name('Modules', False)), Field('name', _("Title"), width=16), Field('description', _("Description"), width=64))
def fields(self): return ( Field('role_id', default=nextval('cms_roles_role_id_seq')), Field('name', _("Title"), width=16), Field('system_role', _("Systémová role"), width=16, type=pd.String(not_null=True)), Field('description', _("Description"), width=64), )
def fields(self): return ( Field('mod_id', default=nextval('cms_modules_mod_id_seq')), Field('modname', _("Title"), width=32), Field('descr', _("Description"), width=64, virtual=True, editable=NEVER, computer=computer(self._descr)), )
def fields(self): return (Field('ip_address', _("IP adresa"), width=12, editable=NEVER), Field('hostname', _("Hostname"), virtual=True, editable=NEVER, computer=computer(self._hostname), column_width=15, width=40), Field('user_agent', _("User agent"), column_width=25, width=80), Field('referer', _("Referer"), column_width=25, width=80))
def fields(self): return ( Field('uid', _("UID"), width=5, default=nextval('cms_users_uid_seq')), Field('login', _("Přihlašovací jméno"), width=16), Field('fullname', _("Celé jméno"), width=40), Field('passwd', _("Heslo"), type=pd.Password(not_null=True, minlen=4, md5=True)), )
def run_any_form(): form_types = ( ("BrowseForm", pytis.form.BrowseForm), ("PopupEditForm", pytis.form.PopupEditForm), ("PopupInsertForm", pytis.form.PopupInsertForm), ("BrowseDualForm", pytis.form.BrowseDualForm), ("MultiBrowseDualForm", pytis.form.MultiBrowseDualForm), ("CodebookForm", pytis.form.CodebookForm), ) resolver = config.resolver all_defs = [] for d in pytis.extensions.get_form_defs(resolver): all_defs.append(specification_path(d)[1]) all_defs.sort() def name_runtime_filter(row): name_substr = row['name_substr'].value() if name_substr: return lambda val: val.lower().find(name_substr.lower()) != -1 else: return None row = pytis.form.run_form( pytis.form.InputForm, title=_("Run Form"), fields=( Field('type', _("Form type"), not_null=True, enumerator=pytis.data.FixedEnumerator( [x[0] for x in form_types]), default='BrowseForm'), Field( 'name_substr', _("Search string"), width=40, ), Field('name', _("Specification name"), width=40, height=10, enumerator=pytis.data.FixedEnumerator(all_defs), not_null=True, selection_type=SelectionType.LISTBOX, runtime_filter=Computer(name_runtime_filter, depends=('name_substr', ))), )) if row is not None: form_type = dict(form_types)[row['type'].value()] pytis.form.run_form(form_type, row['name'].value())
def fields(self): return ( Field('log_id'), Field('session_id'), Field('uid', not_null=True, codebook=self._spec_name('Users')), Field('login', _("Login"), width=8), Field('fullname', _("Jméno"), width=15), Field('success', _("Úspěch"), width=3), Field('start_time', _("Začátek"), width=17), Field('duration', _("Trvání"), width=17), Field('active', _("Active")), ) + super(SessionLog, self).fields()
def fields(self): return ( Field("id", _("ID"), width=10, type=pd.Integer), Field("timestamp", _("Datum a čas"), width=17, type=pd.DateTime), Field("username", _("User"), width=20, type=pd.String), Field("schemaname", _("Schema"), width=20, type=pd.String), Field("tablename", _("Tabulka"), width=20, type=pd.String), Field("operation", _("Operace"), width=10, type=pd.String), Field("key_column", _("ID klíč"), width=20, type=pd.String), Field("key_value", _("Klíč"), width=20, type=pd.String), Field("detail", _("Řádek"), width=40, height=20, type=pd.String), )
class RandomNumbers(Specification): """Demonstration of query fields and argument provider.""" public = True title = _("Random numbers controlled by query fields") table = dbdefs.RandomNumbers query_fields = QueryFields( (Field('count', _("Row Count"), type=pytis.data.Integer(not_null=True), default=10), Field('minimum', _("Min"), type=pytis.data.Integer(not_null=True), default=0), Field('maximum', _("Max"), type=pytis.data.Integer(not_null=True), default=100, check=lambda r, minimum, maximum: (_("Max must be greater than Min!") if maximum < minimum else None))), autoinit=True, ) def argument_provider(self, query_fields, **kwargs): return dict([(k, query_fields[k]) for k in ('count', 'minimum', 'maximum')])
class ObsoleteTree(Specification): """Demonstration of a foldable form.""" public = True title = _("Tree") table = dbdefs.Tree fields = ( Field('id', _("ID")), Field('tid', _("Tree ID")), Field('name', _("Name"), type=_TreeOrder(tree_column_id='tid')), Field('amount', _("Amount"), fixed=True), Field('description', _("Description")), ) layout = ('id', 'name', 'amount', 'description',) columns = ('name', 'amount', 'description',) sorting = (('id', pd.ASCENDENT,),) aggregations = (pd.Data.AGG_SUM,)
def _customize_fields(self, fields): fields.modify_many(( 'id', 'id3', 'num', 'continent', ), column_width=6) fields.modify_many(( 'id', 'id3', 'num', ), fixed=True) fields.modify_many(( 'id', 'id3', ), filter=TextFilter.ALPHANUMERIC, post_process=PostProcess.UPPER) fields.append( Field('cname', _("Continent name"), editable=Editable.NEVER, computer=CbComputer('continent', 'name'), virtual=True, type=pd.String())) fields.set_property('width', id=2, num=3, continent=2, name=30, fullname=40, cname=20)
def set_default_printer(): from pytis.presentation import Field from pytis.form import Error, Text, InputForm, run_dialog, run_form try: import cups import cupshelpers except ImportError: run_dialog( Error, _("Default printer setup failed.\n" "CUPS Python interface not present.\n" "Please, contact the system administrator.")) return None connection = cups.Connection() user_default = UserDefaultPrinter() default_printer = user_default.get() if not default_printer: default_printer = connection.getDefault() printers = cupshelpers.getPrinters(connection) result = run_form( InputForm, title=_("Printer Selection"), fields=(Field('printer', "", width=40, not_null=True, type=pytis.data.String, enumerator=pytis.data.FixedEnumerator( list(printers.keys())), default=default_printer), ), layout=(Text(_("Choose the default printer:")), 'printer'), ) if result: user_default.set(result['printer'].value()) return None
def fields(self): return ( Field('lang_id', default=nextval('cms_languages_lang_id_seq')), Field('lang', _("Kód"), width=2, column_width=6, fixed=True, filter=pp.TextFilter.ALPHANUMERIC, post_process=pp.PostProcess.LOWER), Field('name', _("Title"), virtual=True, editable=NEVER, computer=computer( lambda record, lang: self._language_name(lang))), )
class FormUserList(Specification): public = True table = 'ev_pytis_form_user_list' title = _(u"Uživatelé") fields = ( Field('login', _(u"Login")), ) bindings = (Binding('users', _(u"Formuláře"), 'statistics.FormUserStatistics', condition=(lambda row: pytis.data.EQ('login', row['login']))), Binding('profiles', _("Profiles"), 'profiles.FormProfiles', 'username'), )
def fields(self): return ( Field('item_id'), Field('kind'), Field('spec_name', not_null=True, codebook='help.Help', value_column='spec_name'), Field('identifier', _("Identifier"), width=30, editable=Editable.NEVER), Field('content', _("Description"), width=80, height=15, compact=True, text_format=pp.TextFormat.LCG, attachment_storage=self._attachment_storage), Field('label', _("Title"), width=30, virtual=True, editable=pp.Editable.NEVER, computer=computer(self._label)), Field('removed', _("Removed"), editable=Editable.NEVER), Field('changed', _("Changed"), editable=Editable.NEVER, computer=computer(lambda r, content: True)), )
class FormSettings(Specification): public = True table = 'e_pytis_form_settings' title = _("Nastavení formulářů") fields = ( Field('id', _("Identifier"), width=20, editable=Editable.NEVER), Field('username', _("User"), not_null=True, codebook='statistics.FormUserList', value_column='login', editable=Editable.NEVER), Field('spec_name', _("Specification Name"), width=50, editable=Editable.NEVER), Field('form_name', _("Typ formuláře"), width=50, editable=Editable.NEVER), Field('pickle', editable=Editable.NEVER), Field('dump', _("Content"), width=40, height=5, editable=Editable.NEVER), ) columns = ('username', 'spec_name', 'form_name') layout = HGroup(('username', 'spec_name', 'form_name'), ('dump'))
def _create_view_spec(self): def descr(name): option = config.option(name) descr = option.description() doc = option.documentation() if doc: descr += "\n" + doc return descr fields = [Field(option, _LABELS.get(option, option), descr=descr(option), **_FIELDSPEC_KWARGS.get(option, {})) for option in self._layout().order()] return ViewSpec(_("User interface settings"), fields, layout=self._layout(), **self._spec_kwargs)
def fields(self): return ( Field('filter', _("Country name filter"), default='*', descr=_("Enter a wildcard expression to filter only matching countries in the " "codebook field below.")), Field('switch', _("Show only european countries"), editable=Editable.ALWAYS, type=pd.Boolean(), default=True, descr=_("Check/uncheck this checkbox to enable/disable non-european " "countries in the codebook field below.")), Field('country', _("Country"), width=2, type=pd.String, not_null=True, maxlen=2, codebook='cb.Countries', runtime_filter=computer(self._country_filter), descr=_("Lists countries filtered by the above two fields.")), Field('group', _("Group"), enumerator=self._SystemGroups(), not_null=True, descr=_("Lists system user groups.")), Field('user', _("User"), enumerator=self._SystemGroupMembers(), not_null=True, runtime_arguments=computer(lambda record, group: dict(group=group)), descr=_("Lists users of the above selected group.")), )
def fields(self): return ( Field('menu_id'), Field('menu_item_id'), Field('tree_order'), Field('lang'), Field('title_or_identifier', _("Title"), width=32, type=_TreeOrder), Field('identifier', _("Identifier"), width=20), Field('modname', _("Modul")), #Field('description', _("Description"), width=64), )
def init(self): if not app.question(_("Really print?")): return None result = pytis.form.run_form(pytis.form.InputForm, title=_("Document title"), fields=(Field('title', _("Title"), not_null=True), )) if result: self._add_parameter('title', result['title'].value()) data_countries_spec = pytis.config.resolver.get( 'cb.Countries', 'data_spec') self._data = data_countries_spec.create( dbconnection_spec=pytis.config.dbconnection) return True
def _customize_fields(self, fields): fields.modify('name', editable=pytis.presentation.Computer( self._editable, depends=())) fields.modify('username', editable=pytis.presentation.Computer( self._editable, depends=('name',))) fields.append( Field('admin_password', _(u"Heslo přihlášeného uživatele"), width=24, virtual=True, type=pytis.data.Password(not_null=True, verify=False), editable=pytis.presentation.Computer(self._editable, depends=('name',)) )) fields.append( Field('admin_address', _(u"E-mailová adresa administrátora"), width=24, virtual=True, type=pytis.data.String(not_null=True), editable=pytis.presentation.Computer(self._editable, depends=('name',)), )) fields.append( Field('user_password', _(u"Nové heslo pro uživatele"), virtual=True, type=pytis.data.String(), editable=pytis.presentation.Editable.NEVER ))
def fields(self): return ( Field('key_id', _("Id"), editable=Editable.NEVER), Field('name', _("Name"), not_null=True, codebook='CryptoNames', editable=Editable.NEVER), Field('uid', _("User"), not_null=True, codebook='Users', selection_type=SelectionType.CHOICE, editable=Editable.ONCE), Field('new_uid', _("New user"), not_null=True, codebook='Users', selection_type=SelectionType.CHOICE, type=pd.Integer, virtual=True, runtime_filter=computer(self._new_uid_filter)), Field('key', _("Key")), Field('remove', _("Action"), virtual=True, computer=computer(lambda r: _("Remove"))), Field('old_password', _("Current password"), type=pd.Password, verify=False, virtual=True), Field('new_password', _("New password"), type=pd.Password, virtual=True), Field('delete', virtual=True, computer=computer(lambda row: _("Remove"))), )
def fields(self): return (Field( 'user_role_id', default=nextval('cms_user_role_assignment_user_role_id_seq')), Field('role_id', _("Role"), not_null=True, codebook=self._spec_name('Roles', False)), Field('system_role'), Field('uid', _('UID'), not_null=True, codebook=self._spec_name('Users', False), width=5), Field('login', _("Přihlašovací jméno"), width=16), Field('fullname', _("Celé jméno"), width=50), Field('name', _("Název role"), width=16), Field('description', _("Description"), width=50))
def _customize_fields(self, fields): fields.append(Field('price2', _("Price with VAT"), virtual=True, type=pd.Float(precision=2), computer=computer(lambda r, price: price and price * 1.21))) fields.set_property('width', product_id=3, product=30, count=12, price=12, price2=12, notes=50) fields.modify('product_id', column_width=6, fixed=True) fields.modify('product', style=lambda r: (pp.Style(overstrike=True) if r['count'].value() == 0 else None)) fields.modify('count', style=lambda r: (pp.Style(foreground='#f00') if r['count'].value() <= 5 else None)) fields.modify('price', type=pd.Monetary(not_null=True)) fields.modify('since', descr=_("Date when the product was first included.")) fields.modify('notes', descr=_("Arbitrary internal notes about given product."), height=3, text_format=pp.TextFormat.LCG)
def fields(self): return ( Field('log_id'), Field('timestamp', _("Datum a čas"), width=17), Field('uri', _("Cesta"), width=17), Field('uid', _("User"), not_null=True, codebook=self._spec_name('Users')), Field('modname', _("Modul"), width=17), Field('action', _("Action"), width=17), ) + super(AccessLog, self).fields()
class FormUserStatistics(Specification): public = True table = 'ev_pytis_form_users' title = _(u"Formuláře uživatele") fields = ( Field('login', _(u"Login")), Field('form', _(u"Jméno formuláře")), Field('class', _("Form Class")), Field('info', _(u"Parametry formuláře")), Field('n_open', _(u"Počet otevření")), Field('last_used', _(u"Poslední spuštění")), ) columns = ('form', 'class', 'info', 'n_open', 'last_used',)
def fields(self): return ( Field('rights_assignment_id', default=nextval( 'cms_rights_assignment_rights_assignment_id_seq')), Field('menu_item_id'), Field('role_id', _("Role"), not_null=True, codebook=self._spec_name('AllRoles', False)), Field('role_name', _("Role")), Field('system_role'), Field('mod_id'), Field('action_id', _("Action"), codebook=self._spec_name('Actions', False), not_null=True, runtime_filter=computer(self._action_filter)), Field('action_name', _("Action Name")), Field('action_description', _("Description"), width=30, editable=NEVER), )
class FormStatistics(Specification): public = True table = 'ev_pytis_form_summary' title = _(u"Podrobný přehled používaných formulářů") fields = ( Field('form', _(u"Jméno formuláře")), Field('class', _("Form Class")), Field('info', _(u"Parametry formuláře")), Field('n_users', _(u"Počet uživatelů")), Field('n_open', _(u"Počet otevření")), Field('avg_start', _(u"Průměrná doba startu")), Field('last_used', _(u"Poslední spuštění")), ) bindings = (Binding('users', _(u"Uživatelé"), 'statistics.FormUsers', condition=(lambda row: pytis.data.AND(pytis.data.EQ('form', row['form']), pytis.data.EQ('class', row['class']), pytis.data.EQ('info', row['info'])))), )
def arguments(self): return (Field('date_from', _("From"), type=pd.Date, not_null=True, default=lambda: pd.Date.now().value()), Field('date_to', _("To"), type=pd.Date, not_null=True, default=lambda: pd.Date.now().value()), Field('username_', _("User"), type=pd.String), Field('tablename_', _("Tabulka"), type=pd.String), Field('key_value_', _("Klíč"), type=pd.String), Field('detail_', _("Řádek obsahuje"), type=pd.String), Field('search_path_', _("Schema"), type=pd.String, not_null=True, default=self._df_search_path_))