-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcake.py
More file actions
32 lines (28 loc) · 772 Bytes
/
cake.py
File metadata and controls
32 lines (28 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# cake.py
"""
Cake functions
"""
from flask import request, session
from database import check_user_is_verified as check_is_verified, check_cake, red_cake, ad_cake
def append_cake(cakeId: int) -> None:
"""Add cakes"""
try:
if session['cakeList']:
# nothing to be done
pass
except:
session['cakeList'] = []
if check_is_verified(session['accessToken']) and check_cake(cakeId):
cakes = list(session['cakeList'])
cakes.append(cakeId)
session['cakeList'] = cakes
red_cake(cakeId)
def rm_cake(cakeId: int) -> None:
"""Remove cakes"""
if check_is_verified(session['accessToken']) and check_cake(cakeId):
cakes = list(session['cakeList'])
ind = cakes.index(cakeId)
if ind >= 0:
cakes.pop(ind)
session['cakeList'] = cakes
ad_cake(cakeId)