Beispiel #1
0
def deleteimages():
    message=""
    if request.method == 'POST':
        print(f"selected images{request.form.getlist('selectedimages')}")
        selectedimages=request.form.getlist('selectedimages')
    members = Member.query.all()
    if session.get('username') == 'admin':
        validmember = True
    else:
        for member in members:
            if (member.username == session.get('username')) :
                validmember=True
            else:
                validmember = False

    for image in selectedimages:

        if os.path.exists(f"static/Images/{image}") and validmember==True:
            print("Path Exist!!!")
            os.remove(f"static/Images/{image}")
            flash("Deleted Selected Images")
        else:
            flash("Error or You may not be member of Palghar Milers")
            print(message)
    image_names = os.listdir('static/images')
    return render_template("imagegallery.html", image_names=image_names)
Beispiel #2
0
def logout():
   # loggedingoogleuser=session.get('loggedingoogleuser')
    logout_user()
    session.pop('logged_in', None)
    print(session.get('username'))
 #   print(loggedingoogleuser)
    message = 'You were logged out of Palghar Milers.'
    print(session.get('googleuser'))
    if session.get('googleuser'):
        flash('Logout from Google')
    return render_template('logout.html', message=message)
Beispiel #3
0
def removemember():
    memberid = request.form.get("rmemberid")
    removemember=Member.query.get(memberid)
    print(removemember.username)
    print(session.get('username'))

    if removemember is None:
        return render_template("index.html", message="No Such Member.")
    if (removemember.username == session.get('username')) or (session.get('username')=='admin'):
        db.session.delete(removemember)
        db.session.commit()
        return render_template("index.html", message="Member Successfully Removed")
    flash("Cannot remove other members")
    return redirect('/members')
Beispiel #4
0
def forupdatemember():
    fname = request.form.get("updatefname")
    mname = request.form.get("updatemname")
    lname = request.form.get("updatelname")
    email = request.form.get("updateemail")
    mobile = request.form.get("updatemobile")
    dob = request.form.get("updatedob")
    strava_id = request.form.get("stravaid")
    try:
        member_id = int(request.form.get("updateid"))
    except ValueError:
        return render_template("index.html", message="Invalid member ID.")
    except TypeError:
        return render_template("index.html", message="No Changes Made!")

    if request.method == 'POST':
        file = request.files['file']
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.relpath(f"static/uploads/{filename}"))
            ff = f"static/uploads/{filename}"
            if os.path.exists(f'static/uploads/{member_id}.jpg'):
                os.remove(f'static/uploads/{member_id}.jpg')
            dd = f"static/uploads/{member_id}.jpg"
            os.rename(ff, dd)

    member = Member.query.get(member_id)
    member.firstname = fname
    member.middlename = mname
    member.lastname = lname
    member.email = email
    member.mobile = mobile
    member.dob = dob
    member.strava_id = strava_id
    print(f"uuuuu :{member.username}")
    print(session.get('username'))
    if (member.username == session.get('username')) or (session.get('username')
                                                        == 'admin'):
        db.session.commit()
    else:
        flash("Cannot update data of other members")
        return redirect('/members')
    db.session.commit()
    return render_template("memberdetails.html", member=member)