Skip to content

Commit 2f2d449

Browse files
author
hube
committed
Merge pull request HKCodeCamp#22 from hube/oauth
add user to db
2 parents 7eb90e2 + c89c00f commit 2f2d449

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

utils/database.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setup_db():
1414
con = sqlite3.connect('vocably.db')
1515

1616
with con:
17-
cur = con.cursor()
17+
cur = con.cursor()
1818

1919
cur.execute("SELECT * FROM sqlite_master WHERE type='table' AND name='Users';")
2020
rows = cur.fetchall()
@@ -68,7 +68,7 @@ def get_score(email):
6868
con = sqlite3.connect('vocably.db')
6969

7070
with con:
71-
cur = con.cursor()
71+
cur = con.cursor()
7272
query = 'SELECT score FROM Users WHERE email="'+email+'";'
7373
cur.execute(query)
7474
rows = cur.fetchall()
@@ -78,7 +78,7 @@ def store_user_words(email,words):
7878
con = sqlite3.connect('vocably.db')
7979

8080
with con:
81-
cur = con.cursor()
81+
cur = con.cursor()
8282

8383
for word in words:
8484
query = 'INSERT INTO Vocab VALUES("'
@@ -93,7 +93,7 @@ def wipe_db():
9393
if not os.path.isfile("vocably.db"):
9494
print "The database is not there to begin with!"
9595
return
96-
96+
9797
msg = "Are you 100% sure you want to wipe the database?\n"
9898
msg += "This will remote all data and is irreversible... (yes/no)\n"
9999
input_ = raw_input(msg).strip().lower()

utils/vocably.db

-6 KB
Binary file not shown.

vocably.db

24 KB
Binary file not shown.

vocably.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from bottle import route, run, debug, template, request, static_file, redirect
2-
from utils import vocably_oauth as oauth, score, definition
2+
from utils import vocably_oauth as oauth, score, definition, database
33

44
# Landing Page
55
@route('/')
@@ -10,7 +10,7 @@ def home():
1010
@route('/words')
1111
def words():
1212
# Get words for user
13-
# word_defs = get_word_defs()
13+
# word_defs = get_word_defs()
1414
# newwords = score.choose_words(oauth.user_email())
1515
newwords = ['grinder','helicopter','fab']
1616
word_defs = {w:definition.definition(w) for w in newwords}
@@ -36,6 +36,7 @@ def login_callback():
3636
else:
3737
print "Successfully acquired an authentication token"
3838
oauth.authorize(request.query.code)
39+
database.create_user(oauth.user_email(), 0)
3940
redirect('/emails')
4041

4142
@route('/emails')

0 commit comments

Comments
 (0)