コード例 #1
0
    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)})
コード例 #2
0
    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)})
コード例 #3
0
    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)
            })
コード例 #4
0
    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})
コード例 #5
0
    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)
            })
コード例 #6
0
 def new(self):
     return self.template('collections/items/new.html',
                          {'form': EditItemForm()})