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

[WIP] Slack Integration #25

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from src.routes_staff import StaffRoutes
from src.routes_student import StudentRoutes
from src.routes_system import SystemRoutes
from src.routes_bot import BroadwayBot
from src.template_filters import TemplateFilters

app = Flask(__name__)
Expand Down Expand Up @@ -64,3 +65,4 @@ def root(netid):
StudentRoutes(app)
StaffRoutes(app)
TemplateFilters(app)
BroadwayBot(app)
11 changes: 8 additions & 3 deletions src/bw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
HEADERS = {"Authorization": "Bearer %s" % BROADWAY_API_TOKEN}


def start_grading_run(cid, aid, netid, timestamp):
def start_grading_run(cid, aid, netids, timestamp):
"""
Attempt to start a grading run.
:param cid: the course ID.
:param aid: the assignment ID within the course.
:param netid: the student's NetID.
:param netid: the student's NetID or a list of student NetIDs.
:param timestamp: the UNIX timestamp for the run due date.
:return: a run_id string if successful, or None otherwise.
"""

if not isinstance(netids, list):
netids = [netids]

data = {
"students_env": [{
"STUDENT_ID": netid,
"DUE_DATE": timestamp_to_bw_api_format(timestamp)
}]
} for netid in netids]
}

try:
resp = requests.post(url="%s/grading_run/%s/%s" % (BROADWAY_API_URL, cid, aid), headers=HEADERS, json=data)
run_id = resp.json()["data"]["grading_run_id"]
Expand Down
8 changes: 8 additions & 0 deletions src/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ def verify_staff(netid, cid):
:return: a boolean value.
"""
return netid in db.get_course(cid)["staff_ids"]


def verify_course(cid):
return db.get_course(cid) is not None


def verify_assignment(cid, aid):
return db.get_assignment(cid, aid) is not None
5 changes: 5 additions & 0 deletions src/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def get_courses_for_staff(netid):
return list(courses)


def get_all_courses():
courses = mongo.db.courses.find({})
return list(courses)


def get_course(cid):
return mongo.db.courses.find_one({"_id": cid})

Expand Down
2 changes: 2 additions & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ pytz==2018.9
requests==2.21.0
urllib3==1.24.1
Werkzeug==0.14.1
slackclient
slackeventsapi
Loading