Ejemplo n.º 1
0
def delete_a_place(place_id):
    place = PlaceModel.select().where(PlaceModel.ID == place_id)
    if len(place) != 0:
        place = PlaceModel.delete().where(PlaceModel.ID == place_id)
        place.execute()
        success_message = "Record deleted Successfully"
        return jsonify({"message": success_message})
    success_message = "No record Found"
    return jsonify({"message": success_message})
Ejemplo n.º 2
0
def initialize_tables():
    connect_db()
    if not PlaceModel.table_exists():
        PlaceModel.create_table()
    if not UserModel.table_exists():
        UserModel.create_table()
    if not AdminModel.table_exists():
        AdminModel.create_table()

    disconnect_db()
Ejemplo n.º 3
0
def get_a_place(place_id):
    place = PlaceModel.select().where(PlaceModel.ID == place_id).order_by(
        PlaceModel.ID).dicts()
    if len(place) == 0:
        success_message = "No record Found"
        return jsonify({"message": success_message})
    return jsonify({'count': place.count()}, {'places': list(place)})
Ejemplo n.º 4
0
def update_place(place_id):
    place = PlaceModel.get(PlaceModel.ID == place_id)
    temp_place = place._data
    for key, value in temp_place.items():
        place._data[key] = request.form.get(key, value)
    place.save()
    success_message = "Successfully Updated record with ID {}".format(place_id)
    return jsonify({"message": success_message})
Ejemplo n.º 5
0
def create_place():
    NameOfPlace = request.form['NameOfPlace']
    Description = request.form['Description']
    GPS = [{'long': request.form['long']}, {'lat': request.form['lat']}]
    PhotoPlace = request.form['PhotoPlace']
    PhotoQrcode = request.form['PhotoQrcode']
    PhoneNumberPlace1 = request.form['PhoneNumberPlace1']
    PhoneNumberPlace2 = request.form['PhoneNumberPlace2']

    save_place = PlaceModel(NameOfPlace=NameOfPlace,
                            Description=Description,
                            GPS=GPS,
                            PhotoPlace=PhotoPlace,
                            PhotoQrcode=PhotoQrcode,
                            PhoneNumberPlace1=PhoneNumberPlace1,
                            PhoneNumberPlace2=PhoneNumberPlace2)
    save_place.save()

    success_message = "Added Successfully"
    return jsonify({"message": success_message})
Ejemplo n.º 6
0
def log_in_user():
    Email = request.form['email']
    Password = request.form['password']
    querry_users = AdminModel.select().where(AdminModel.Email == Email).first()

    if (querry_users == 0 and bcrypt.hashpw(Password, querry_users.Password)
            == querry_users.Password):
        success_message = 'No Results Found'
        return jsonify({"message ": success_message})
    session['logged_in'] = True
    session['username'] = querry_users.NameOfUser
    # return jsonify([{"message":"successful Login"},{"user":session['username']},{"Login_status":session['logged_in']}])
    message = "successful Login"
    user = session['username']
    login_status = session['logged_in']

    places = len(PlaceModel.select())

    return render_template('index.html',
                           places=places,
                           message=message,
                           user=user,
                           login_status=login_status)
Ejemplo n.º 7
0
def get_all_place():
    place = PlaceModel.select().order_by(PlaceModel.ID).dicts()
    return jsonify({'count': place.count()}, {'result': list(place)})