def create(self): form = EditItemForm(self.request.POST) if not form.is_valid(): return self.json_error('collections.items.create.form_errors', form.errors) item = ItemPrototype.create(kit=form.c.kit, caption=form.c.caption, text=form.c.text) return self.json_ok(data={'next_url': url('collections:collections:show', item.kit.collection_id)})
def update(self, method='post'): form = EditItemForm(self.request.POST) if not form.is_valid(): return self.json_error('collections.items.update.form_errors', form.errors) self.item.kit_id = form.c.kit.id self.item.caption = form.c.caption self.item.text = form.c.text self.item.save() return self.json_ok(data={'next_url': url('collections:collections:show', self.item.kit.collection_id)})
def create(self): form = EditItemForm(self.request.POST) if not form.is_valid(): return self.json_error('collections.items.create.form_errors', form.errors) item = ItemPrototype.create(kit=form.c.kit, caption=form.c.caption, text=form.c.text) return self.json_ok( data={ 'next_url': url('collections:collections:show', item.kit.collection_id) })
def edit(self): form = EditItemForm( initial={ 'kit': self.item.kit_id, 'caption': self.item.caption, 'text': self.item.text }) return self.template('collections/items/edit.html', {'form': form})
def update(self, method='post'): form = EditItemForm(self.request.POST) if not form.is_valid(): return self.json_error('collections.items.update.form_errors', form.errors) self.item.kit_id = form.c.kit.id self.item.caption = form.c.caption self.item.text = form.c.text self.item.save() return self.json_ok( data={ 'next_url': url('collections:collections:show', self.item.kit.collection_id) })
def new(self): return self.template('collections/items/new.html', {'form': EditItemForm()})