gunicorn \
flask \
schoolopy \
+ schedule \
cachecontrol \
google-auth \
google_auth_oauthlib
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"]
-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)}"
-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 (
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 = []
-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
group = Group(
api.get_group(GROUP_ID).title, api.get_group(GROUP_ID).description
)
+group.projects = database.read()
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))
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()
* {
color: #ffff82;
- background-color: black;
+ background-color: transparent;
text-align: center;
}
width: 100%;
height: 100%;
margin: 0;
- padding: 0;
+}
+
+body {
+ background-color: black;
}
#board {
#back {
color: white;
+ position: absolute;
+ padding-top: 8px;
}
#back.hidden {
* {
color: white;
- background-color: black;
+ background-color: transparent;
font-family: monospace;
+ font-size: 18px;
}
html, body {
}
body {
- padding: 8px;
-}
-
-input, textarea {
- color: black;
+ background-color: black;
}
center {
transform: translate(-50%, -50%);
position: absolute;
}
+
+#title {
+ font-size: 32px;
+}
+
+input, textarea {
+ color: black;
+}
+
{% 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 %}
{% macro head(group, subsection) -%}
<title>
- {{ group.name }} {% if subsection %} - {{ subsection }} {% endif %}
+ CSC {% if subsection %} - {{ subsection }} {% endif %}
</title>
-<link rel="icon" type="image/x-icon" href="{{ group.picture }}" />
{%- endmacro %}
{% macro stars(num) -%}
<style>
- #star {
+ .star {
position: absolute;
background-color: white !important;
width: 1px;
return [rw, rh];
}
- for (let i = 0; i < {{ num }}; i++) {
- let star = document.createElement("div");
- star.id = "star";
- var [w, h] = randomPosition();
- star.style.top = h + "px";
- star.style.left = w + "px";
- document.body.append(star);
+ function createStars() {
+ document.querySelectorAll(".star").forEach(element => element.remove());
+ for (let i = 0; i < {{ num }}; i++) {
+ let star = document.createElement("div");
+ star.className = "star";
+ var [w, h] = randomPosition();
+ star.style.top = h + "px";
+ star.style.left = w + "px";
+ document.body.append(star);
+ }
}
+ createStars();
+ window.onresize = createStars;
</script>
{%- endmacro %}
{% import "elements/space.html" as space %}
{{ space.stars(500) }}
<center>
- <h1>{{ group.name }}</h1>
+ <h1 id="title">{{ group.name }}</h1>
<p>{{ group.description }}</p>
{% import "elements/events.html" as events %}