-
Notifications
You must be signed in to change notification settings - Fork 17
API: Leave Group issue solving #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from flask import url_for,render_template,redirect,Flask,flash | ||
| from flask import url_for,render_template,redirect,Flask,flash, request, jsonify | ||
| from forms import LoginForm | ||
| from Make_Tables.mysqlconnect import mydb, mycursor, create_insert_statement #Imported the mysqlconnect.py file from Make_tables folder | ||
| from Make_Tables.mysqlconnect import mydb, mycursor, create_insert_statement, sqlerror #Imported the mysqlconnect.py file from Make_tables folder | ||
| #use sqlerror to track errors in mysql databases | ||
|
|
||
| app=Flask(__name__,static_url_path='/public') | ||
| app.config['SECRET_KEY']='c828b6ff21f45063fd7860e5c1b1d233' | ||
|
|
@@ -20,5 +21,28 @@ def Login(): | |
| flash('Login Unsuccessful. Invalid Email/Password') | ||
| return render_template('login.html',title='Login | SAC Portal, IIT Mandi',form=form) | ||
|
|
||
| #Example https://host/leaveclub?userID='B19188'&clubID='C10001' | ||
| @app.route('/leaveclub', methods = ['POST']) | ||
| def leave_club(): | ||
| data = { | ||
| "tablename" : "ClubMembers", | ||
| "userID" : request.args.get('userID'), | ||
|
||
| "clubID" : request.args.get('clubID') | ||
| } | ||
| stmt = "DELETE FROM ClubMembers WHERE userID='"+data["userID"]+"' and clubID='"+data["clubID"]+"';" | ||
| #print(stmt) | ||
| success = 0;msg='' | ||
| try: | ||
| mycursor.execute(stmt) | ||
| mydb.commit() | ||
| success=1 | ||
| msg = "Deleted" | ||
| except sqlerror as err: | ||
| success=0 | ||
| msg = str(err) | ||
|
|
||
| return(jsonify(success=success,msg=msg)) | ||
|
|
||
|
|
||
| if __name__=="__main__": | ||
| app.run(debug=True) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this comment. @vsvipul @Milind712000 what do you think about this?
Guard this function to check whether the user is logged in. If the user is logged in we don't need to store the userid.
If you are thinking about admin functionalities, we can have a different function for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done, understood.
I will do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will only take the clubID in the body, and take the userID from the session.