From: Damian Myrda Date: Tue, 17 Sep 2024 23:34:14 +0000 (-0500) Subject: Complete remolding X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=efeb83ecfc76b7eb50e648efec78b7b0906b91bb;p=csc.git Complete remolding --- diff --git a/Dockerfile b/Dockerfile index fb0f002..ecc7d2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN pip install --no-cache-dir \ gunicorn \ flask \ schoolopy \ + schedule \ cachecontrol \ google-auth \ google_auth_oauthlib diff --git a/config.py b/config.py index 0fed17c..e5ad8b4 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,8 @@ import os -DOMAIN = "https://" + os.environ["DOMAIN"] +DOMAIN = os.environ["DOMAIN"] GROUP_ID = os.environ["GROUP_ID"] +SCHOOLOGY_DOMAIN = "https://" + os.environ["SCHOOLOGY_DOMAIN"] SCHOOLOGY_API_KEY = os.environ["SCHOOLOGY_API_KEY"] SCHOOLOGY_API_SECRET = os.environ["SCHOOLOGY_API_SECRET"] diff --git a/models/discussion.py b/models/discussion.py index cc3e9ff..d45fbd5 100644 --- a/models/discussion.py +++ b/models/discussion.py @@ -1,8 +1,8 @@ -from config import DOMAIN +from config import SCHOOLOGY_DOMAIN class Discussion: def __init__(self, id, name, description): self.name = name self.description = description - self.link = f"{DOMAIN}/discussion/{str(id)}" + self.link = f"{SCHOOLOGY_DOMAIN}/discussion/{str(id)}" diff --git a/models/event.py b/models/event.py index 7140c70..d941847 100644 --- a/models/event.py +++ b/models/event.py @@ -1,11 +1,11 @@ -from config import DOMAIN +from config import SCHOOLOGY_DOMAIN class Event: def __init__(self, id, name, description, start, end=None): self.name = name self.description = description - self.link = f"{DOMAIN}/event/{str(id)}" + self.link = f"{SCHOOLOGY_DOMAIN}/event/{str(id)}" self.start = start self.end = end if end and ( diff --git a/models/group.py b/models/group.py index 24a070d..59b5e3a 100644 --- a/models/group.py +++ b/models/group.py @@ -2,7 +2,6 @@ class Group: def __init__(self, name, description): self.name = name self.description = description - self.picture = "https://www.shutterstock.com/image-vector/computer-science-icon-outline-thin-600nw-1613513884.jpg" self.events = [] self.updates = [] diff --git a/schoology.py b/schoology.py index 9525f12..21de793 100644 --- a/schoology.py +++ b/schoology.py @@ -1,14 +1,22 @@ -from config import DOMAIN, GROUP_ID, SCHOOLOGY_API_KEY, SCHOOLOGY_API_SECRET +from config import ( + GROUP_ID, + SCHOOLOGY_DOMAIN, + SCHOOLOGY_API_KEY, + SCHOOLOGY_API_SECRET, +) from datetime import datetime from models import Group, Event, Update, Discussion, Member from schoolopy import Schoology, Auth from database import database +import schedule +import time +from threading import Thread auth = Auth( SCHOOLOGY_API_KEY, SCHOOLOGY_API_SECRET, - domain=DOMAIN, + domain=SCHOOLOGY_DOMAIN, ) api = Schoology(auth) api.limit = 64 @@ -16,6 +24,7 @@ api.limit = 64 group = Group( api.get_group(GROUP_ID).title, api.get_group(GROUP_ID).description ) +group.projects = database.read() def get_members(): @@ -27,19 +36,10 @@ def get_members(): group.members.append(member) -def find_member(name): - for member in group.members: - if member.name == name: - return member - return None - - def get_updates(): for update in api.get_group_updates(GROUP_ID): user = api.get_user(update.uid) - member = find_member(user.name_display) - if not member: - continue + member = Member(user.name_display) created = datetime.utcfromtimestamp(int(update.created)) group.updates.append(Update(member, update.body, created)) @@ -66,7 +66,17 @@ def update(): get_updates() get_events() get_discussions() - group.projects = database.read() update() +schedule.every().hour.do(update) + + +def run(): + while True: + schedule.run_pending() + time.sleep(1 * 60) + + +scheduler = Thread(target=run, daemon=True) +scheduler.start() diff --git a/static/intro.css b/static/intro.css index 8cbd128..6774b31 100644 --- a/static/intro.css +++ b/static/intro.css @@ -1,6 +1,6 @@ * { color: #ffff82; - background-color: black; + background-color: transparent; text-align: center; } @@ -8,7 +8,10 @@ html, body { width: 100%; height: 100%; margin: 0; - padding: 0; +} + +body { + background-color: black; } #board { @@ -53,6 +56,8 @@ html, body { #back { color: white; + position: absolute; + padding-top: 8px; } #back.hidden { diff --git a/static/main.css b/static/main.css index 828e370..388220c 100644 --- a/static/main.css +++ b/static/main.css @@ -1,7 +1,8 @@ * { color: white; - background-color: black; + background-color: transparent; font-family: monospace; + font-size: 18px; } html, body { @@ -11,11 +12,7 @@ html, body { } body { - padding: 8px; -} - -input, textarea { - color: black; + background-color: black; } center { @@ -24,3 +21,12 @@ center { transform: translate(-50%, -50%); position: absolute; } + +#title { + font-size: 32px; +} + +input, textarea { + color: black; +} + diff --git a/templates/elements/datetime.html b/templates/elements/datetime.html index a913bcd..66a42e7 100644 --- a/templates/elements/datetime.html +++ b/templates/elements/datetime.html @@ -1,7 +1,7 @@ {% macro time(time) -%} -{{ time.hour }}:{{ time.minute }} +{{ "{:02}:{:02}".format(time.hour, time.minute) }} {%- endmacro %} {% macro date(date) -%} -{{ date.year }}.{{ date.month }}.{{ date.day }} +{{ "{:04}.{:02}.{:02}".format(date.year, date.month, date.day) }} {%-endmacro %} diff --git a/templates/elements/metadata.html b/templates/elements/metadata.html index 2b9d0a0..5a1292e 100644 --- a/templates/elements/metadata.html +++ b/templates/elements/metadata.html @@ -1,6 +1,5 @@ {% macro head(group, subsection) -%} - {{ group.name }} {% if subsection %} - {{ subsection }} {% endif %} + CSC {% if subsection %} - {{ subsection }} {% endif %} - {%- endmacro %} diff --git a/templates/elements/space.html b/templates/elements/space.html index 83deaf0..900ceb9 100644 --- a/templates/elements/space.html +++ b/templates/elements/space.html @@ -1,6 +1,6 @@ {% macro stars(num) -%}