def create_user(post_data): my_birth_date = datetime.datetime.strptime(post_data['birth_date'], "%d/%m/%Y") _user = user(first_name=post_data['first_name'], last_name=post_data['last_name'], birth_date=my_birth_date, email=post_data['email'], genre=post_data['genre'], topics_descriptions=post_data['topics_descriptions']) create_in_db(_user) user_created = user.query.filter_by(email=_user.email).first() return user_created
def create_user_status(id_user, my_user_status): my_user_status = my_user_status.lower() _user_status = user_status(id_user=id_user, user_status=my_user_status) create_in_db(_user_status) user_status_created = user_status.query.filter_by( id_user=_user_status.id_user).order_by(desc(user_status.date_created)).first() return user_status_created
def create_disabled_account(post_data): _disabled_account = disabled_account(id_user=post_data['id_user'], is_disabled=post_data['is_disabled']) create_in_db(_disabled_account) disabled_account_created = disabled_account.query.filter_by( id_user=_disabled_account.id_user).order_by( desc(disabled_account.date_created)).first() return disabled_account_created
def create_feedback(post_data): _feedback = feedback( id_user_receiver=post_data['id_user_receiver'], id_user_giver=post_data['id_user_giver'], feedback_description=post_data['feedback_description']) create_in_db(_feedback) feedback_created = feedback.query.filter_by( feedback_description=_feedback.feedback_description).first() return feedback_created
def create_report(id_report_type, id_user_reported, id_user_reported_by): _report = report(id_report_type=id_report_type, id_user_reported=id_user_reported, id_user_reported_by=id_user_reported_by) create_in_db(_report) _report_created = report.query.filter_by( id_report_type=id_report_type, id_user_reported=id_user_reported, id_user_reported_by=id_user_reported_by).first() return _report_created
def create_report_type(post_data): _report_type = report_type( report_type_description=post_data['report_type_description']) create_in_db(_report_type) return report_type.query.filter_by( report_type_description=_report_type.report_type_description).first()
def create_report_status(id_report, is_pending=True): _report_status = report_status(id_report=id_report, is_pending=is_pending) create_in_db(_report_status) return True
def create_report_text(id_report, text): _report_text = report_text(id_report=id_report, report_text=text) create_in_db(_report_text) return True
def add_fb_user(fb_user_id, id_user): _fb_user = fb_user(fb_user_id=str(fb_user_id), id_user=id_user) create_in_db(_fb_user)
def create_language(post_data): _language = language(language_description=post_data['language_description']) create_in_db(_language) language_created = language.query.filter_by(language_description=_language.language_description).first() return language_created
def add_profile_picture(id_user, url): _profile_picture = profile_picture(id_user=id_user, url_picture=url) create_in_db(_profile_picture)
def create_level(post_data): _level = level(level_description=post_data['level_description']) create_in_db(_level) level_created = level.query.filter_by( level_description=_level.level_description).first() return level_created
def create_block(id_user_1, id_user_2): _block = block(id_user_blocker=id_user_1, id_user_blocked=id_user_2) return create_in_db(_block)
def add_spoken_language_native(id_user, id_language, id_level=None): _spoken_language = spoken_language(id_user=id_user, id_language=id_language, id_level=id_level, is_native=True) create_in_db(_spoken_language)
def create_log_login_user(id_user): _log_login_user = log_login_user(id_user=id_user) return create_in_db(_log_login_user)
def add_spoken_language_practice(id_user, id_language, id_level): _spoken_language = spoken_language(id_user=id_user, id_language=id_language, id_level=id_level, is_native=False) create_in_db(_spoken_language)
def create_admin(email, encoded_password, first_name, last_name): _admin = admin(email=email, password=encoded_password, first_name=first_name, last_name=last_name) return create_in_db(_admin)
def create_follower(id_user_1, id_user_2): _follower = follower(id_user_followed=id_user_1, id_user_following=id_user_2) create_in_db(_follower)
def create_genre(post_data): _genre = genre(genre_description=post_data['genre_description']) create_in_db(_genre) genre_created = genre.query.filter_by( genre_description=_genre.genre_description).first() return genre_created