summaryrefslogtreecommitdiff
path: root/grades
diff options
context:
space:
mode:
Diffstat (limited to 'grades')
-rw-r--r--grades/tests/test_models.py2
-rw-r--r--grades/tests/test_views.py9
-rw-r--r--grades/views.py16
3 files changed, 15 insertions, 12 deletions
diff --git a/grades/tests/test_models.py b/grades/tests/test_models.py
index f8d5c5c..a508eb3 100644
--- a/grades/tests/test_models.py
+++ b/grades/tests/test_models.py
@@ -1,5 +1,5 @@
from django.test import TestCase
-from grades.models import GradingSystem, GradeRange
+from grades.models import GradingSystem
class GradingSystemTestCase(TestCase):
diff --git a/grades/tests/test_views.py b/grades/tests/test_views.py
index c944f03..6b76565 100644
--- a/grades/tests/test_views.py
+++ b/grades/tests/test_views.py
@@ -5,8 +5,7 @@ from grades.models import GradingSystem
def setUpModule():
- user = User.objects.create_user(username='grades_user',
- password='grades_user')
+ User.objects.create_user(username='grades_user', password='grades_user')
def tearDownModule():
@@ -73,7 +72,7 @@ class AddGradingSystemTest(TestCase):
'graderange_set-MAX_NUM_FORMS': ['1000'], 'add': ['Add'],
'graderange_set-INITIAL_FORMS': ['0']}
# When
- response = self.client.post(reverse('grades:add_grade'), data)
+ self.client.post(reverse('grades:add_grade'), data)
# Then
grading_systems = GradingSystem.objects.filter(name='new_sys')
self.assertEqual(len(grading_systems), 1)
@@ -98,8 +97,8 @@ class AddGradingSystemTest(TestCase):
'graderange_set-0-grade': ['F'],
'graderange_set-INITIAL_FORMS': ['0'], 'save': ['Save']}
# When
- response = self.client.post(reverse('grades:edit_grade',
- kwargs={'system_id': 2}), data)
+ self.client.post(reverse('grades:edit_grade',
+ kwargs={'system_id': 2}), data)
# Then
ranges = grading_system.graderange_set.all()
self.assertEqual(len(ranges), 1)
diff --git a/grades/views.py b/grades/views.py
index 10f9999..67844bd 100644
--- a/grades/views.py
+++ b/grades/views.py
@@ -23,7 +23,8 @@ def add_grading_system(request, system_id=None):
GradeRangeFormSet = inlineformset_factory(GradingSystem, GradeRange,
fields='__all__', extra=0)
grade_form = GradingSystemForm(instance=grading_system)
- is_default = grading_system is not None and grading_system.name == 'default'
+ is_default = (grading_system is not None and
+ grading_system.name == 'default')
if request.method == 'POST':
formset = GradeRangeFormSet(request.POST, instance=grading_system)
@@ -36,10 +37,13 @@ def add_grading_system(request, system_id=None):
if formset.is_valid():
formset.save()
if 'add' in request.POST:
- GradeRangeFormSet = inlineformset_factory(GradingSystem, GradeRange,
- fields='__all__', extra=1)
+ GradeRangeFormSet = inlineformset_factory(
+ GradingSystem, GradeRange, fields='__all__', extra=1
+ )
formset = GradeRangeFormSet(instance=grading_system)
- return render(request, 'add_grades.html', {'formset': formset,
- 'grade_form': grade_form, "system_id": system_id,
- 'is_default': is_default})
+ return render(request, 'add_grades.html',
+ {'formset': formset,
+ 'grade_form': grade_form, "system_id": system_id,
+ 'is_default': is_default}
+ )