Some good progresspython main.py Started the edit verse functionality. The cards on dashboard now pull dynamically based on the users in the db. Will need to add 'start up' functions that allow you to input your children so everything is scalable. Need to look into auth too.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/awana-clubs.png
Normal file
BIN
assets/awana-clubs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
28
dashboard (conflicted copy 2024-10-07 175852).py
Normal file
28
dashboard (conflicted copy 2024-10-07 175852).py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import theme
|
||||||
|
from nicegui import ui
|
||||||
|
from main import checked_data
|
||||||
|
import data
|
||||||
|
from utils import Utils
|
||||||
|
|
||||||
|
print(theme.tnt)
|
||||||
|
|
||||||
|
@ui.page('/dashboard')
|
||||||
|
def dashboard():
|
||||||
|
with theme.frame('Dashboard'):
|
||||||
|
pass
|
||||||
|
|
||||||
|
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'):
|
||||||
|
peoples = Utils.get_unique_people()
|
||||||
|
for ppl in peoples:
|
||||||
|
pl = ''.join(ppl)
|
||||||
|
card_info = Utils.get_persons_incomplete(pl)
|
||||||
|
for item in card_info:
|
||||||
|
vcard = ui.label(item[1]).classes('hidden')
|
||||||
|
pcard = ui.label(item[2]).classes('hidden')
|
||||||
|
club = ui.label(item[3]).classes('hidden')
|
||||||
|
clubcolor = ui.label(f'{theme.club.text}')
|
||||||
|
with ui.card().classes('grid justify-items-center').style(f'border: 2px solid {clubcolor.text}'):
|
||||||
|
ui.label(pl).classes('absolute top-0 left-0 font-thin text-sm')
|
||||||
|
ui.label(vcard.text).classes('text-center')
|
||||||
|
ui.label(pcard.text).classes('font-bold')
|
||||||
|
|
||||||
40
dashboard.py
40
dashboard.py
@ -2,36 +2,26 @@ import theme
|
|||||||
from nicegui import ui
|
from nicegui import ui
|
||||||
from main import checked_data
|
from main import checked_data
|
||||||
import data
|
import data
|
||||||
|
from utils import Utils
|
||||||
|
|
||||||
db = data.CON
|
color = {'tnt': theme.tnt, 'cubbies': theme.cubbies, 'sparks': theme.sparks}
|
||||||
cur = db.cursor()
|
|
||||||
|
|
||||||
@ui.page('/dashboard')
|
@ui.page('/dashboard')
|
||||||
def dashboard():
|
def dashboard():
|
||||||
with theme.frame('Dashboard'):
|
with theme.frame('Dashboard'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'): #(columns='auto 99px 1fr 2fr').classes('w-full gap-3'):
|
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'):
|
||||||
res = cur.execute(f"select person,verse,verse_passage,status from tasks where status = '0'")
|
peoples = Utils.get_unique_people()
|
||||||
information = res.fetchall()
|
for ppl in peoples:
|
||||||
for info in information:
|
pl = ''.join(ppl)
|
||||||
if info[0] == 'hannah':
|
card_info = Utils.get_persons_incomplete(pl)
|
||||||
hvc = ui.label(info[1]).classes('hidden')
|
for item in card_info:
|
||||||
hpc = ui.label(info[2]).classes('hidden')
|
vcard = ui.label(item[1]).classes('hidden')
|
||||||
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(0, 255, 0, .25)'):
|
pcard = ui.label(item[2]).classes('hidden')
|
||||||
ui.label('Hannah').classes('absolute top-0 left-0 font-thin text-sm')
|
club = ui.label(item[3]).classes('hidden')
|
||||||
ui.label(hvc.text).classes('text-center')
|
with ui.card().classes('grid justify-items-center').style(f'border: 2px solid {color[club.text.lower()]}'):
|
||||||
ui.label(hpc.text).classes('font-bold')
|
ui.label(pl).classes('absolute top-0 left-0 font-thin text-sm')
|
||||||
elif info[0] == 'fiona':
|
ui.label(vcard.text).classes('text-center')
|
||||||
fvc = ui.label(info[1]).classes('hidden')
|
ui.label(pcard.text).classes('font-bold')
|
||||||
fpc = ui.label(info[2]).classes('hidden')
|
|
||||||
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(255, 55, 0, .25)'):
|
|
||||||
ui.label(fvc.text).classes('text-center')
|
|
||||||
ui.label(fpc.text).classes('font-bold')
|
|
||||||
else:
|
|
||||||
lvc = ui.label(info[1]).classes('hidden')
|
|
||||||
lpc = ui.label(info[2]).classes('hidden')
|
|
||||||
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(0, 0, 255, .25)'):
|
|
||||||
ui.label(lvc.text).classes('text-center')
|
|
||||||
ui.label(lpc.text).classes('font-bold')
|
|
||||||
|
|
||||||
|
|||||||
29
main.py
29
main.py
@ -16,7 +16,9 @@ HEADERS = { 'Authorization': APIKEY}
|
|||||||
def index_page() -> None:
|
def index_page() -> None:
|
||||||
with theme.frame('Homepage'):
|
with theme.frame('Homepage'):
|
||||||
with ui.dialog().props('persistent') as addverse:
|
with ui.dialog().props('persistent') as addverse:
|
||||||
pass
|
pass
|
||||||
|
with ui.dialog().props('persistent') as editverse:
|
||||||
|
pass
|
||||||
|
|
||||||
with ui.grid(columns=1).classes('self-center justify-items-center content-center p-2 m-2 rounded-xl'):
|
with ui.grid(columns=1).classes('self-center justify-items-center content-center p-2 m-2 rounded-xl'):
|
||||||
users = Utils.get_unique_people()
|
users = Utils.get_unique_people()
|
||||||
@ -60,10 +62,10 @@ def index_page() -> None:
|
|||||||
label_verse = ui.label(text=item[0]).classes('hidden')
|
label_verse = ui.label(text=item[0]).classes('hidden')
|
||||||
label_passage = ui.label(text=item[1]).classes('hidden')
|
label_passage = ui.label(text=item[1]).classes('hidden')
|
||||||
label_status = ui.label(text=item[2]).classes('hidden')
|
label_status = ui.label(text=item[2]).classes('hidden')
|
||||||
ui.label(label_verse.text).classes('font-bold')
|
ui.label(label_verse.text).classes('font-bold text-center')
|
||||||
with ui.row():
|
with ui.row():
|
||||||
ui.label(label_passage.text).classes('text-wrap')
|
ui.label(label_passage.text).classes('text-wrap')
|
||||||
ui.chip("Edit Verse", selectable=True, icon="edit", color="white", on_selection_change=lambda label_verse=label_verse: edit_verse(label_verse.text))
|
ui.chip("Edit Verse", selectable=True, icon="edit", color="white", on_selection_change=lambda label_verse=label_verse: edit_verse(label_verse.text, person, label_passage.text))
|
||||||
if label_status.text == '1':
|
if label_status.text == '1':
|
||||||
ui.chip('Complete',
|
ui.chip('Complete',
|
||||||
selectable=True, icon="add", color="positive",
|
selectable=True, icon="add", color="positive",
|
||||||
@ -79,20 +81,17 @@ def index_page() -> None:
|
|||||||
ui.separator().classes('col-span-5 h-2')
|
ui.separator().classes('col-span-5 h-2')
|
||||||
else:
|
else:
|
||||||
showperson.clear()
|
showperson.clear()
|
||||||
|
addverse.close()
|
||||||
|
|
||||||
def edit_verse(verse):
|
def edit_verse(verse, person, passage):
|
||||||
ui.notify(f"Edit Verse function is running for {verse}")
|
editverse.open()
|
||||||
|
with editverse:
|
||||||
# def toggle_completion(verse, person, status):
|
with ui.card().classes('flex-wrap items-center'):
|
||||||
# ins = cur.execute(f"update tasks set status = '{status}' where person = '{person.value.lower()}' and verse = '{verse}'")
|
editing = ui.textarea(label="Edit Below", placeholder=passage)
|
||||||
# print(f"update tasks set status = '{status}' where person = '{person.value.lower()}' and verse = '{verse}'")
|
with ui.row().classes('justify-content-center'):
|
||||||
# db.commit()
|
ui.button().props('push glossy icon=add_circle color=secondary').on('click', lambda: submit_verse(result, person))
|
||||||
# show_person.refresh
|
|
||||||
# show_person(person)
|
|
||||||
|
|
||||||
|
|
||||||
def add_verse(person):
|
def add_verse(person):
|
||||||
# TODO: Add check of existing verses so that a user can't add duplicates.
|
|
||||||
if person.value is None:
|
if person.value is None:
|
||||||
ui.notify("Oops! You haven't selected a person")
|
ui.notify("Oops! You haven't selected a person")
|
||||||
else:
|
else:
|
||||||
@ -114,7 +113,7 @@ def index_page() -> None:
|
|||||||
# Verify the format of a Bible Verse
|
# Verify the format of a Bible Verse
|
||||||
if not re.match(r'((^\d\s\w{1,}\s|^\w{1,}\s)(\d{1,2}:)(\d{1,2}-\d{1,2}|\d{1,2}))', result.value):
|
if not re.match(r'((^\d\s\w{1,}\s|^\w{1,}\s)(\d{1,2}:)(\d{1,2}-\d{1,2}|\d{1,2}))', result.value):
|
||||||
ui.notify("Verse was input incorrectly.")
|
ui.notify("Verse was input incorrectly.")
|
||||||
addverse.clear()
|
addverse.close()
|
||||||
else:
|
else:
|
||||||
# Split up the string for later
|
# Split up the string for later
|
||||||
colon = result.value.split(':')
|
colon = result.value.split(':')
|
||||||
|
|||||||
Binary file not shown.
9
theme.py
9
theme.py
@ -1,12 +1,17 @@
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from nicegui import ui
|
from nicegui import ui
|
||||||
|
|
||||||
|
#Club Colors
|
||||||
|
tnt='rgba(30, 206, 0, 0.25)'
|
||||||
|
cubbies='rgba(25, 39, 255, 0.25)'
|
||||||
|
sparks='rgba(255, 0, 0, 0.25)'
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def frame(navigation_title: str):
|
def frame(navigation_title: str):
|
||||||
"""Custom page frame to share the same styling and behavior across all pages"""
|
"""Custom page frame to share the same styling and behavior across all pages"""
|
||||||
ui.colors(primary='#023047', secondary='#219ebc', accent='#8ecae6', positive='#ffb703', negative='#fb8500')
|
ui.colors(primary='#023047', secondary='#219ebc', accent='#8ecae6', positive='#ffb703', negative='#fb8500', header="#abb8c3", tnt='rgba(30, 206, 0, 0.25)', cubbies='rgba(25, 39, 255, 0.25)', sparks='rgba(255, 0, 0, 0.25)')
|
||||||
with ui.header():
|
with ui.header().style('background-color: #abb8c3'):
|
||||||
|
ui.image('./assets/awana-clubs.png').classes('w-16')
|
||||||
ui.label('Awana Verse Practice').classes('font-bold font-16')
|
ui.label('Awana Verse Practice').classes('font-bold font-16')
|
||||||
ui.space()
|
ui.space()
|
||||||
ui.space()
|
ui.space()
|
||||||
|
|||||||
9
utils.py
9
utils.py
@ -21,3 +21,12 @@ class Utils():
|
|||||||
def toggle_completion(verse, person, status):
|
def toggle_completion(verse, person, status):
|
||||||
ins = cur.execute(f"update tasks set status = '{status}' where person = '{person.value}' and verse = '{verse}'")
|
ins = cur.execute(f"update tasks set status = '{status}' where person = '{person.value}' and verse = '{verse}'")
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
def get_persons_incomplete(person):
|
||||||
|
inc = cur.execute(f"select person, verse, verse_passage, club from tasks where status = '0' and person = '{person}'")
|
||||||
|
incret = inc.fetchall()
|
||||||
|
return incret
|
||||||
|
|
||||||
|
def edit_verse(person, verse):
|
||||||
|
vedit = cur.execute(f"update tasks set verse_passage = '{verse_text}' where person = '{person.value} and verse = '{verse}'")
|
||||||
|
db.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user