Ejemplo n.º 1
0
 def post(self):
     training = Training()
     if not self.try_update_model(training) or \
             not self.validate(model=training, validator=training_validator):
         if self.request.ajax:
             return self.json_response({'errors': self.errors})
         return self.get(training)
     with Session(database='training') as session:
         repo = TrainingRepository(session)
         try:
             repo.add_training(training)
         except PyMongoError:
             self.error('Can not add data to db')
             return self.get(training)
     return self.see_other_for('list')