def edit_page():
    uid = current_user.uid
    room = Classroom.from_uid(uid, db)
    classes = [
        {
            "name": c["name"],
            "id": c["id"],
            "webhook": (
                a.get_webhook_url() if (a := current_user.get_class(c["id"])) else ""
            ),
        }
        for c in room.get_courses()
    ]
예제 #2
0
def new_connection(uid, classId, webhookUrl, db):
    webhookId, webhookToken = clean_webhook_url(webhookUrl)

    regId, time = Classroom.from_uid(uid, db).register(classId)

    con = Connection(
        uid=uid,
        classId=classId,
        webhookId=webhookId,
        webhookToken=webhookToken,
        registration=regId,
        expire=parsetime(time),
    )
    db.add(con)
from datetime import datetime, timedelta
from sys import argv
from constants import parsetime

try:
    hrs_ahead = int(argv[1])
except IndexError:
    hrs_ahead = 6

hrs_behind = 2

app = Flask(__name__)
# with app.app_context():
#     create(app)
db = dbHelper(app)

now = datetime.utcnow()
time1 = now + timedelta(hours=hrs_ahead)
# time2 = now - timedelta(hours=hrs_behind)

with app.app_context():
    ls = db.find_connection_by_expire(end=time1)  # start=time2)

    for connection in ls:
        room = Classroom.from_uid(connection.uid, db)
        regId, expTime = room.register(courseId=connection.classId)
        connection.registration = regId
        connection.expire = parsetime(expTime)
        print(regId)

    db.commit_modification()