示例#1
0
 def get(self,item_id):
     from page.models import Button
     self._context['button'] = Button.get_by_id(item_id).name
     return self.render()
示例#2
0
 def get(self, item_id):
     from page.models import Button
     self._context['button'] = Button.get_by_id(item_id).name
     return self.render()
示例#3
0
 def post(self):
     from page.models import Button
     if self._form().validate():
         f = self._form()
         b = Button.query.get(Button.get_id_by_name(f.name.data))
         if b is not None:
             self.flash('There is already a button by that name')
         else:
             b = Button()
             b.name = f.name.data
             b.size = f.size.data
             b.color = f.color.data
             b.text = f.text.data
             b.icon = f.icon.data
             b.icon_library = f.icon_library.data
             b.type = f.type.data
             if b.type == 'link':
                 b.is_link = True
                 b.endpoint = f.link_href.data
             else:
                 b.is_link = False
             b.save()
             return self.redirect('admin.view_button',item_id=b.id)
         return self.render()
     return self.render()
示例#4
0
 def post(self):
     from page.models import Button
     if self._form().validate():
         f = self._form()
         b = Button.query.get(Button.get_id_by_name(f.name.data))
         if b is not None:
             self.flash('There is already a button by that name')
         else:
             b = Button()
             b.name = f.name.data
             b.size = f.size.data
             b.color = f.color.data
             b.text = f.text.data
             b.icon = f.icon.data
             b.icon_library = f.icon_library.data
             b.type = f.type.data
             if b.type == 'link':
                 b.is_link = True
                 b.endpoint = f.link_href.data
             else:
                 b.is_link = False
             b.save()
             return self.redirect('admin.view_button', item_id=b.id)
         return self.render()
     return self.render()