示例#1
0
 def test_login(self):
     from utils.DBController import DBController
     db_controller = DBController()
     db_controller.connect()
     result = db_controller.select("users", {"username": self.__test_user.get_username(),
                                             "password": self.__test_user.get_password()})
     self.assertTrue(result is not None, "Login test passed!")
示例#2
0
 def suicide(self):
     db_controller = DBController()
     db_controller.connect()
     return db_controller.delete("users", {"email": self.get_email(),
                                           "name": self.get_name(),
                                           "password": self.get_password(),
                                           "username": self.get_username()})
示例#3
0
 def save(self):
     db_controller = DBController()
     db_controller.connect()
     insert_result = db_controller.insert("reports", {
         "content": self.get_content(),
         "user": self.get_content()
     })
     if insert_result is not None:
         return insert_result.inserted_id
     else:
         return None
示例#4
0
文件: User.py 项目: hhldiniz/reportit
 def save(self):
     db_controller = DBController()
     db_controller.connect()
     insert_result = db_controller.insert(
         "users", {
             "name": self.__name,
             "username": self.__username,
             "password": self.__password,
             "email": self.__email,
         })
     return insert_result.inserted_id is not None
示例#5
0
 def save(self):
     db_controller = DBController()
     db_controller.connect()
     insert_result = db_controller.insert(self.get_collection(), {
         "content": self.get_content(),
         "type": self.get_type()
     })
     if insert_result is not None:
         return insert_result.inserted_id
     else:
         return None
示例#6
0
 def get(select_filter):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     return db_controller.as_array("users", select_filter)
示例#7
0
 def __save_photo(self):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     handle = HandlePhotoUpload(db_controller.get_database())
     return handle.put(self.get_photo())
示例#8
0
 def save(self):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     insert_result = db_controller.insert("sources", {
         "url": self.get_url(),
         "user": self.get_user()
     })
     return insert_result.inserted_id is not None
示例#9
0
 def __get_photo_stream(self):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     handle = HandlePhotoUpload(db_controller.get_database())
     file_id = self.get({
         "username": self.get_username(),
         "password": self.get_password()
     })[0]["photo"]
     return handle.write_on_file(file_id)
示例#10
0
 def get():
     result = []
     db_controller = DBController()
     db_controller.connect()
     result.append(db_controller.as_array("report_header"))
     result.append(db_controller.as_array("report_body"))
     result.append(db_controller.as_array("report_footer"))
     return result
示例#11
0
 def save(self):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     insert_result = db_controller.insert(
         "users", {
             "name": self.__name,
             "username": self.__username,
             "password": self.__password,
             "email": self.__email,
             "photo": self.__save_photo()
         })
     return insert_result.inserted_id is not None
示例#12
0
 def save(self):
     if os.environ.get("MONGODB_URI") is None:
         db_controller = DBController()
     else:
         db_controller = DBController(uri=os.environ.get("MONGODB_URI"))
         db_controller.set_dbname(os.environ.get("DATABASE"))
     db_controller.connect()
     self.set_date(datetime.now().timestamp())
     insert_result = db_controller.insert("articles",
                                          {
                                              "name": self.__name,
                                              "source": self.__src,
                                              "content": self.__content,
                                              "user": self.__user,
                                              "date": self.get_date()
                                          })
     return insert_result.inserted_id is not None
def get_articles_names():
    if request.method == "GET":
        db_controller = DBController()
        db_controller.connect()
示例#14
0
 def get():
     db_controller = DBController()
     db_controller.connect()
     return db_controller.as_array("reports")
示例#15
0
文件: User.py 项目: hhldiniz/reportit
 def get(select_filter):
     db_controller = DBController()
     db_controller.connect()
     return db_controller.as_array("users", select_filter)