Skip to content

Commit

Permalink
redirect to template for new assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Eurie Oh committed Sep 7, 2016
1 parent 13868bb commit 2b5ed79
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/controllers/admin.py
Expand Up @@ -336,6 +336,8 @@ def new_assignment(cid):
cache.delete_memoized(Assignment.name_to_assign_info)

flash("Assignment created successfully.", "success")
if form.visible.data:
return redirect(url_for(".templates", cid=cid, aid=model.id))
return redirect(url_for(".course_assignments", cid=cid))

return render_template('staff/course/assignment/assignment.new.html', form=form,
Expand Down
Expand Up @@ -36,7 +36,7 @@ <h3 class="box-title"><span> {{ title }} </span></h3>
<td class="sid">{{ item.sid }}</td>
<td class="secondary">{{ item.class_account }}</td>
<td class="role"><span class="label label-success">{{item.role | title }}</span></td>
<td class="timestamp" data-timestamp="{{ item.created }}">{{ utils.local_time(item.created, current_course) }}</td>
<td class="timestamp" data-timestamp="{{ item.created }}">{{ utils.local_time_obj(item.created, current_course) }}</td>
<td class="section">{{item.section}}</td>
<td class="unenroll">
{% call forms.render_form_bare(unenroll_form, action_url=url_for('.unenrollment', cid=current_course.id, user_id=item.user.id), class_='form') %}
Expand Down
52 changes: 52 additions & 0 deletions tests/test_assignment.py
@@ -0,0 +1,52 @@
import datetime
import json
from server.models import db, Assignment, Backup, Course, User, Version
from server.utils import encode_id
from server.forms import VersionForm

from tests import OkTestCase

class TestAssignment(OkTestCase):

def setUp(self):
super().setUp()
self.setup_course()

def test_new_assignment(self):

self.login(self.admin.email)

data = {
"display_name": "test",
"name": "{}/test".format(self.course.offering),
"due_date": "2016-09-14 23:59:59",
"lock_date": "2016-09-15 23:59:59",
"max_group_size": 1,
"visible": True
}

response = self.client.post("admin/course/1/assignments/new",
data=data, follow_redirects=True)

self.assert200(response)
self.assert_template_used('staff/course/assignment/assignment.template.html')


def test_new_assignment_not_visible(self):

self.login(self.admin.email)

data = {
"display_name": "test",
"name": "{}/test".format(self.course.offering),
"due_date": "2016-09-14 23:59:59",
"lock_date": "2016-09-15 23:59:59",
"max_group_size": 1
}

response = self.client.post("admin/course/1/assignments/new",
data=data, follow_redirects=True)

self.assert200(response)
self.assertTemplateUsed('staff/course/assignment/assignments.html')

0 comments on commit 2b5ed79

Please sign in to comment.