Exemple #1
0
def add(data):
    with database:
        place_id = database.insert_place(data)

    if not place_id:
        log.warn("Failed to add place: %s", data)

        return False

    return place_id
Exemple #2
0
def register(name, password):
    hashed = bcrypt.generate_password_hash(password)

    with database:
        patron_id = database.insert_patron(name, hashed)

    if not patron_id:
        log.warn("Failed to register Patron name: %s", name)

        return False

    log.info("Registered Patron name: %s", name)

    return login(name, password)
Exemple #3
0
def login(name, password):
    with database:
        patron = database.select_patron(name)

    if not patron:
        log.warn("Patron name not found: %s", name)

        return False

    result = bcrypt.check_password_hash(patron["password"], password)

    if result:
        store(patron)

    log.warn("Password failed hash check for Patron name: %s", name)

    return result
Exemple #4
0
def add(data):
    place_id = place.add(data["place"])

    if not place_id:
        return False

    data["place_id"] = place_id

    with database:
        visit_id = database.insert_visit(data)

    if not visit_id:
        log.warn("Failed to add visit: %s", data)

        return False

    return visit_id