Skip to content
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

Edit event #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DATABASE_HOST=localhost
DATABASE_PORT=3306
#Default Host is localhost with Port: 3306
DATABASE_USER=root
DATABASE_PASSWORD=Priyam@0911
DATABASE_PASSWORD=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
Binary file not shown.
2 changes: 1 addition & 1 deletion Make_Tables/createdatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
mycursor.execute("CREATE TABLE Coordinators(clubID char(6), userID char(6), FOREIGN KEY (userID) REFERENCES Users(userID), FOREIGN KEY (clubID) REFERENCES Clubs(clubID))")
print("Successfully Created Table Coordinators ") #To store who is the coordie of a group

mycursor.execute("CREATE TABLE Events(eventID Integer(4) PRIMARY KEY, eventName varchar(30), about varchar(600), eventDate date, clubID char(6), registered varchar(3000), attended varchar(3000), FOREIGN KEY (clubID) REFERENCES Clubs(clubID));")
mycursor.execute("CREATE TABLE Events(eventID Integer(6) AUTO_INCREMENT=1 PRIMARY KEY, eventName varchar(30), about varchar(600), eventDate date, eventTime time, eventVenue varchar(30), clubID char(6), registered varchar(3000), attended varchar(3000), FOREIGN KEY (clubID) REFERENCES Clubs(clubID));")
print("Successfully Created Events Table") #To store all the events

print("Done Creating Tables")
Expand Down
Binary file added __pycache__/forms.cpython-37.pyc
Binary file not shown.
42 changes: 41 additions & 1 deletion app.py
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,jsonify,request
from forms import LoginForm
from Make_Tables.mysqlconnect import mydb, mycursor, create_insert_statement #Imported the mysqlconnect.py file from Make_tables folder
import datetime

app=Flask(__name__,static_url_path='/public')
app.config['SECRET_KEY']='c828b6ff21f45063fd7860e5c1b1d233'
Expand All @@ -20,5 +21,44 @@ def Login():
flash('Login Unsuccessful. Invalid Email/Password')
return render_template('login.html',title='Login | SAC Portal, IIT Mandi',form=form)

@app.route("/add_event",methods=['POST']) #add a new event
def create_event():
data=request.get_json()
eventName=data["eventName"]
about=data["about"]
eventDate=data["eventDate"]
eventTime=data["eventTime"]
eventVenue=data["eventVenue"]
clubID=data["clubID"]
registered=data["registered"]
attended=data["attended"]
try:
mycursor.execute("INSERT INTO Events(eventName, about, eventDate, eventTime, eventVenue, clubID, registered, attended) VALUES('"+eventName+"','"+about+"','"+eventDate+"','"+eventTime+"','"+eventVenue+"','"+clubID+"','"+registered+"','"+attended+"')")
mydb.commit()
return "Event added successfully!"
except:
return "Check the clubID."

@app.route("/update_event/<clubID>/<eventID>") #update an existing event
def update_event(clubID,eventID):
data=request.get_json()
eventName=data["eventName"]
about=data["about"]
eventDate=data["eventDate"]
eventTime=data["eventTime"]
eventVenue=data["eventVenue"]
registered=data["registered"]
attended=data["attended"]
query1="UPDATE Events SET eventName='"+eventName+"', about='"+about+"', eventDate='"+eventDate+"', eventTime='"+eventTime+"', eventVenue='"+eventVenue+"', registered='"+registered+"', attended='"+attended+"' WHERE clubID ='"+clubID+ "'AND eventID='"+eventID+"'"
try:
mycursor.execute(query1)
mydb.commit()
return "Event updated successfully."
except:
return "Check the clubID and eventID."




if __name__=="__main__":
app.run(debug=True)