Exemple #1
0
def organizations():
	org_id = request.args.get("id")
	email = session["webex_brada_persondetails"].get("emails")[0]
	if(org_id == None):
		organizations = db.get_organization(email=email)
		return render_template("admin.html", email=email, orgs=organizations, message="please specify an org id")
	org = db.get_organization(org_id=org_id)
	students = db.get_all_students(org_id)
	staff = db.get_all_staff(org_id)
	return render_template("organization.html", email=email, org=org[0], students=students, staff=staff)
Exemple #2
0
def new_org_form():
	orgname = request.form.get("orgname")
	username = request.form.get("username")
	email = session["webex_brada_persondetails"].get("emails")[0]
	if((orgname == "") or (username == "")):
		return render_template("admin.html", createresponse="organization name and username cannot be blank.", orgs=db.get_organization(email=email))
	if(len(db.get_organization(username=username)) > 0):
		return render_template("admin.html", createresponse="An organization with that username already exists.", orgs=db.get_organization(email=email))
	access_token = session["webex_brada_accesstoken"].get("access_token")
	wc = wu.WebexConnector(access_token)
	team_id = wc.create_team("Teaching Staff: " + orgname)
	lobby_id = wc.create_room("Class Forum: " + orgname, team_id=team_id)
	db.create_organization(orgname, email, username, team_id=team_id, lobby_id=lobby_id)
	return render_template("admin.html", message="successful", orgs=db.get_organization(email=email))
Exemple #3
0
def staff():
	if(session.get("webex_brada_persondetails") == None):
		return render_template("index.html", message="you must complete the oauth first")
	email = session.get("webex_brada_persondetails").get("emails")[0]
	if(email == None):
		return render_template("index.html", message="email not configured")
	session["webex_brada_userdata"] = db.get_staff(email=email)
	if(session["webex_brada_userdata"] == False):
		return render_template("home.html", message="unrecognized staff")
	print(session["webex_brada_userdata"])
	all_orgs = []
	for org in session["webex_brada_userdata"]:
		org_id = org["org_id"]
		organization = db.get_organization(org_id=org_id)
		print(organization)
		if(len(organization) == 0):
			print("no org")
			continue
		team_id = organization[0][4]
		orgname = organization[0][1]
		lobby = organization[0][5]
		if(team_id == ""):
			print("no team id")
			continue
		wc = wu.WebexConnector(session["webex_brada_accesstoken"].get("access_token"))
		rooms = wc.get_all_rooms(team_id)
		rooms = [(room["id"], room["title"]) for room in rooms]
		all_orgs.append((org_id,orgname,lobby,team_id, rooms))
	access_token = session["webex_brada_accesstoken"].get("access_token")
	return render_template("staff.html", data=session["webex_brada_userdata"], orgs=all_orgs, access_token=access_token)
Exemple #4
0
def upload_staff():
	org_id = request.form.get("org_id")
	org = db.get_organization(org_id=org_id)[0]
	if('file' not in request.files):
		return return_org_template(org_id,message="no file specifed")
	file = request.files['file']
	if(len(file.filename.strip()) == 0):
		return return_org_template(org_id,message="no file specifed")
	file.save("data/" + file.filename)
	access_token = session["webex_brada_accesstoken"].get("access_token")
	wc = wu.WebexConnector(access_token)
	staff = pu.read_file("data/" + file.filename)
	for member in staff:
		member["org_id"] = org_id
	students = db.get_all_students(org_id)
	wc.students = students
	wc.staff = staff
	wc.team_id = org[4]
	wc.lobby_id = org[5]
	wc.update_staff_members(wc.staff)
	wc.add_members_to_team(wc.staff, wc.team_id)
	wc.setup_new_tas(wc.staff)
	print(wc.staff)
	db.insert_staff(wc.staff, org_id)
	db.update_staff(wc.staff, "id", "person_id")
	return return_org_template(org_id,message="successfully updated")
Exemple #5
0
def upload_students():
	org_id = request.form.get("org_id")
	org = db.get_organization(org_id=org_id)[0]
	if('file' not in request.files):
		return return_org_template(org_id,message="no file specifed")
	file = request.files['file']
	if(len(file.filename.strip()) == 0):
		return return_org_template(org_id,message="no file specifed")
	file.save("data/" + file.filename)
	access_token = session["webex_brada_accesstoken"].get("access_token")
	wc = wu.WebexConnector(access_token)
	students = pu.read_file("data/" + file.filename)
	for student in students:
		student["org_id"] = org_id
	staff = db.get_all_staff(org_id)
	wc.students = students
	wc.staff = staff
	wc.team_id = org[4]
	lobby_id = org[5]
	if(lobby_id == ""):
		lobby_id = None
	wc.update_student_members(wc.students)
	wc.create_student_rooms(lobby_id=lobby_id)
	db.insert_students(wc.students, org_id)
	db.update_students(wc.students, "staff_room", "room_id")
	db.update_students(wc.students, "id", "person_id")
	return return_org_template(org_id,message="successfully updated")
Exemple #6
0
def admin():
	try:
		email = session["webex_brada_persondetails"].get("emails")[0]
	except:
		return render_template("index.html", message="not properly loggedin")
	organizations = db.get_organization(email=email)
	print(organizations)
	return render_template("admin.html", email=email, orgs=organizations)
Exemple #7
0
def admin_login():
	email = request.form.get("email")
	password = request.form.get("password")
	rows = db.get_organization(email)
	if(len(rows) == 0):
		return render_template("login.html", message="no such email registered")
	if(rows[0]["admin_password"] != password):
		return render_template("login.html", message="invalid password")
	session["webex_brada_usertype"] = "admin"
	session["webex_brada_userdata"] = rows[0]
	return render_template("admin.html",data=rows[0])
Exemple #8
0
def student():
	if(session.get("webex_brada_persondetails") == None):
		return render_template("index.html", message="you must complete the oauth first")
	email = session.get("webex_brada_persondetails").get("emails")[0]
	if(email == None):
		return render_template("index.html", message="email not configured")
	session["webex_brada_userdata"] = db.get_student(email=email)
	if(session["webex_brada_userdata"] == False):
		return render_template("home.html", message="unrecognized student")
	all_orgs = []
	for studentorg in session["webex_brada_userdata"]:
		room_id = studentorg.get("staff_room")
		org_id = studentorg.get("org_id")
		organization = db.get_organization(org_id=studentorg["org_id"])
		if(len(organization) == 0):
			print("no org")
			continue
		lobby_id = organization[0][5]
		org_name = organization[0][1]
		all_orgs.append((org_id, org_name, room_id, lobby_id))
	print(all_orgs)
	access_token = session["webex_brada_accesstoken"].get("access_token")
	return render_template("student.html", orgs=all_orgs, access_token = access_token)
Exemple #9
0
def return_org_template(org_id, message):
	org = db.get_organization(org_id=org_id)
	email = session["webex_brada_persondetails"].get("emails")[0]
	students = db.get_all_students(org_id)
	staff = db.get_all_staff(org_id)
	return render_template("organization.html", email=email, org=org[0], students=students, staff=staff, message=message)