def create_category(self):
     """ Add a new category to the database """
     try:
         category = self.get_argument("category", "")
         if Category.by_category(category) is not None:
             raise ValidationError("Category already exists")
         else:
             new_category = Category()
             new_category.category = category
             self.dbsession.add(new_category)
             self.dbsession.commit()
             self.redirect("/admin/view/categories")
     except ValidationError as error:
         self.render("admin/create/category.html", errors=[str(error)])
 def create_category(self):
     ''' Add a new category to the database '''
     try:
         category = self.get_argument('category', '')
         if Category.by_category(category) is not None:
             raise ValidationError("Category already exists")
         else:
             new_category = Category()
             new_category.category = category
             self.dbsession.add(new_category)
             self.dbsession.commit()
             self.redirect('/admin/view/categories')
     except ValidationError as error:
         self.render("admin/create/category.html", errors=[str(error), ])