Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin api routes #166

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6ca4b7d
Non-existent courses now return a 404, as opposed to error-ing the se…
ananthm3 Jan 25, 2024
899a187
Updated .gitignore
ananthm3 Feb 4, 2024
5a8237f
Recached files
ananthm3 Feb 4, 2024
1f4e201
Merge branch 'master' of github.com:illinois-cs241/broadway-on-demand
ananthm3 Feb 4, 2024
67c5552
Updated on-demand admin to handle API requests
ananthm3 Feb 5, 2024
72fca37
Changed API routes to be more consistent with existing ones
ananthm3 Feb 7, 2024
1c24a55
Added API to add multiple extensions at once
ananthm3 Feb 7, 2024
91ae4f2
Added api to schedule runs
ananthm3 Feb 17, 2024
ca10e46
Merge branch 'master' of github.com:illinois-cs241/broadway-on-demand…
ananthm3 Feb 17, 2024
e2870f9
Merge branch 'admin-api-routes' of github.com:illinois-cs241/broadway…
ananthm3 Feb 17, 2024
bd10941
Reverted changes to admin routes
ananthm3 Feb 17, 2024
0f89da5
Fixed duplicate routes
ananthm3 Feb 17, 2024
8c5f3a0
Reverted changes to admin routes
ananthm3 Feb 17, 2024
3d6cb2d
Fixed issues with routes API parsing JSON
ananthm3 Feb 17, 2024
fb74796
Edited return codes and fixed functionality with APIs
ananthm3 Feb 18, 2024
6bff0e6
Fixed functionality for modifying assignments in add
ananthm3 Feb 18, 2024
fdd7a8d
Uncommented sched_api (sched_api is untested, but *should* work)
ananthm3 Feb 18, 2024
2af1791
Somehow this got deleted?
ananthm3 Feb 20, 2024
3460845
Somehow this also got deleted?
ananthm3 Feb 20, 2024
82c1b0f
Removed unnecessary str check for json decoding
ananthm3 Feb 20, 2024
3e5cd4c
Make extensions api route atomic
Feb 21, 2024
0bf9dd3
Tied adding run to adding extension
ananthm3 Apr 2, 2024
29b3256
Removed debug print
ananthm3 Apr 2, 2024
d9ceac3
Added validation to query param
ananthm3 Apr 2, 2024
0d59a99
Fixed errors
ananthm3 Apr 3, 2024
e8a9086
Fixed merge conflicts
ananthm3 Apr 3, 2024
d81a446
Update routes_api.py
ananthm0203 Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 0 additions & 110 deletions .gitignore
nd-0r marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

19 changes: 0 additions & 19 deletions requirements.txt
nd-0r marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

Binary file added src/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/auth.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/bw_api.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/common.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/db.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/ghe_api.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/routes_admin.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/routes_api.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/routes_staff.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/routes_student.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/sched_api.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/template_filters.cpython-37.pyc
Binary file not shown.
Binary file added src/__pycache__/util.cpython-37.pyc
Binary file not shown.
12 changes: 10 additions & 2 deletions src/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import wraps
from http import HTTPStatus
import json

from flask import session, redirect, url_for, abort, request, render_template, make_response
from src.common import verify_staff, verify_admin
Expand Down Expand Up @@ -81,6 +82,7 @@ def wrapper(*arg, **kwargs):
token = request.headers.get("Authorization", None)
cid = kwargs[CID_KEY]
course = get_course(cid)
print(course["token"]==token)
if course is None or ("token" in course and token != course["token"]):
return abort(HTTPStatus.FORBIDDEN)
return func(*arg, **kwargs)
Expand All @@ -97,8 +99,14 @@ def require_admin_status(func):
@wraps(func)
def wrapper(*args, **kwargs):
netid = kwargs.get(UID_KEY, None)
if request.json is not None:
netid = request.json.get(UID_KEY, netid)
if netid is None and request.json is not None:
_json = request.json
if isinstance(_json, str):
nd-0r marked this conversation as resolved.
Show resolved Hide resolved
try:
_json = json.loads(request.json)
except json.JSONDecodeError:
return abort(HTTPStatus.BAD_REQUEST)
netid = _json.get(UID_KEY, netid)
cid = kwargs[CID_KEY]
if netid is None or not verify_staff(netid, cid) or not verify_admin(netid, cid):
return abort(HTTPStatus.FORBIDDEN)
Expand Down
3 changes: 2 additions & 1 deletion src/routes_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def add_assignment(netid, cid):
return util.error("Start must be before End.")

try:
config = json.loads(request.form["config"])
if not isinstance(request.form["config"], dict):
config = json.loads(request.form["config"])
msg = bw_api.set_assignment_config(cid, aid, config)

if msg:
Expand Down
Loading