def transaction(): entity_key = context.input.get('key') entity = entity_key.get() context.rule.entity = entity rule.Engine.run(context, True) if not rule.executable(context): raise rule.ActionDenied(context) if context.input.get('state') not in ('su_opened', 'su_awaiting_closure'): # raise custom exception!!! return context.error('state', 'invalid_state') entity.state = context.input.get('state') entity.put() context.log.entities.append((entity, { 'message': context.input.get('message'), 'note': context.input.get('note') })) log.Engine.run(context)
def complete_save(cls, entity, context): upload_url = context.input.get('upload_url') if upload_url: context.output['upload_url'] = blobstore.create_upload_url( upload_url, gs_bucket_name=settings.COMPANY_LOGO_BUCKET) return context context.rule.entity = entity rule.Engine.run(context) if not rule.executable(context): raise rule.ActionDenied(context) set_args = {} for field_name in cls.get_fields(): if field_name in context.input: set_args[field_name] = context.input.get(field_name) entity.populate(**set_args) ndb.make_complete_name(entity, 'name', 'parent_record') entity.put() context.log.entities.append((entity, )) log.Engine.run(context) # mark the logo as used, if it was just uploaded if 'logo' in context.input: blob.Manager.used_blobs(entity.logo.image)
def transaction(): entity_key = context.input.get('key') entity = entity_key.get() context.rule.entity = entity rule.Engine.run(context) if not rule.executable(context): raise rule.ActionDenied(context) entity.key.delete() context.log.entities.append((entity, )) log.Engine.run(context)
def transaction(): entity = cls(parent=context.auth.user.key, state='new') context.rule.entity = entity rule.Engine.run(context, True) if not rule.executable(context): raise rule.ActionDenied(context) entity.reference = context.input.get('reference') entity.put() context.log.entities.append((entity, )) log.Engine.run(context)
def complete_save(cls, entity, context): context.rule.entity = entity rule.Engine.run(context) if not rule.executable(context): raise rule.ActionDenied(context) entity.title = context.input.get('title') entity.body = context.input.get('body') entity.sequence = context.input.get('sequence') entity.put() context.log.entities.append((entity, )) log.Engine.run(context)
def complete_save(cls, entity, context): set_args = {} for field_key in cls.get_fields(): if field_key in context.input: set_args[field_key] = context.input.get(field_key) context.rule.entity = entity rule.Engine.run(context, True) if not rule.executable(context): raise rule.ActionDenied(context) entity.populate(**set_args) entity.put() context.log.entities.append((entity, )) log.Engine.run(context)
def transaction(): entity_key = context.input.get('key') entity = entity_key.get() context.rule.entity = entity rule.Engine.run(context, True) if not rule.executable(context): raise rule.ActionDenied(context) entity.put() # ref project-documentation.py #L-244 context.log.entities.append((entity, { 'message': context.input.get('message'), 'note': context.input.get('note') })) log.Engine.run(context)
def transaction(): entity_key = context.input.get('key') entity = entity_key.get() context.rule.entity = entity rule.Engine.run(context, True) if not rule.executable(context): raise rule.ActionDenied(context) entity.state = 'closed' entity.put() context.log.entities.append((entity, { 'message': context.input.get('message'), 'note': context.input.get('note') })) log.Engine.run(context)