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!")
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()})
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
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)
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())
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
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
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
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
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)
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
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()
def get(): db_controller = DBController() db_controller.connect() return db_controller.as_array("reports")
def get(select_filter): db_controller = DBController() db_controller.connect() return db_controller.as_array("users", select_filter)