Commit 4d30aedf by stv

Fix PEP8: E127 continuation line over-indented

for visual indent
parent 6763c5dd
...@@ -219,9 +219,11 @@ def get_cohort(user, course_key): ...@@ -219,9 +219,11 @@ def get_cohort(user, course_key):
return None return None
try: try:
return CourseUserGroup.objects.get(course_id=course_key, return CourseUserGroup.objects.get(
group_type=CourseUserGroup.COHORT, course_id=course_key,
users__id=user.id) group_type=CourseUserGroup.COHORT,
users__id=user.id,
)
except CourseUserGroup.DoesNotExist: except CourseUserGroup.DoesNotExist:
# Didn't find the group. We'll go on to create one if needed. # Didn't find the group. We'll go on to create one if needed.
pass pass
......
...@@ -24,8 +24,11 @@ class CourseUserGroup(models.Model): ...@@ -24,8 +24,11 @@ class CourseUserGroup(models.Model):
# Note: groups associated with particular runs of a course. E.g. Fall 2012 and Spring # Note: groups associated with particular runs of a course. E.g. Fall 2012 and Spring
# 2013 versions of 6.00x will have separate groups. # 2013 versions of 6.00x will have separate groups.
course_id = CourseKeyField(max_length=255, db_index=True, course_id = CourseKeyField(
help_text="Which course is this group associated with?") max_length=255,
db_index=True,
help_text="Which course is this group associated with?",
)
# For now, only have group type 'cohort', but adding a type field to support # For now, only have group type 'cohort', but adding a type field to support
# things like 'question_discussion', 'friends', 'off-line-class', etc # things like 'question_discussion', 'friends', 'off-line-class', etc
......
...@@ -46,8 +46,10 @@ class CountryMiddlewareTests(TestCase): ...@@ -46,8 +46,10 @@ class CountryMiddlewareTests(TestCase):
return ip_dict.get(ip_addr, 'US') return ip_dict.get(ip_addr, 'US')
def test_country_code_added(self): def test_country_code_added(self):
request = self.request_factory.get('/somewhere', request = self.request_factory.get(
HTTP_X_FORWARDED_FOR='117.79.83.1') '/somewhere',
HTTP_X_FORWARDED_FOR='117.79.83.1',
)
request.user = self.authenticated_user request.user = self.authenticated_user
self.session_middleware.process_request(request) self.session_middleware.process_request(request)
# No country code exists before request. # No country code exists before request.
...@@ -59,8 +61,10 @@ class CountryMiddlewareTests(TestCase): ...@@ -59,8 +61,10 @@ class CountryMiddlewareTests(TestCase):
self.assertEqual('117.79.83.1', request.session.get('ip_address')) self.assertEqual('117.79.83.1', request.session.get('ip_address'))
def test_ip_address_changed(self): def test_ip_address_changed(self):
request = self.request_factory.get('/somewhere', request = self.request_factory.get(
HTTP_X_FORWARDED_FOR='4.0.0.0') '/somewhere',
HTTP_X_FORWARDED_FOR='4.0.0.0',
)
request.user = self.anonymous_user request.user = self.anonymous_user
self.session_middleware.process_request(request) self.session_middleware.process_request(request)
request.session['country_code'] = 'CN' request.session['country_code'] = 'CN'
...@@ -71,8 +75,10 @@ class CountryMiddlewareTests(TestCase): ...@@ -71,8 +75,10 @@ class CountryMiddlewareTests(TestCase):
self.assertEqual('4.0.0.0', request.session.get('ip_address')) self.assertEqual('4.0.0.0', request.session.get('ip_address'))
def test_ip_address_is_not_changed(self): def test_ip_address_is_not_changed(self):
request = self.request_factory.get('/somewhere', request = self.request_factory.get(
HTTP_X_FORWARDED_FOR='117.79.83.1') '/somewhere',
HTTP_X_FORWARDED_FOR='117.79.83.1',
)
request.user = self.anonymous_user request.user = self.anonymous_user
self.session_middleware.process_request(request) self.session_middleware.process_request(request)
request.session['country_code'] = 'CN' request.session['country_code'] = 'CN'
...@@ -83,8 +89,10 @@ class CountryMiddlewareTests(TestCase): ...@@ -83,8 +89,10 @@ class CountryMiddlewareTests(TestCase):
self.assertEqual('117.79.83.1', request.session.get('ip_address')) self.assertEqual('117.79.83.1', request.session.get('ip_address'))
def test_same_country_different_ip(self): def test_same_country_different_ip(self):
request = self.request_factory.get('/somewhere', request = self.request_factory.get(
HTTP_X_FORWARDED_FOR='117.79.83.100') '/somewhere',
HTTP_X_FORWARDED_FOR='117.79.83.100',
)
request.user = self.anonymous_user request.user = self.anonymous_user
self.session_middleware.process_request(request) self.session_middleware.process_request(request)
request.session['country_code'] = 'CN' request.session['country_code'] = 'CN'
......
...@@ -19,13 +19,15 @@ Pass a single filename.""" ...@@ -19,13 +19,15 @@ Pass a single filename."""
l = [] l = []
for user in users: for user in users:
up = UserProfile.objects.get(user=user) up = UserProfile.objects.get(user=user)
d = {'username': user.username, d = {
'email': user.email, 'username': user.username,
'is_active': user.is_active, 'email': user.email,
'joined': user.date_joined.isoformat(), 'is_active': user.is_active,
'name': up.name, 'joined': user.date_joined.isoformat(),
'language': up.language, 'name': up.name,
'location': up.location} 'language': up.language,
'location': up.location,
}
l.append(d) l.append(d)
json.dump(l, f) json.dump(l, f)
f.close() f.close()
...@@ -59,8 +59,10 @@ class TrackMiddleware(object): ...@@ -59,8 +59,10 @@ class TrackMiddleware(object):
if string in get_dict: if string in get_dict:
get_dict[string] = '*' * 8 get_dict[string] = '*' * 8
event = {'GET': dict(get_dict), event = {
'POST': dict(post_dict)} 'GET': dict(get_dict),
'POST': dict(post_dict),
}
# TODO: Confirm no large file uploads # TODO: Confirm no large file uploads
event = json.dumps(event) event = json.dumps(event)
......
...@@ -339,8 +339,13 @@ def divide_chemical_expression(s1, s2, ignore_state=False): ...@@ -339,8 +339,13 @@ def divide_chemical_expression(s1, s2, ignore_state=False):
if treedic['1 phases'] != treedic['2 phases']: if treedic['1 phases'] != treedic['2 phases']:
return False return False
if any(map(lambda x, y: x / y - treedic['1 factors'][0] / treedic['2 factors'][0], if any(
treedic['1 factors'], treedic['2 factors'])): map(
lambda x, y: x / y - treedic['1 factors'][0] / treedic['2 factors'][0],
treedic['1 factors'],
treedic['2 factors'],
)
):
# factors are not proportional # factors are not proportional
return False return False
else: else:
......
...@@ -260,8 +260,10 @@ def _grade(student, request, course, keep_raw_scores): ...@@ -260,8 +260,10 @@ def _grade(student, request, course, keep_raw_scores):
if graded_total.possible > 0: if graded_total.possible > 0:
format_scores.append(graded_total) format_scores.append(graded_total)
else: else:
log.info("Unable to grade a section with a total possible score of zero. " + log.info(
str(section_descriptor.location)) "Unable to grade a section with a total possible score of zero. " +
str(section_descriptor.location)
)
totaled_scores[section_format] = format_scores totaled_scores[section_format] = format_scores
......
...@@ -28,8 +28,11 @@ class MyCompleter(object): # Custom completer ...@@ -28,8 +28,11 @@ class MyCompleter(object): # Custom completer
def complete(self, text, state): def complete(self, text, state):
if state == 0: # on first trigger, build possible matches if state == 0: # on first trigger, build possible matches
if text: # cache matches (entries that start with entered text) if text: # cache matches (entries that start with entered text)
self.matches = [s for s in self.options self.matches = [
if s and s.startswith(text)] option
for option in self.options
if option and option.startswith(text)
]
else: # no text entered, all matches possible else: # no text entered, all matches possible
self.matches = self.options[:] self.matches = self.options[:]
......
...@@ -158,8 +158,12 @@ def combined_notifications(course, user): ...@@ -158,8 +158,12 @@ def combined_notifications(course, user):
try: try:
#Get the notifications from the grading controller #Get the notifications from the grading controller
notifications = controller_qs.check_combined_notifications(course.id, student_id, user_is_staff, notifications = controller_qs.check_combined_notifications(
last_time_viewed) course.id,
student_id,
user_is_staff,
last_time_viewed,
)
if notifications.get('success'): if notifications.get('success'):
if (notifications.get('staff_needs_to_grade') or if (notifications.get('staff_needs_to_grade') or
notifications.get('student_needs_to_peer_grade')): notifications.get('student_needs_to_peer_grade')):
......
...@@ -14,14 +14,18 @@ class TestPaverBokChoy(unittest.TestCase): ...@@ -14,14 +14,18 @@ class TestPaverBokChoy(unittest.TestCase):
def _expected_command(self, expected_text_append): def _expected_command(self, expected_text_append):
if expected_text_append: if expected_text_append:
expected_text_append = "/" + expected_text_append expected_text_append = "/" + expected_text_append
expected_statement = ("DEFAULT_STORE=None SCREENSHOT_DIR='{repo_dir}/test_root/log' " expected_statement = (
"BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' " "DEFAULT_STORE=None SCREENSHOT_DIR='{repo_dir}/test_root/log' "
"SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' " "BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log/hars' "
"nosetests {repo_dir}/common/test/acceptance/tests{exp_text} " "SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log' "
"--with-xunit " "nosetests {repo_dir}/common/test/acceptance/tests{exp_text} "
"--xunit-file={repo_dir}/reports/bok_choy/xunit.xml " "--with-xunit "
"--verbosity=2 ".format(repo_dir=REPO_DIR, "--xunit-file={repo_dir}/reports/bok_choy/xunit.xml "
exp_text=expected_text_append)) "--verbosity=2 ".format(
repo_dir=REPO_DIR,
exp_text=expected_text_append,
)
)
return expected_statement return expected_statement
def test_default_bokchoy(self): def test_default_bokchoy(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment