Ejemplo n.º 1
0
def mod_profile_password(user):
    current_password = md5(user["current_password"].encode())
    new_password = md5(user["new_password"].encode())
    email = token_query(user["token"])
    db_user_info = r.table("user").get(email).run()
    if current_password.hexdigest() == db_user_info["password"]:
        r.table("user").get(email).update({
            "password": new_password.hexdigest()
        }).run()
        return "information changed"
    else:
        return "wrong password"
def create_lunch(event):
    email = token_query(event["token"])
    # extract the information and convert string in a datetime object
    starting_time = datetime.strptime(event["range_min"], "%H:%M")
    starting_day = datetime.strptime(event["starting_flexible_day"], "%Y-%m-%d").\
        replace(hour=starting_time.hour, minute=starting_time.minute)
    ending_day = datetime.strptime(event["ending_flexible_day"], "%Y-%m-%d")
    # datespan create the start time of the event day by day
    for timestamp in datespan(starting_day, ending_day):
        start = timestamp
        # add the duration at the startime
        end = start + timedelta(hours=datetime.strptime(event["duration_event"], "%H:%M").hour,
                                minutes=datetime.strptime(event["duration_event"], "%H:%M").minute)
        create_lunch_event(start, end, email)
Ejemplo n.º 3
0
def get_route(token, gps_start, gps_stop):
    r.connect(rts.ip, rts.port, rts.db_name).repl()
    email = token_query(token)
    prefs = r.table("user").get(email).get_field('preference').run()
    trans_list = [elem[0] for elem in prefs.items() if elem[1]]
    req_dict = {
        'gps_begin': gps_start,
        'gps_end': gps_stop,
        'allowed_types': trans_list
    }
    req = requests.post(url, json=req_dict)
    if req.status_code == 200:
        return req.text
    else:
        return "ERROR"
Ejemplo n.º 4
0
def mod_profile(user):
    email = token_query(user["token"])
    del user["token"]
    r.table("user").get(email).update(user).run()
Ejemplo n.º 5
0
def get_profile_preference(token):
    email = token_query(token)
    result = r.table("user").get(email).get_field("preference").run()
    return result
Ejemplo n.º 6
0
def mod_profile_preference(user):
    email = token_query(user["token"])
    del user["token"]
    r.table("user").get(email).update({"preference": user}).run()
Ejemplo n.º 7
0
def get_profile(token):
    email = token_query(token)
    result = r.table("user").get(email).run()
    return result
Ejemplo n.º 8
0
def get_email(token):
    return token_query(token)