def add_interest(interest, icon, id_user): array1 = [interest, icon] sql = 'INSERT INTO interests (title, icon) VALUES (?, ?)' database.db_insert(sql, array1) id_interest = get_interest_by_title(interest)[0]['id_interest'] if not check_interest(id_interest, id_user): array2 = [id_interest, id_user] sql = 'INSERT INTO interests_users (id_interest, id_user) VALUES (?, ?)' res = database.db_insert(sql, array2) return res else: return 'exists'
def add_work(id_user, company, designation, from_year, to_year, city, description): array = [ id_user, company, designation, from_year, to_year, city, description ] sql = 'INSERT INTO job(id_user, company, designation, from_year, to_year, city, description) VALUES (?, ?, ?, ?, ?, ?, ?)' res = database.db_insert(sql, array) return res
def save_user_to_db(login, password, firstname, lastname, email, avatar, background, birth_date, city, country, token, gender, sex_pref): array = [ login, password, firstname, lastname, email, avatar, background, birth_date, city, country, token, gender, sex_pref ] sql = 'INSERT INTO users (login, password, firstname, lastname, email, avatar, background, birth_date, city, country, token, gender, sex_pref) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' res = database.db_insert(sql, array) return res
def dislike(id_photo, id_user): array = [id_photo, id_user] if check_dislike(id_photo, id_user): remove_dislike(id_photo, id_user) else: sql = 'INSERT INTO dislikes (id_photo, id_user) VALUES (?, ?)' res = database.db_insert(sql, array) if check_like(id_photo, id_user): remove_like(id_photo, id_user) return 'was' return res
def delete_comment(id_comment): array = [id_comment] sql = 'DELETE FROM comments WHERE id_comment=?' res = database.db_insert(sql, array) return res
def create_profile_settings(id_user, user_gender, user_sex_pref, user_filter): array = [id_user, user_gender, user_sex_pref, user_filter] sql = 'INSERT INTO profile_settings (id_user, user_gender, user_sex_pref, user_filter) VALUES (?, ?, ?, ?)' res = database.db_insert(sql, array) return res
def add_comment(id_photo, id_user, text): array = [id_photo, id_user, text] sql = 'INSERT INTO comments(id_photo, id_user, text) VALUES (?, ?, ?)' res = database.db_insert(sql, array) return res
def add_users_to_sympathys(id_user1, id_user2): array = [id_user1, id_user2] sql = 'INSERT INTO sympathys (id_user1, id_user2) VALUES (?,?)' res = database.db_insert(sql, array) return res
def create_about_for_user(id): array = [id] sql = 'INSERT INTO about(id_user) VALUES(?)' res = database.db_insert(sql, array) return res
def like_back_user(id_sender, id_taker): array = [id_sender, id_taker, id_taker, id_sender] sql = 'UPDATE requests SET status=1 WHERE id_sender=? AND id_taker=? OR id_sender=? AND id_taker=?' res = database.db_insert(sql, array) return res
def add_education(id_user, university, date_from, date_to, description): array = [id_user, university, date_from, date_to, description] sql = 'INSERT INTO education(id_user, university, from_year, to_year, description) VALUES (?, ?, ?, ?, ?)' res = database.db_insert(sql, array) return res
def recovery_password(id, password): array = [password, id] sql = 'UPDATE users SET password=?, token = NULL WHERE id=?' res = database.db_insert(sql, array) return res
def remove_dislike(id_photo, id_user): array = [id_photo, id_user] sql = 'DELETE FROM dislikes WHERE id_photo=? AND id_user=?' res = database.db_insert(sql, array) return res
def create_dialogue(dialogue_name, id_user1, id_user2): array = [dialogue_name, id_user1, id_user2] sql = "INSERT INTO dialogues (dialogue_name, id_user1, id_user2) VALUES (?, ?, ?)" res = database.db_insert(sql, array) return res
def send_message(id_dialogue, from_whom_id, to_whom_id, message): array = [id_dialogue, from_whom_id, to_whom_id, message] sql = 'INSERT INTO messages (id_dialogue, from_whom_id, to_whom_id, message) VALUES (?, ?, ?, ?)' res = database.db_insert(sql, array) return res
def add_photo(id_user, photo): array = [id_user, photo] sql = 'INSERT INTO photos (id_user, photo) VALUES (?, ?)' res = database.db_insert(sql, array) return res
def add_notification(to_whom_id, notification, type, image): array = [to_whom_id, notification, type, image] sql = 'INSERT INTO notifications (to_whom_id, notification, notif_type, image) VALUES (?,?,?,?)' res = database.db_insert(sql, array) return res
def like_user(id_sender, id_taker): status = 0 array = [id_sender, id_taker, status] sql = "INSERT INTO requests (id_sender, id_taker, status) VALUES (?, ?, ?)" res = database.db_insert(sql, array) return res
def add_geolocation(id_user, latitude, longitude): array = [id_user, latitude, longitude] sql = 'INSERT INTO geolocation(id_user, latitude, longitude) VALUES (?, ?, ?)' res = database.db_insert(sql, array) return res
def block_user(id_user, my_id): array = [id_user, my_id] sql = 'INSERT INTO blocked_users (blocked_user_id, who_block_id) VALUES (?, ?)' res = database.db_insert(sql, array) return res