mirror of
https://github.com/Adam-Ant/QuotesDB
synced 2024-12-20 11:34:35 +00:00
Add logging for what user added which quotes
This commit is contained in:
parent
54afcfad1d
commit
75f96f74a7
@ -12,6 +12,7 @@ CREATE TABLE Quotes (
|
|||||||
date VARCHAR(255) NOT NULL,
|
date VARCHAR(255) NOT NULL,
|
||||||
user INT NOT NULL,
|
user INT NOT NULL,
|
||||||
context VARCHAR(8000),
|
context VARCHAR(8000),
|
||||||
|
addedby INT NOT NULL,
|
||||||
FOREIGN KEY (user) REFERENCES Users(uid)
|
FOREIGN KEY (user) REFERENCES Users(uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
4
main.py
4
main.py
@ -32,7 +32,7 @@ def mysql_do(query):
|
|||||||
def app_init():
|
def app_init():
|
||||||
# Check to make sure tables are set up properly
|
# Check to make sure tables are set up properly
|
||||||
mysql_do("CREATE TABLE IF NOT EXISTS Users ( uid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, user VARCHAR(255) NOT NULL UNIQUE, realname VARCHAR(255) NOT NULL, password VARCHAR(255), isadmin BIT NOT NULL);")
|
mysql_do("CREATE TABLE IF NOT EXISTS Users ( uid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, user VARCHAR(255) NOT NULL UNIQUE, realname VARCHAR(255) NOT NULL, password VARCHAR(255), isadmin BIT NOT NULL);")
|
||||||
mysql_do("CREATE TABLE IF NOT EXISTS Quotes ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, quote VARCHAR(2048) NOT NULL, date VARCHAR(255) NOT NULL, user INT NOT NULL, context VARCHAR(8000), FOREIGN KEY (user) REFERENCES Users(uid) );")
|
mysql_do("CREATE TABLE IF NOT EXISTS Quotes ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, quote VARCHAR(2048) NOT NULL, date VARCHAR(255) NOT NULL, user INT NOT NULL, context VARCHAR(8000), addedby INT NOT NULL, FOREIGN KEY (user) REFERENCES Users(uid) );")
|
||||||
|
|
||||||
# Generate random key for session cookies
|
# Generate random key for session cookies
|
||||||
app.secret_key = rand(24)
|
app.secret_key = rand(24)
|
||||||
@ -120,7 +120,7 @@ def addquote():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
sql = "INSERT INTO `Quotes` (`id`, `quote`, `date`, `user`, `context`) VALUES (NULL, '%s', CURRENT_TIMESTAMP, %d, %s);" % (quotein, userin, contextin)
|
sql = "INSERT INTO `Quotes` (`id`, `quote`, `date`, `user`, `context`, `addedby`) VALUES (NULL, '%s', CURRENT_TIMESTAMP, %d, %s, %s);" % (quotein, userin, contextin, session['uid'])
|
||||||
print(sql)
|
print(sql)
|
||||||
mysql_do(sql)
|
mysql_do(sql)
|
||||||
flash("Success! The entry was added to the database.","success")
|
flash("Success! The entry was added to the database.","success")
|
||||||
|
Loading…
Reference in New Issue
Block a user