2024-10-07 15:17:24 -04:00
|
|
|
import data
|
2024-10-09 17:03:32 -04:00
|
|
|
import requests
|
2024-10-07 15:17:24 -04:00
|
|
|
|
|
|
|
|
db = data.CON
|
|
|
|
|
cur = db.cursor()
|
|
|
|
|
|
|
|
|
|
|
2024-10-09 17:03:32 -04:00
|
|
|
class Utils:
|
2024-10-07 15:17:24 -04:00
|
|
|
def __init__():
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def get_unique_people():
|
2024-10-09 17:03:32 -04:00
|
|
|
data = cur.execute("select distinct person from tasks;")
|
2024-10-07 15:17:24 -04:00
|
|
|
ppl = data.fetchall()
|
|
|
|
|
return ppl
|
|
|
|
|
|
|
|
|
|
def get_specific_person(person):
|
2024-10-09 17:03:32 -04:00
|
|
|
res = cur.execute(
|
|
|
|
|
f"select verse,verse_passage,status from tasks where person='{person.value}'"
|
|
|
|
|
)
|
2024-10-07 15:17:24 -04:00
|
|
|
dbinfo = res.fetchall()
|
|
|
|
|
return dbinfo
|
|
|
|
|
|
|
|
|
|
def toggle_completion(verse, person, status):
|
2024-10-09 17:03:32 -04:00
|
|
|
cur.execute(
|
|
|
|
|
f"update tasks set status = '{status}' where person = '{person.value}' and verse = '{verse}'"
|
|
|
|
|
)
|
2024-10-07 15:17:24 -04:00
|
|
|
db.commit()
|
2024-10-07 18:14:27 -04:00
|
|
|
|
|
|
|
|
def get_persons_incomplete(person):
|
2024-10-09 17:03:32 -04:00
|
|
|
inc = cur.execute(
|
|
|
|
|
f"select person, verse, verse_passage, club from tasks where status = '0' and person = '{person}'"
|
|
|
|
|
)
|
2024-10-07 18:14:27 -04:00
|
|
|
incret = inc.fetchall()
|
|
|
|
|
return incret
|
|
|
|
|
|
2024-10-09 17:03:32 -04:00
|
|
|
def add_verse(person, verse, passage):
|
|
|
|
|
club = cur.execute(
|
|
|
|
|
f"select distinct club from tasks where person = '{person.value}'"
|
|
|
|
|
)
|
|
|
|
|
clubstring = club.fetchone()
|
|
|
|
|
clubstring = "".join(clubstring)
|
|
|
|
|
cur.execute(
|
|
|
|
|
f"replace into tasks (person, verse, verse_passage, status, club) values('{person.value}', '{verse.value}', '{passage}', '0', '{clubstring}');"
|
|
|
|
|
)
|
|
|
|
|
db.commit()
|
|
|
|
|
|
2024-10-08 17:35:04 -04:00
|
|
|
def edit_verse(person, verse, passage):
|
2024-10-09 17:03:32 -04:00
|
|
|
passage = passage.value.replace("'", '"')
|
|
|
|
|
cur.execute(
|
|
|
|
|
f"update tasks set verse_passage = '{passage}' where person = '{person.value}' and verse = '{verse}'"
|
|
|
|
|
)
|
2024-10-08 17:35:04 -04:00
|
|
|
db.commit()
|
|
|
|
|
|
2024-10-09 17:03:32 -04:00
|
|
|
def add_person(person, club):
|
|
|
|
|
cur.execute(
|
|
|
|
|
f"insert into tasks(person, club) values ('{person.value}', '{club.value}')"
|
|
|
|
|
)
|
2024-10-08 17:35:04 -04:00
|
|
|
db.commit()
|
|
|
|
|
|
|
|
|
|
def delete_verse(verse, person):
|
2024-10-09 17:03:32 -04:00
|
|
|
cur.execute(
|
|
|
|
|
f"delete from tasks where person = '{person.value}' and verse = '{verse}'"
|
|
|
|
|
)
|
2024-10-07 18:14:27 -04:00
|
|
|
db.commit()
|