Exemplo n.º 1
0
    def edit(self, id):
        c.stream = Stream.find_by_id(id)

        defaults = h.object_to_defaults(c.stream, 'stream')

        form = render('/stream/edit.mako')
        return htmlfill.render(form, defaults)
Exemplo n.º 2
0
    def _delete(self, id):
        c.stream = Stream.find_by_id(id)
        meta.Session.delete(c.stream)
        meta.Session.commit()

        h.flash("Stream has been deleted.")
        redirect_to('index')
Exemplo n.º 3
0
    def delete(self, id):
        """Delete the stream

        GET will return a form asking for approval.

        POST requests will delete the item.
        """
        c.stream = Stream.find_by_id(id)
        return render('/stream/confirm_delete.mako')
Exemplo n.º 4
0
    def _new(self):
        results = self.form_result['stream']

        c.stream = Stream(**results)
        meta.Session.add(c.stream)
        meta.Session.commit()

        h.flash("Stream created")
        redirect_to(action='index')
Exemplo n.º 5
0
    def _edit(self, id):
        stream = Stream.find_by_id(id)

        for key in self.form_result['stream']:
            setattr(stream, key, self.form_result['stream'][key])

        # update the objects with the validated form data
        meta.Session.commit()
        h.flash("The stream has been updated successfully.")
        redirect_to(action='index')
Exemplo n.º 6
0
 def index(self):
     c.can_edit = True
     c.stream_collection = Stream.find_all()
     return render('/stream/list.mako')
Exemplo n.º 7
0
 def view(self, id):
     c.stream = Stream.find_by_id(id)
     return render('/stream/view.mako')
Exemplo n.º 8
0
 def validate_python(self, values, state):
     stream = Stream.find_by_name(values['stream']['name'])
     if stream != None and stream != c.stream:
         message = "Duplicate Stream name"
         error_dict = {'stream.name': "Stream name already in use"}
         raise Invalid(message, values, state, error_dict=error_dict)