class EPytisHelpPagesAttachments(Base_LogSQLTable): """Attachments for help texts (images etc.)""" name = 'e_pytis_help_pages_attachments' fields = ( sql.PrimaryColumn('file_id', pytis.data.Serial()), sql.Column('page_id', pytis.data.Integer(not_null=True), references=sql.a(sql.r.EPytisHelpPages.page_id, ondelete='CASCADE')), sql.Column('file_name', pytis.data.String(not_null=True)), sql.Column('byte_size', pytis.data.Integer(not_null=True)), sql.Column('width', pytis.data.Integer(not_null=False)), sql.Column('height', pytis.data.Integer(not_null=False)), sql.Column('resized_width', pytis.data.Integer(not_null=False)), sql.Column('resized_height', pytis.data.Integer(not_null=False)), sql.Column('thumbnail_width', pytis.data.Integer(not_null=False)), sql.Column('thumbnail_height', pytis.data.Integer(not_null=False)), sql.Column('file', pytis.data.Binary(not_null=True)), sql.Column('resized', pytis.data.Binary(not_null=False)), sql.Column('thumbnail', pytis.data.Binary(not_null=False)), ) inherits = (XChanges, ) unique = (( 'page_id', 'file_name', ), ) depends_on = (EPytisHelpPages, ) access_rights = default_access_rights.value(globals())
class EPytisHelpSpecItems(Base_LogSQLTable): """Help texts for specification items, such as fields, bindings, actions.""" name = 'e_pytis_help_spec_items' fields = ( sql.PrimaryColumn('item_id', pytis.data.Serial()), sql.Column('spec_name', pytis.data.String(not_null=True), references=sql.a(sql.r.EPytisHelpSpec.spec_name, onupdate='CASCADE', ondelete='CASCADE')), sql.Column( 'kind', pytis.data.String(not_null=True), check="kind in ('field', 'profile', 'binding', 'action', 'proc')"), sql.Column('identifier', pytis.data.String(not_null=True)), sql.Column('content', pytis.data.String(not_null=False)), sql.Column('changed', pytis.data.Boolean(not_null=True), doc="True when the content was edited by hand.", default=False), sql.Column('removed', pytis.data.Boolean(not_null=True), doc="False when the item still exists in specification.", default=False), ) inherits = (XChanges, ) unique = (( 'spec_name', 'kind', 'identifier', ), ) depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisUserHelp(sql.SQLView): """Help menu structure limited to the current user according to DMP rights.""" name = 'ev_pytis_user_help' @classmethod def query(cls): def select_1(): h = sql.t.EvPytisHelp.alias('h') u = sqlalchemy.select(["*"], from_obj=["pytis_view_user_menu()"]).alias('u') return sqlalchemy.select( sql.reorder_columns(cls._exclude(h), ['help_id', 'menuid', 'fullname', 'title', 'description', 'menu_help', 'spec_name', 'spec_description', 'spec_help', 'page_id', 'parent', 'ord', 'content', 'position', 'position_nsub', 'changed', 'removed']), from_obj=[h.join(u, sql.gR('h.menuid = u.menuid'))] ) def select_2(): h = sql.t.EvPytisHelp.alias('h') return sqlalchemy.select( sql.reorder_columns(cls._exclude(h), ['help_id', 'menuid', 'fullname', 'title', 'description', 'menu_help', 'spec_name', 'spec_description', 'spec_help', 'page_id', 'parent', 'ord', 'content', 'position', 'position_nsub', 'changed', 'removed']), from_obj=[h], whereclause='h.menuid is null' ) return sqlalchemy.union(select_1(), select_2()) depends_on = (EvPytisHelp, PytisViewUserMenu,) access_rights = default_access_rights.value(globals())
class EPytisFormLog(sql.SQLTable): """ Statistics about using forms by users and form opening performance. form is fully qualified specification name. class is pytis class name of the form instance. login is login name of the user who has opened the form. info is optional extra information provided by the form (e.g. sorting used). t_start is the time when user invoked the form opening command. t_show is the time when the form got actually ready for operation after its start. """ name = 'e_pytis_form_log' schemas = pytis_schemas.value(globals()) fields = ( sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('form', pytis.data.String(not_null=True), index=True), sql.Column('class', pytis.data.String(not_null=True), index=True), sql.Column('info', pytis.data.String(not_null=False), index=True), sql.Column('login', pytis.data.Name(not_null=True), index=True), sql.Column('t_start', pytis.data.DateTime(not_null=True, without_timezone=True), index=True), sql.Column('t_show', pytis.data.DateTime(not_null=True, without_timezone=True)), ) inherits = (XChanges, ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class VUpdatesUser(sql.SQLView): """Tabulka zaznamenávající změny v záznamech standardních tabulek.""" name = 'v_updates_user' @classmethod def query(cls): _updates = sql.t.XUpdates return sqlalchemy.select( [ sql.gL("zmeneno::date").label('datum'), sql.gL("zmeneno::time").label('cas'), _updates.c.id.label('id'), _updates.c.zmenil.label('zmenil'), _updates.c.zmeneno.label('zmeneno'), _updates.c.tabulka.label('tabulka'), _updates.c.klic.label('klic'), _updates.c.zmeny.label('zmeny') ], from_obj=[_updates], whereclause=_updates.c.zmenil == sqlalchemy.text('current_user'), ) depends_on = (XUpdates, ) access_rights = default_access_rights.value(globals())
class EPytisCryptoKeys(Base_LogSQLTable): """Table of encryption keys of users for defined encryption areas.""" name = 'e_pytis_crypto_keys' schemas = pytis_schemas.value(globals()) fields = ( sql.PrimaryColumn('key_id', pytis.data.Serial()), sql.Column('name', pytis.data.String(not_null=True), label=_("Šifrovací oblast"), references=sql.a(sql.r.CPytisCryptoNames.name, onupdate='CASCADE')), sql.Column('username', pytis.data.String(not_null=True), label=_("Uživatel"), doc="Arbitrary user identifier."), sql.Column('key', pytis.data.Binary(not_null=True)), sql.Column( 'fresh', pytis.data.Boolean(not_null=True), label=_("Nový"), doc= "Flag indicating the key is encrypted by a non-login password. ", default=False), ) inherits = (XChanges, ) unique = (( 'name', 'username', ), ) depends_on = (CPytisCryptoNames, ) access_rights = default_access_rights.value(globals())
class TChangesDetail(sql.SQLTable): """Detail information about database changes.""" name = 't_changes_detail' schemas = (('public',),) fields = (sql.Column('id', pytis.data.Integer(not_null=True), index=True, references=sql.a(sql.r.TChanges.id, onupdate='CASCADE', ondelete='CASCADE')), sql.Column('detail', pytis.data.String(not_null=True)), ) with_oids = True depends_on = (TChanges,) access_rights = default_access_rights.value(globals())
class Log(sql.SQLTable): """Tabulka pro logování provedených DML příkazů.""" name = 'log' fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('command', pytis.data.String(not_null=True)), sql.Column('login', pytis.data.Name(not_null=True), default=sqlalchemy.text('user')), sql.Column('timestamp', pytis.data.DateTime(not_null=True), default=sqlalchemy.text('now()')), ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisUserCryptoKeys(sql.SQLView): name = 'ev_pytis_user_crypto_keys' @classmethod def query(cls): keys = sql.t.EPytisCryptoKeys.alias('keys') return sqlalchemy.select(cls._exclude(keys, 'username', 'key'), from_obj=[keys], whereclause='username=current_user') depends_on = (EPytisCryptoKeys, ) access_rights = default_access_rights.value(globals())
class EPytisConfig(sql.SQLTable): """Pytis application configuration storage.""" name = 'e_pytis_config' schemas = pytis_schemas.value(globals()) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('option', pytis.data.String(not_null=True)), sql.Column('value', pytis.data.String(not_null=True)), ) inherits = (XChanges,) unique = (('username', 'option',),) depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisFormUserList(sql.SQLView): name = 'ev_pytis_form_user_list' schemas = pytis_schemas.value(globals()) @classmethod def query(cls): log = sql.t.EPytisFormLog.alias('log') return sqlalchemy.select(cls._exclude(log, 'id', 'form', 'class', 'info', 't_start', 't_show'), from_obj=[log]).group_by('login') depends_on = (EPytisFormLog, ) access_rights = default_access_rights.value(globals())
class XChangesStatistic(sql.SQLTable): """Tabulka pro statistiky změn v tabulkách.""" name = '_changes_statistic' fields = (sql.PrimaryColumn('id', pytis.data.Serial(), doc="identifikace řádku"), sql.Column('uzivatel', pytis.data.Name(not_null=True), default=sqlalchemy.text('user')), sql.Column('datum', pytis.data.Date(not_null=False)), sql.Column('inserts', pytis.data.Integer(not_null=False)), sql.Column('updates', pytis.data.Integer(not_null=False)), sql.Column('deletes', pytis.data.Integer(not_null=False)), ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class CTypFormular(Base_LogSQLTable): """Slouží jako číselník typů formulářů""" name = 'c_typ_formular' fields = (sql.PrimaryColumn('id', pytis.data.String(maxlen=2, not_null=False)), sql.Column('popis', pytis.data.String(not_null=False)), ) inherits = (XChanges,) init_columns = ('id', 'popis') init_values = (('BF', 'Jednoduchý náhled',), ('DF', 'Duální náhled',), ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisFormProfiles(sql.SQLView): """Pytis profiles.""" name = 'ev_pytis_form_profiles' schemas = pytis_schemas.value(globals()) @classmethod def query(cls): profile = sql.t.EPytisFormProfileBase.alias('profile') params = sql.t.EPytisFormProfileParams.alias('params') return sqlalchemy.select( cls._exclude(profile, 'id', 'username', 'spec_name', 'profile_id', 'pickle', 'dump', 'errors') + cls._exclude(params, 'id', 'pickle', 'dump', 'errors') + [ sql.gL("profile.id||'.'||params.id").label('id'), sql. gL("'form/'|| params.form_name ||'/'|| profile.spec_name ||'//'" ).label('fullname'), sql.gL( "case when profile.errors is not null and params.errors is not null " "then profile.errors ||'\n'||params.errors " "else coalesce(profile.errors, params.errors) end").label( 'errors'), sql.gL( "case when profile.dump is not null and params.dump is not null " "then profile.dump ||'\n'||params.dump " "else coalesce(profile.dump, params.dump) end").label( 'dump'), profile.c.pickle.label('pickled_filter'), params.c.pickle.label('pickled_params') ], from_obj=[ profile.join( params, sql.gR('profile.username = params.username and ' 'profile.spec_name = params.spec_name and ' 'profile.profile_id = params.profile_id')) ]) def on_delete(self): return ( "(delete from e_pytis_form_profile_base where id = split_part(old.id, '.', 1)::int;" "delete from e_pytis_form_profile_params where id = split_part(old.id, '.', 2)::int" ";)", ) depends_on = ( EPytisFormProfileBase, EPytisFormProfileParams, ) access_rights = default_access_rights.value(globals())
class EPytisFormSettings(sql.SQLTable): """Storage of pytis profile independent form settings.""" name = 'e_pytis_form_settings' schemas = pytis_schemas.value(globals()) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('spec_name', pytis.data.String(not_null=True)), sql.Column('form_name', pytis.data.String(not_null=True)), sql.Column('pickle', pytis.data.String(not_null=True)), sql.Column('dump', pytis.data.String(not_null=False)), ) inherits = (XChanges,) unique = (('username', 'spec_name', 'form_name',),) depends_on = () access_rights = default_access_rights.value(globals())
class CPytisCryptoNames(Base_LogSQLTable): """Codebook of encryption areas defined in the application.""" name = 'c_pytis_crypto_names' schemas = pytis_schemas.value(globals()) fields = ( sql.PrimaryColumn('name', pytis.data.String(not_null=False), label=_("Šifrovací oblast")), sql.Column('description', pytis.data.String(not_null=False), label=_("Popis")), ) inherits = (XChanges, ) depends_on = () access_rights = default_access_rights.value(globals())
class EPytisHelpSpec(Base_LogSQLTable): """Help texts for specifications.""" name = 'e_pytis_help_spec' fields = (sql.PrimaryColumn('spec_name', pytis.data.String(not_null=False)), sql.Column('description', pytis.data.String(not_null=False)), sql.Column('help', pytis.data.String(not_null=False)), sql.Column('changed', pytis.data.Boolean(not_null=True), doc="True when the content was edited by hand.", default=False), sql.Column('removed', pytis.data.Boolean(not_null=True), doc="False when the specification still exists.", default=False), ) inherits = (XChanges,) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class EPytisAggregatedViews(sql.SQLTable): """Pytis aggregated views storage.""" name = 'e_pytis_aggregated_views' schemas = pytis_schemas.value(globals()) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('spec_name', pytis.data.String(not_null=True)), sql.Column('aggregated_view_id', pytis.data.String(not_null=True)), sql.Column('title', pytis.data.String(not_null=True)), sql.Column('pickle', pytis.data.String(not_null=True)), ) inherits = (XChanges,) unique = (('username', 'spec_name', 'aggregated_view_id',),) depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisGlobalOutputTemplates(sql.SQLView): name = 'ev_pytis_global_output_templates' @classmethod def query(cls): templates = sql.t.EPytisOutputTemplates.alias('templates') return sqlalchemy.select(cls._exclude(templates), from_obj=[templates], whereclause='username is null') insert_order = (EPytisOutputTemplates, ) update_order = (EPytisOutputTemplates, ) delete_order = (EPytisOutputTemplates, ) depends_on = (EPytisOutputTemplates, ) access_rights = default_access_rights.value(globals())
class EPytisActionLog(sql.SQLTable): """Pytis user actions log.""" name = 'e_pytis_action_log' schemas = pytis_schemas.value(globals()) fields = ( sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('timestamp', pytis.data.DateTime(not_null=True)), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('spec_name', pytis.data.String(not_null=True)), sql.Column('form_name', pytis.data.String(not_null=True)), sql.Column('action', pytis.data.String(not_null=True)), sql.Column('info', pytis.data.String(not_null=False)), ) inherits = (XChanges, ) depends_on = () access_rights = default_access_rights.value(globals())
class EPytisHelpPages(Base_LogSQLTable): """Structure of static help pages.""" name = 'e_pytis_help_pages' fields = (sql.PrimaryColumn('page_id', pytis.data.Serial()), sql.Column('parent', pytis.data.Integer(not_null=False), references=sql.r.EPytisHelpPages.page_id), sql.Column('ord', pytis.data.Integer(not_null=True)), sql.Column('position', pytis.data.LTree(not_null=True), unique=True), sql.Column('title', pytis.data.String(not_null=True)), sql.Column('description', pytis.data.String(not_null=False)), sql.Column('content', pytis.data.String(not_null=False)), ) inherits = (XChanges,) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class EvPytisFormUsers(sql.SQLView): name = 'ev_pytis_form_users' schemas = pytis_schemas.value(globals()) @classmethod def query(cls): log = sql.t.EPytisFormLog.alias('log') return sqlalchemy.select( cls._exclude(log, 'id', 't_start', 't_show') + [ sql.gL("count(t_start)").label('n_open'), sql.gL("max(t_start)").label('last_used') ], from_obj=[log]).group_by('form', 'class', 'info', 'login') depends_on = (EPytisFormLog, ) access_rights = default_access_rights.value(globals())
class EPytisHelpMenu(Base_LogSQLTable): """Texts for help pages.""" name = 'e_pytis_help_menu' fields = (sql.PrimaryColumn('fullname', pytis.data.String(not_null=False), references=sql.a(sql.r.CPytisMenuActions.fullname, onupdate='CASCADE', ondelete='CASCADE')), sql.Column('content', pytis.data.String(not_null=False)), sql.Column('changed', pytis.data.Boolean(not_null=True), doc="True when the content was edited by hand.", default=False), sql.Column('removed', pytis.data.Boolean(not_null=True), doc="False when the item still exists in menu.", default=False), ) inherits = (XChanges,) with_oids = True depends_on = (EPytisMenu,) access_rights = default_access_rights.value(globals())
class XChanges(sql.SQLTable): """Sloupečky zaznamenávající uživatele a časy vytvoření a změn údajů. Je určena k tomu, aby ji dědily všechny ostatní tabulky.""" name = '_changes' fields = (sql.Column('vytvoril', pytis.data.Name(not_null=True), default=sqlalchemy.text('user')), sql.Column('vytvoreno', pytis.data.DateTime(not_null=True), default=sqlalchemy.text('now()')), sql.Column('zmenil', pytis.data.Name(not_null=True), default=sqlalchemy.text('user')), sql.Column('zmeneno', pytis.data.DateTime(not_null=True), default=sqlalchemy.text('now()')), ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class EPytisFormProfileParams(sql.SQLTable): """Pytis form profile form type specific parameters.""" name = 'e_pytis_form_profile_params' schemas = pytis_schemas.value(globals()) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('spec_name', pytis.data.String(not_null=True)), sql.Column('form_name', pytis.data.String(not_null=True)), sql.Column('profile_id', pytis.data.String(not_null=True)), sql.Column('pickle', pytis.data.String(not_null=True)), sql.Column('dump', pytis.data.String(not_null=False)), sql.Column('errors', pytis.data.String(not_null=False)), ) inherits = (XChanges,) unique = (('username', 'spec_name', 'form_name', 'profile_id',),) depends_on = () access_rights = default_access_rights.value(globals())
class EPytisFormProfileBase(sql.SQLTable): """Pytis form configuration storage.""" name = 'e_pytis_form_profile_base' schemas = pytis_schemas.value(globals()) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('username', pytis.data.Name(not_null=True)), sql.Column('spec_name', pytis.data.String(not_null=True)), sql.Column('profile_id', pytis.data.String(not_null=True)), sql.Column('title', pytis.data.String(not_null=True)), sql.Column('pickle', pytis.data.String(not_null=True)), sql.Column('dump', pytis.data.String(not_null=False)), sql.Column('errors', pytis.data.String(not_null=False)), ) inherits = (XChanges,) unique = (('username', 'spec_name', 'profile_id',),) depends_on = () access_rights = default_access_rights.value(globals())
class TChanges(sql.SQLTable): """Log of data changes.""" name = 't_changes' schemas = (('public',),) fields = (sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('timestamp', pytis.data.DateTime(not_null=True), index=True), sql.Column('username', pytis.data.String(not_null=True), index=True), sql.Column('schemaname', pytis.data.String(not_null=True)), sql.Column('tablename', pytis.data.String(not_null=True), index=True), sql.Column('operation', pytis.data.String(not_null=True), doc="One of: INSERT, UPDATE, DELETE"), sql.Column('key_column', pytis.data.String(not_null=True)), sql.Column('key_value', pytis.data.String(not_null=True), index=True), ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())
class PytisLogForm(sql.SQLFunction): schemas = pytis_schemas.value(globals()) name = 'pytis_log_form' arguments = ( sql.Column('', pytis.data.String()), sql.Column('', pytis.data.String()), sql.Column('', pytis.data.String()), sql.Column('', pytis.data.DateTime(without_timezone=True)), sql.Column('', pytis.data.DateTime(without_timezone=True)), ) result_type = pytis.data.Integer() multirow = False stability = 'VOLATILE' depends_on = (EPytisFormLog, ) access_rights = default_access_rights.value(globals()) def body(self): return """
class VChanges(sql.SQLView): name = 'v_changes' schemas = (('public',),) @classmethod def query(cls): changes = sql.t.TChanges.alias('changes') detail = sql.t.TChangesDetail.alias('detail') return sqlalchemy.select( cls._exclude(changes) + cls._exclude(detail, 'id'), from_obj=[changes.outerjoin(detail, changes.c.id == detail.c.id)] ) insert_order = () update_order = () delete_order = () depends_on = (TChanges, TChangesDetail,) access_rights = default_access_rights.value(globals())
class EPytisOutputTemplates(Base_LogSQLTable): """Storage of print output templates handled by a DatabaseResolver.""" name = 'e_pytis_output_templates' fields = ( sql.PrimaryColumn('id', pytis.data.Serial()), sql.Column('module', pytis.data.String(not_null=True)), sql.Column('specification', pytis.data.String(not_null=True)), sql.Column('template', pytis.data.String(not_null=False)), sql.Column('rowtemplate', pytis.data.String(not_null=False)), sql.Column('header', pytis.data.String(not_null=False)), sql.Column('first_page_header', pytis.data.String(not_null=False)), sql.Column('footer', pytis.data.String(not_null=False)), sql.Column('style', pytis.data.String(not_null=False)), sql.Column('username', pytis.data.String(not_null=False)), ) inherits = (XChanges, ) with_oids = True depends_on = () access_rights = default_access_rights.value(globals())