예제 #1
0
    def POST(self, brand, usp):
        get_url = '/'.join(['/ui/usp_quotes', brand, usp])

        # DELETE?
        try:
            delete_id = web.input().delete_id
        except AttributeError:
            delete_id = None
        if delete_id is not None:
            util.usp.delete_quote(delete_id)
            raise web.seeother(get_url)

        # POST
        form = self.quote_form()
        if not form.validates():
            # FAILURE
            quotes = list(util.usp.get_quotes(brand, usp)['quotes'])
            return render.usp_quotes(brand, usp, quotes, form)
        else:
            # SUCCESS
            util.usp.insert_quote(
                brand, usp,
                form.d.quote, form.d.name, form.d.image,
                bool(form.d.from_twitter)
            )
            raise web.seeother(get_url)
예제 #2
0
 def GET(self, brand, usp):
     form = self.quote_form()
     quotes = list(util.usp.get_quotes(brand, usp)['quotes'])
     return render.usp_quotes(brand, usp, quotes, form)