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

Adding a delete button to remove an assignment. #1383

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
15 changes: 15 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ExpandedNodes": [
"",
"\\server",
"\\server\\controllers",
"\\server\\templates",
"\\server\\templates\\staff",
"\\server\\templates\\staff\\course",
"\\server\\templates\\staff\\course\\assignment",
"\\server\\templates\\student",
"\\server\\templates\\student\\assignment"
],
"SelectedNode": "\\server\\controllers\\admin.py",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/ok/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
17 changes: 17 additions & 0 deletions server/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,23 @@ def assignment(cid, aid):
form=form, courses=courses, autograder_url=current_course.autograder_url,
current_course=current_course)

@admin.route("/course/<int:cid>/assignments", methods=['POST'])
@is_staff(course_arg='cid')
def delete_assignment(cid):
assign = Assignment.query.filter_by(id=request.args.get("aid"), course_id=cid).one_or_none()
if not assign:
return abort(404)
if not Assignment.can(assign, current_user, 'edit'):
flash('Insufficient permissions', 'error')
return abort(401)
form = forms.CSRFForm()
if form.validate_on_submit():
Backup.query.filter_by(assignment=assign).delete()
db.session.delete(assign)
db.session.commit()
flash("Successfully deleted assignment", "success")
return redirect(url_for('.course_assignments', cid=cid))

@admin.route("/course/<int:cid>/assignments/<int:aid>/stats")
@is_staff(course_arg='cid')
def assignment_stats(cid, aid):
Expand Down
Loading