Skip to content
Merged
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
11 changes: 10 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import base64

def create_pem_from_base64(base64_string, filename):
# if certificate already exists, return
if os.path.exists(filename):
return

decoded_data = base64.b64decode(base64_string)

# save to file
Expand All @@ -23,4 +27,9 @@ def create_pem_from_base64(base64_string, filename):
tls=True,
tlsCertificateKeyFile="certificate.pem")
else:
MONGO_CLIENT = pymongo.MongoClient(MONGO_URL)
if os.path.exists("certificate.pem"):
MONGO_CLIENT = pymongo.MongoClient(MONGO_URL,
tls=True,
tlsCertificateKeyFile="certificate.pem")
else:
MONGO_CLIENT = pymongo.MongoClient(MONGO_URL)
9 changes: 4 additions & 5 deletions task_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
import gspread
# import gspread
import re
from math import floor
import tasklists
Expand All @@ -25,7 +25,6 @@

'''


def get_user(username) -> UserDatabaseObject:
coll = mydb['taskAccounts']
users = list(coll.find({'username': username}))
Expand All @@ -34,8 +33,7 @@ def get_user(username) -> UserDatabaseObject:
old_user_data = users[0]
return convert_database_user(migrate_database_user_to_new_format(old_user_data))


# For new taskList data format - Replaces above after migration
# to replace above function after migration
def get_user_2(username) -> UserDatabaseObject:
coll = mydb['taskLists']
users = list(coll.find({'username': username}))
Expand Down Expand Up @@ -343,7 +341,7 @@ def complete_task_unofficial_tier(username: str, task_id: int, tier: str) -> dic
def complete_task(username: str) -> dict:
user = get_user(username)
task_check = user.current_task()

print(task_check)
if task_check is None:
return {}

Expand Down Expand Up @@ -1145,4 +1143,5 @@ def to_user(data):


if __name__ == "__main__":

pass
4 changes: 3 additions & 1 deletion taskapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tasklists
from task_database import (get_taskCurrent, generate_task, complete_task, get_task_progress,
get_task_lists, manual_complete_tasks, manual_revert_tasks,
import_spreadsheet, uncomplete_all_tasks, lms_status_change,
uncomplete_all_tasks, lms_status_change,
official_status_change, username_change, official_icon, unofficial_icon, get_taskCurrent_tier, generate_task_for_tier,
complete_task_unofficial_tier, get_user, get_leaderboard)
import send_grid_email
Expand Down Expand Up @@ -354,6 +354,8 @@ def login():

except Exception as e:
error = "An error occurred while processing your request, please try again."
print(e)
flash(error)
return render_template('loginV2.html')


Expand Down
Loading