class Configuration(orm.BaseExpando): _kind = 57 _use_record_engine = False _use_rule_engine = False created = orm.SuperDateTimeProperty('1', required=True, auto_now_add=True) updated = orm.SuperDateTimeProperty('2', required=True, auto_now=True) configuration_input = orm.SuperPickleProperty('3', required=True, compressed=False, indexed=False) setup = orm.SuperStringProperty('4', required=True, indexed=False) state = orm.SuperStringProperty('5', required=True) next_operation = orm.SuperStringProperty('6', indexed=False) next_operation_input = orm.SuperPickleProperty('7', indexed=False) _default_indexed = False _global_role = GlobalRole(permissions=[ orm.ActionPermission('57', [ orm.Action.build_key('57', 'install'), orm.Action.build_key('57', 'cron_install') ], True, 'user._is_taskqueue') ]) _actions = [ orm.Action( key=orm.Action.build_key('57', 'install'), arguments={'key': orm.SuperKeyProperty(required=True, kind='57')}, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), RulePrepare(cfg={'skip_user_roles': True}), RuleExec(), ConfigurationInstall() ]) ]), orm.Action(key=orm.Action.build_key('57', 'cron_install'), arguments={}, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), RulePrepare(cfg={'skip_user_roles': True}), RuleExec(), ConfigurationCronInstall( cfg={'time': settings.SETUP_ELAPSED_TIME}) ]) ]) ]
class LineTax(orm.BaseModel): _kind = 116 _use_rule_engine = False name = orm.SuperStringProperty('1', required=True, indexed=False) code = orm.SuperStringProperty('2', required=True, indexed=False) formula = orm.SuperPickleProperty('3', required=True, indexed=False)
class Role(orm.BaseExpando): _kind = 66 # feature proposition (though it should create overhead due to the required drilldown process!) # parent_record = orm.SuperKeyProperty('1', kind='Role', indexed=False) # complete_name = orm.SuperTextProperty('2') name = orm.SuperStringProperty('1', required=True) active = orm.SuperBooleanProperty('2', required=True, default=True) permissions = orm.SuperPickleProperty('3', required=True, default=[], compressed=False) # List of Permissions instances. Validation is required against objects in this list, if it is going to be stored in datastore. _default_indexed = False def run(self, context): for permission in self.permissions: permission.run(self, context)
class CustomTemplate(Template): _kind = 59 _use_rule_engine = False message_recievers = orm.SuperPickleProperty('1', required=True, indexed=False) message_subject = orm.SuperStringProperty('2', required=True, indexed=False) message_body = orm.SuperTextProperty('3', required=True) outlet = orm.SuperStringProperty('4', required=True, default='send_mail', indexed=False) def run(self, **kwargs): callbacks = [] template_values = {'entity': kwargs['caller_entity']} data = { 'action_id': self.outlet, 'action_model': '61', 'recipient': self.message_recievers(kwargs['caller_entity'], kwargs['caller_user']), 'body': render_template(self.message_body, template_values), 'subject': render_template(self.message_subject, template_values), 'caller_entity': kwargs['caller_entity'].key.urlsafe() } callbacks.append(('send', data)) return callbacks
class Notification(orm.BaseExpando): _kind = 61 name = orm.SuperStringProperty('1', required=True) action = orm.SuperKeyProperty('2', kind='56', required=True) condition = orm.SuperStringProperty('3', required=True, indexed=False) active = orm.SuperBooleanProperty('4', required=True, default=True) templates = orm.SuperPickleProperty('5', required=True, indexed=False, compressed=False) _default_indexed = False _virtual_fields = {'_records': orm.SuperRecordProperty('61')} _global_role = GlobalRole(permissions=[ orm.ActionPermission( '61', [ orm.Action.build_key('61', 'prepare'), orm.Action.build_key('61', 'create'), orm.Action.build_key('61', 'read'), orm.Action.build_key('61', 'update'), orm.Action.build_key('61', 'delete'), orm.Action.build_key('61', 'search') ], False, 'entity._original.namespace_entity._original.state != "active"'), orm.ActionPermission('61', [ orm.Action.build_key('61', 'initiate'), orm.Action.build_key('61', 'send_mail'), orm.Action.build_key('61', 'send_http') ], False, 'True'), orm.ActionPermission( '61', [ orm.Action.build_key('61', 'initiate'), orm.Action.build_key('61', 'send_mail'), orm.Action.build_key('61', 'send_http') ], True, 'entity._original.namespace_entity._original.state == "active" and user._is_taskqueue' ), orm.FieldPermission( '61', ['name', 'action', 'condition', 'active', 'templates', '_records'], False, False, 'entity._original.namespace_entity._original.state != "active"') ]) _actions = [ orm.Action(key=orm.Action.build_key('61', 'prepare'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Set(cfg={'d': { 'output.entity': '_notification' }}) ]) ]), orm.Action( key=orm.Action.build_key('61', 'create'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True), 'name': orm.SuperStringProperty(required=True), 'action': orm.SuperVirtualKeyProperty(required=True, kind='56'), 'condition': orm.SuperTextProperty(required=True), 'active': orm.SuperBooleanProperty(), 'templates': orm.SuperMultiLocalStructuredProperty(('58', '63'), repeated=True) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), Set( cfg={ 'd': { '_notification.name': 'input.name', '_notification.action': 'input.action', '_notification.condition': 'input.condition', '_notification.active': 'input.active', '_notification.templates': 'input.templates' } }), RulePrepare(), RuleExec() ]), orm.PluginGroup( transactional=True, plugins=[ Write(), Set(cfg={'d': { 'output.entity': '_notification' }}), CallbackNotify(), CallbackExec() ]) ]), orm.Action(key=orm.Action.build_key('61', 'read'), arguments={ 'key': orm.SuperKeyProperty(kind='61', required=True), 'read_arguments': orm.SuperJsonProperty() }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Set(cfg={'d': { 'output.entity': '_notification' }}) ]) ]), orm.Action( key=orm.Action.build_key('61', 'update'), arguments={ 'key': orm.SuperKeyProperty(required=True, kind='61'), 'name': orm.SuperStringProperty(required=True), 'action': orm.SuperVirtualKeyProperty(required=True, kind='56'), 'condition': orm.SuperTextProperty(required=True), 'active': orm.SuperBooleanProperty(), 'templates': orm.SuperMultiLocalStructuredProperty(('58', '63'), repeated=True), 'read_arguments': orm.SuperJsonProperty() }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), Set( cfg={ 'd': { '_notification.name': 'input.name', '_notification.action': 'input.action', '_notification.condition': 'input.condition', '_notification.active': 'input.active', '_notification.templates': 'input.templates' } }), RulePrepare(), RuleExec() ]), orm.PluginGroup( transactional=True, plugins=[ Write(), Set(cfg={'d': { 'output.entity': '_notification' }}), CallbackNotify(), CallbackExec() ]) ]), orm.Action( key=orm.Action.build_key('61', 'delete'), arguments={'key': orm.SuperKeyProperty(required=True, kind='61')}, _plugin_groups=[ orm.PluginGroup( plugins=[Context( ), Read(), RulePrepare(), RuleExec()]), orm.PluginGroup( transactional=True, plugins=[ Delete(), Set(cfg={'d': { 'output.entity': '_notification' }}), CallbackNotify(), CallbackExec() ]) ]), orm.Action(key=orm.Action.build_key('61', 'search'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True), 'search': orm.SuperSearchProperty( default={ 'filters': [], 'orders': [{ 'field': 'name', 'operator': 'asc' }] }, cfg={ 'search_arguments': { 'kind': '61', 'options': { 'limit': settings.SEARCH_PAGE } }, 'filters': { 'name': orm.SuperStringProperty(), 'action': orm.SuperVirtualKeyProperty(kind='56'), 'active': orm.SuperBooleanProperty() }, 'indexes': [{ 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('name', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('action', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('active', ['=='])], 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('active', ['==']), ('name', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('active', ['==']), ('action', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])] }, { 'filters': [('active', ['==']), ('name', ['==', '!=']), ('action', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])] }] }) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Search(), RulePrepare(cfg={'path': '_entities'}), Set( cfg={ 'd': { 'output.entities': '_entities', 'output.cursor': '_cursor', 'output.more': '_more' } }) ]) ]), orm.Action( key=orm.Action.build_key('61', 'initiate'), arguments={ 'caller_entity': orm.SuperKeyProperty(required=True), 'caller_user': orm.SuperKeyProperty(required=True, kind='0'), 'caller_action': orm.SuperVirtualKeyProperty(required=True) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Set(cfg={ 'd': { '_caller_entity': 'input.caller_entity.entity' } }), Read(cfg={'namespace': '_caller_entity.key_namespace'}), RulePrepare(), RuleExec(), NotificationInitiate(), CallbackExec() ]) ]), orm.Action( key=orm.Action.build_key('61', 'send_mail'), arguments={ 'recipient': orm.SuperStringProperty(repeated=True), 'subject': orm.SuperTextProperty(required=True), 'body': orm.SuperTextProperty(required=True), 'caller_entity': orm.SuperKeyProperty(required=True) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Set(cfg={ 'd': { '_caller_entity': 'input.caller_entity.entity' } }), Read(cfg={'namespace': '_caller_entity.key_namespace'}), RulePrepare(), RuleExec(), NotificationMailSend(cfg={'sender': settings.NOTIFY_EMAIL}) ]) ]), orm.Action( key=orm.Action.build_key('61', 'send_http'), arguments={ 'recipient': orm.SuperStringProperty(required=True), 'subject': orm.SuperTextProperty(required=True), 'body': orm.SuperTextProperty(required=True), 'caller_entity': orm.SuperKeyProperty(required=True) }, _plugin_groups=[ orm.PluginGroup(plugins=[ Context(), Set(cfg={ 'd': { '_caller_entity': 'input.caller_entity.entity' } }), Read(cfg={'namespace': '_caller_entity.key_namespace'}), RulePrepare(), RuleExec(), NotificationHttpSend() ]) ]) ]
class Journal(orm.BaseExpando): _kind = 49 created = orm.SuperDateTimeProperty('1', required=True, auto_now_add=True) updated = orm.SuperDateTimeProperty('2', required=True, auto_now=True) name = orm.SuperStringProperty('3', required=True) state = orm.SuperStringProperty('4', required=True, default='draft', choices=['draft', 'active', 'decommissioned']) entry_fields = orm.SuperPickleProperty('5', required=True, indexed=False, compressed=False) line_fields = orm.SuperPickleProperty('6', required=True, indexed=False, compressed=False) _default_indexed = False _virtual_fields = { '_records': orm.SuperRecordProperty('49'), '_code': orm.SuperComputedProperty(lambda self: self.key_id_str), '_transaction_actions': orm.SuperRemoteStructuredProperty(Action, repeated=True), '_transaction_plugin_groups': orm.SuperRemoteStructuredProperty(PluginGroup, repeated=True) } _global_role = GlobalRole( permissions=[ orm.ActionPermission('49', [orm.Action.build_key('49', 'prepare'), orm.Action.build_key('49', 'create'), orm.Action.build_key('49', 'read'), orm.Action.build_key('49', 'update'), orm.Action.build_key('49', 'delete'), orm.Action.build_key('49', 'search'), orm.Action.build_key('49', 'activate'), orm.Action.build_key('49', 'decommission')], False, 'entity._original.namespace_entity._original.state != "active"'), orm.ActionPermission('49', [orm.Action.build_key('49', 'delete')], False, 'entity._original.state != "draft"'), orm.ActionPermission('49', [orm.Action.build_key('49', 'activate')], False, 'entity._original.state == "active"'), orm.ActionPermission('49', [orm.Action.build_key('49', 'decommission')], False, 'entity._is_system or entity._original.state != "active"'), orm.FieldPermission('49', ['created', 'updated', 'state'], False, None, 'True'), orm.FieldPermission('49', ['created', 'updated', 'name', 'state', 'entry_fields', 'line_fields', '_records', '_code', '_transaction_actions', '_transaction_plugin_groups'], False, False, 'entity._original.namespace_entity._original.state != "active"'), orm.FieldPermission('49', ['created', 'updated', 'name', 'state', 'entry_fields', 'line_fields', '_records', '_code'], False, None, 'entity._original.state != "draft"'), orm.FieldPermission('49', ['_transaction_actions', '_transaction_plugin_groups.name', '_transaction_plugin_groups.subscriptions', '_transaction_plugin_groups.active', '_transaction_plugin_groups.sequence', '_transaction_plugin_groups.transactional'], False, None, 'entity._is_system'), orm.FieldPermission('49', ['_transaction_plugin_groups.plugins'], False, None, 'entity._is_system and entity._original._transaction_plugin_groups.name != "User Plugins"'), # @todo Missing index between _transaction_plugin_groups and name! orm.FieldPermission('49', ['state'], True, None, '(action.key_id_str == "activate" and entity.state == "active") or (action.key_id_str == "decommission" and entity.state == "decommissioned")') ] ) _actions = [ orm.Action( key=orm.Action.build_key('49', 'prepare'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Set(cfg={'d': {'output.entity': '_journal'}}) ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'create'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True), '_code': orm.SuperStringProperty(required=True, max_size=64), # Regarding max_size, take a look at the transaction.JournalUpdateRead() plugin! 'name': orm.SuperStringProperty(required=True), 'entry_fields': orm.SuperPropertyStorageProperty(required=True, cfg=JOURNAL_FIELDS), 'line_fields': orm.SuperPropertyStorageProperty(required=True, cfg=JOURNAL_FIELDS) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), Set(cfg={'s': {'_journal.state': 'draft'}, 'd': {'_journal.name': 'input.name', '_journal.entry_fields': 'input.entry_fields', '_journal.line_fields': 'input.line_fields'}}), RulePrepare(), RuleExec() ] ), orm.PluginGroup( transactional=True, plugins=[ Write(), Set(cfg={'d': {'output.entity': '_journal'}}), CallbackNotify(), CallbackExec() ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'read'), arguments={ 'key': orm.SuperKeyProperty(kind='49', required=True), 'read_arguments': orm.SuperJsonProperty() }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Set(cfg={'d': {'output.entity': '_journal'}}) ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'update'), arguments={ 'key': orm.SuperKeyProperty(kind='49', required=True), 'name': orm.SuperStringProperty(required=True), 'entry_fields': orm.SuperPropertyStorageProperty(required=True, cfg=JOURNAL_FIELDS), 'line_fields': orm.SuperPropertyStorageProperty(required=True, cfg=JOURNAL_FIELDS), '_transaction_actions': orm.SuperLocalStructuredProperty(Action, repeated=True), '_transaction_plugin_groups': orm.SuperLocalStructuredProperty(PluginGroup, repeated=True) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), Set(cfg={'d': {'_journal.name': 'input.name', '_journal.entry_fields': 'input.entry_fields', '_journal.line_fields': 'input.line_fields', '_journal._transaction_actions': 'input._transaction_actions', '_journal._transaction_plugin_groups': 'input._transaction_plugin_groups'}}), RulePrepare(), RuleExec() ] ), orm.PluginGroup( transactional=True, plugins=[ Write(), Set(cfg={'d': {'output.entity': '_journal'}}), CallbackNotify(), CallbackExec() ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'delete'), arguments={ 'key': orm.SuperKeyProperty(kind='49', required=True) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), RulePrepare(), RuleExec() ] ), orm.PluginGroup( transactional=True, plugins=[ Delete(), Set(cfg={'d': {'output.entity': '_journal'}}), CallbackNotify(), CallbackExec() ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'search'), arguments={ 'domain': orm.SuperKeyProperty(kind='6', required=True), 'search': orm.SuperSearchProperty( default={'filters': [], 'orders': [{'field': 'name', 'operator': 'asc'}]}, cfg={ 'search_arguments': {'kind': '49', 'options': {'limit': settings.SEARCH_PAGE}}, 'filters': {'name': orm.SuperStringProperty(), 'state': orm.SuperStringProperty(choices=[])}, 'indexes': [{'orders': [('name', ['asc', 'desc'])]}, {'orders': [('state', ['asc', 'desc'])]}, {'filters': [('name', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])]}, {'filters': [('state', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])]}, {'filters': [('state', ['==', '!=']), ('name', ['==', '!='])], 'orders': [('name', ['asc', 'desc'])]}] } ) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), RulePrepare(), RuleExec(), Search(), RulePrepare(cfg={'path': '_entities'}), Set(cfg={'d': {'output.entities': '_entities', 'output.cursor': '_cursor', 'output.more': '_more'}}) ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'activate'), arguments={ 'key': orm.SuperKeyProperty(kind='49', required=True), 'message': orm.SuperTextProperty(required=True) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), Set(cfg={'s': {'_journal.state': 'active'}}), RulePrepare(), RuleExec() ] ), orm.PluginGroup( transactional=True, plugins=[ Write(cfg={'dra': {'message': 'input.message'}}), CallbackNotify(), CallbackExec() ] ), orm.PluginGroup( plugins=[ RulePrepare(), Set(cfg={'d': {'output.entity': '_journal'}}) ] ) ] ), orm.Action( key=orm.Action.build_key('49', 'decommission'), arguments={ 'key': orm.SuperKeyProperty(kind='49', required=True), 'message': orm.SuperTextProperty(required=True) }, _plugin_groups=[ orm.PluginGroup( plugins=[ Context(), Read(), Set(cfg={'s': {'_journal.state': 'decommissioned'}}), RulePrepare(), RuleExec() ] ), orm.PluginGroup( transactional=True, plugins=[ Write(cfg={'dra': {'message': 'input.message'}}), CallbackNotify(), CallbackExec() ] ), orm.PluginGroup( plugins=[ RulePrepare(), Set(cfg={'d': {'output.entity': '_journal'}}) ] ) ] ) ] @classmethod def prepare_key(cls, input, **kwargs): code = input.get('_code') return cls.build_key(code, namespace=kwargs.get('namespace')) # @todo Possible prefix? @property def _is_system(self): return self.key_id_str.startswith('system_')