def edit(self, key, **data): """Display an edit form for a record""" c = self.collection user = c.user user.authorize('update', c) record = locate(c, key) if record: user.authorize('read', record) user.authorize('update', record) c.fields.initialize(record) c.fields.update(data) form = form_for(c.fields, ButtonField('Save', cancel=record.url)) if c.verbose: msg = '%s edited %s %s' % ( user.link, c.link, record.link, ) log_activity(msg) return page(form, title=c.item_title) else: return page('%s missing' % key)
def new(self, *args, **kwargs): """Return a New Item form""" c = self.collection c.user.authorize('create', c) if kwargs: c.fields.validate(kwargs) form = form_for(c.fields, ButtonField('Create', cancel=c.url)) return page(form, title='New '+c.item_title)