Beispiel #1
0
def students(class_slug):
    teacher = authorize_teacher(request)
    klass = TeachersRepo.get_class(teacher.id, class_slug)
    return jsonify({
        "students": [s.to_dict() for s in klass.students],
        "klass": klass.to_dict()
    })
Beispiel #2
0
def create():
    username, password = request.json.get("username"), request.json.get(
        "password")
    teacher = TeachersRepo.create_teacher(username, password)
    response = jsonify({"teacher": teacher.to_dict()})
    enhance_response_with_teacher_auth(response, teacher)
    return response
Beispiel #3
0
def login():
    body = request.json
    username, password = body.get("username"), body.get("password")
    teacher = TeachersRepo.find_teacher_by_username_password(
        username, password)
    response = jsonify({"teacher": teacher.to_dict()})
    enhance_response_with_teacher_auth(response, teacher)
    return response
Beispiel #4
0
def teacher_login():
    auth_token = request.args.get("pw")
    teacher = TeachersRepo.find_teacher_by_auth(auth_token)
    if not teacher:
        return abort(400)
    res = redirect("/classes")
    enhance_response_with_teacher_auth(res, teacher)
    return res
Beispiel #5
0
def authorize_student_or_teacher(request):
    student_auth = request.cookies.get("student")
    student = StudentRepo.get_student_by_auth(student_auth)
    if student:
        return student, None
    teacher_auth = request.cookies.get("teacher")
    teacher = TeachersRepo.find_teacher_by_auth(teacher_auth)
    if teacher:
        return None, teacher
    raise Exception("Cant find student :(")
Beispiel #6
0
def login():
    content = request.json
    username = content.get("username")
    password = content.get("password")
    teacher = TeachersRepo.find_teacher_by_username_password(
        username, password)
    if not teacher:
        return jsonify("Not found"), 404
    response = jsonify({"teacher": teacher.to_dict()})
    enhance_response_with_teacher_auth(response, teacher)
    return response
Beispiel #7
0
import random
from datetime import date, datetime, timedelta

from app import db
from models import Teacher, Klass, Student, Vote
from repos.teachers_repo import TeachersRepo

k = Klass(title="Test Class 1")
db.session.add(k)
db.session.commit()
t = TeachersRepo.create_teacher(username="******", password="******")
k.teacher_id = t.id

names = """Teddie Manning
Teegan Mitchell
Chanel Coles
Robert Escobar
Allegra Hancock
Eben Thomas
Zayne Lamb
Liana Nelson
Sian Byrne
Rhiannon Storey""".split("\n")

pictures = """jrn8thz2tfxmchwahyr1.png
mle6mcgbuhq7ueofxgtf.png
hy4fqnlgmdcvdpx481up.png
kmsrmi26hix2vm3t0hem.png
a0iumvhijg90vigzqzyq.png
mug41ae0g93lm8ad0vnh.png
tldkubag7qnp6gipgfja.png
Beispiel #8
0
def authorize_teacher(request):
    teacher_auth = request.cookies.get("teacher")
    return TeachersRepo.find_teacher_by_auth(teacher_auth)