Beispiel #1
0
 def update_from_dict(self, json_data):
     try:
         self.set_values(json_data)
         self.save_db()
         return self
     except Exception as ex:
         raise exceptions.RepositoryError(str(ex))
Beispiel #2
0
 def create_from_dict(cls, json_data):
     try:
         instance = cls()
         instance.set_values(json_data)
         instance.save_db()
         return instance
     except Exception as ex:
         raise exceptions.RepositoryError(str(ex))
Beispiel #3
0
 def update_from_dict(self, json_data):
     try:
         self.set_values(json_data)
         self.save_db()
         return self
     except Exception as ex:
         if 'manotes_users_email_key' in str(ex):
             raise exceptions.EmailAlreadyExists('Could not update user because the email already exists')
         if 'manotes_users_username_key' in str(ex):
             raise exceptions.UsernameAlreadyExists('Could not update user because the username already exists')
         raise exceptions.RepositoryError(str(ex))
Beispiel #4
0
 def create_from_dict(cls, json_data):
     try:
         instance = cls()
         instance.set_values(json_data)
         instance.save_db()
         return instance
     except Exception as ex:
         if 'manotes_users_email_key' in str(ex):
             raise exceptions.EmailAlreadyExists('Could not create user because the email already exists')
         if 'manotes_users_username_key' in str(ex):
             raise exceptions.UsernameAlreadyExists('Could not create user because the username already exists')
         raise exceptions.RepositoryError(str(ex))