Skip to content

Commit

Permalink
#476 Fix E231 missing whitespace after ‘,’, ‘;’, or ‘:’
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlittle committed Nov 3, 2019
1 parent bb12e8e commit 3ad1ced
Show file tree
Hide file tree
Showing 27 changed files with 311 additions and 188 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -6,9 +6,9 @@ django-oppia is the server side component for the OppiaMobile learning platform
For documentation please visit: https://oppiamobile.readthedocs.io

For information on how to contribute, submit bug reports and feature requests,
please visit:
please visit:
https://github.com/DigitalCampus/django-oppia/blob/master/CONTRIBUTING.md

For help and support, please join our OppiaMobile Community site at
For help and support, please join our OppiaMobile Community site at
https://community.oppia-mobile.org/

2 changes: 1 addition & 1 deletion activitylog/views.py
Expand Up @@ -30,7 +30,7 @@ def process_uploaded_trackers(request, trackers, user, user_api_key):
else:
messages.warning(request, _(
u"Already uploaded: tracker activity %(uuid)s for %(username)s added" % {'username': user.username,
'uuid': tracker.get('digest')}),'danger')
'uuid': tracker.get('digest')}), 'danger')


def process_uploaded_quizresponses(request, quiz_responses, user, user_api_key):
Expand Down
2 changes: 1 addition & 1 deletion av/management/commands/generate_media_images.py
Expand Up @@ -44,7 +44,7 @@ def handle(self, *args, **options):
self.stdout.write(" > Generating miniatures... 100% \r\n", )

# Now get the images generated and add to the db
self.add_images_to_db(cache_dir,m)
self.add_images_to_db(cache_dir, m)

self.stdout.write("\n > Process completed.")

Expand Down
2 changes: 1 addition & 1 deletion gamification/models.py
Expand Up @@ -94,7 +94,7 @@ def __str__(self):
class Meta:
verbose_name = _(u'Activity Gamification Event')
verbose_name_plural = _(u'Activity Gamification Events')


class MediaGamificationEvent(GamificationEvent):
media = models.ForeignKey(Media, on_delete=models.CASCADE, related_name='gamification_events')
Expand Down
13 changes: 7 additions & 6 deletions gamification/views.py
Expand Up @@ -118,7 +118,9 @@ def edit_course_gamification(request, course_id):

course = get_object_or_404(Course, pk=course_id)

events_formset = formset_factory(GamificationEventForm, extra=0, can_delete=True)
events_formset = formset_factory(GamificationEventForm,
extra=0,
can_delete=True)
if request.method == 'POST':
formset = events_formset(request.POST, request.FILES, prefix='events')
if formset.is_valid():
Expand Down Expand Up @@ -187,10 +189,9 @@ def edit_course_gamification(request, course_id):
m.events[event.event] = event.points

return render(request, 'gamification/edit.html',
{
'default_points':default_points,
'course': course,
'events_formset':formset,
{'default_points': default_points,
'course': course,
'events_formset': formset,
'course_events': course_events,
'activities':activities,
'activities': activities,
'media': media})
2 changes: 1 addition & 1 deletion helpers/forms/dates.py
Expand Up @@ -14,7 +14,7 @@ class DateDiffForm(forms.Form):
required=True,
error_messages={'required': _('Please enter a valid date'),
'invalid': _('Please enter a valid date')},
widget=DateInput(attrs={'class':'date-picker-selector single'})
widget=DateInput(attrs={'class': 'date-picker-selector single'})
)

def __init__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions integrations/dhis/views.py
Expand Up @@ -28,7 +28,7 @@ def export_latest(request):
last_month = datetime.datetime.now() + dateutil.relativedelta.relativedelta(months=-1)
data = create_csv(last_month.year, last_month.month)
response = HttpResponse(data.csv, content_type='application/text;charset=utf-8')
response['Content-Disposition'] = "attachment; filename=dhis-export-{year}-{month}.csv".format(year=last_month.year,month=last_month.month)
response['Content-Disposition'] = "attachment; filename=dhis-export-{year}-{month}.csv".format(year=last_month.year, month=last_month.month)

return response

Expand All @@ -37,7 +37,7 @@ def export_latest(request):
def export_month(request, year, month):
data = create_csv(year, month)
response = HttpResponse(data.csv, content_type='application/text;charset=utf-8')
response['Content-Disposition'] = "attachment; filename=dhis-export-{year}-{month}.csv".format(year=year,month=month)
response['Content-Disposition'] = "attachment; filename=dhis-export-{year}-{month}.csv".format(year=year, month=month)

return response

Expand Down
2 changes: 1 addition & 1 deletion oppia/management/commands/oppiacron.py
Expand Up @@ -32,7 +32,7 @@ def handle(self, *args, **options):
hours=0

#check if cron already running
prop, created = SettingProperties.objects.get_or_create(key='oppia_cron_lock',int_value=1)
prop, created = SettingProperties.objects.get_or_create(key='oppia_cron_lock', int_value=1)
if not created:
self.stdout.write("Oppia cron is already running")
return
Expand Down
8 changes: 4 additions & 4 deletions oppia/uploader.py
Expand Up @@ -359,7 +359,7 @@ def parse_and_save_activity(req, user, course, section, act, new_course, process
action="activity_added",
data=msg_text).save()
else:
msg_text = _(u'Activity "%(act)s"(%(digest)s) previously existed. Updated with new information') % {'act': activity.title, 'digest':activity.digest}
msg_text = _(u'Activity "%(act)s"(%(digest)s) previously existed. Updated with new information') % {'act': activity.title, 'digest': activity.digest}
'''
If we also want to show the activities that previously existed, uncomment this next line
messages.info(req, msg_text)
Expand All @@ -386,7 +386,7 @@ def parse_and_save_activity(req, user, course, section, act, new_course, process
defaults={'points': event['points'], 'user': req.user})

if created:
msg_text = _(u'Gamification for "%(event)s" at activity "%(act)s"(%(digest)s) added') % {'event': e.event, 'act':activity.title, 'digest': activity.digest}
msg_text = _(u'Gamification for "%(event)s" at activity "%(act)s"(%(digest)s) added') % {'event': e.event, 'act': activity.title, 'digest': activity.digest}
messages.info(req, msg_text)
CoursePublishingLog(course=course,
user=user,
Expand Down Expand Up @@ -472,7 +472,7 @@ def parse_course_meta(xml_doc):
description[t.get('lang')] = t.text
meta_info['description'] = json.dumps(description)

meta_info['shortname'] = get_content(meta,'shortname')
meta_info['shortname'] = get_content(meta, 'shortname')
exportversion = meta.find('exportversion')
if exportversion:
meta_info['exportversion'] = exportversion
Expand Down Expand Up @@ -518,7 +518,7 @@ def clean_old_course(req, user, oldsections, old_course_filename, course):

if old_course_filename is not None and old_course_filename != course.filename:
try:
os.remove(os.path.join(settings.COURSE_UPLOAD_DIR,
os.remove(os.path.join(settings.COURSE_UPLOAD_DIR,
old_course_filename))
except OSError:
pass
Expand Down
2 changes: 1 addition & 1 deletion oppiamobile/settings.py
Expand Up @@ -91,7 +91,7 @@

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(ROOT_DIR, 'static')
MEDIA_ROOT = os.path.join(ROOT_DIR, 'media')
ADMIN_MEDIA_PREFIX = '/static/admin/'
Expand Down
2 changes: 1 addition & 1 deletion profile/views.py
Expand Up @@ -544,7 +544,7 @@ def search_users(request):
users = User.objects

filtered = False
search_form = UserSearchForm(request.GET,request.FILES)
search_form = UserSearchForm(request.GET, request.FILES)
if search_form.is_valid():
filters = get_filters_from_row(search_form)
if filters:
Expand Down
2 changes: 1 addition & 1 deletion summary/cron.py
Expand Up @@ -15,7 +15,7 @@ def update_summaries(last_tracker_pk=0, last_points_pk=0):
from summary.models import UserCourseSummary, CourseDailyStats, UserPointsSummary

#check if cron already running
prop, created = SettingProperties.objects.get_or_create(key='oppia_summary_cron_lock',int_value=1)
prop, created = SettingProperties.objects.get_or_create(key='oppia_summary_cron_lock', int_value=1)
if not created:
print("Oppia summary cron is already running")
return
Expand Down
20 changes: 10 additions & 10 deletions tests/api/test_media_upload.py
Expand Up @@ -27,7 +27,7 @@ def test_no_get(self):
# test all params have been sent
def test_required_params(self):

video_file = open(self.video_file_path,'rb')
video_file = open(self.video_file_path, 'rb')

# no username
response = self.client.post(self.url,
Expand All @@ -47,7 +47,7 @@ def test_required_params(self):
# check authentication check working correctly
def test_authentication(self):

video_file = open(self.video_file_path,'rb')
video_file = open(self.video_file_path, 'rb')
# incorrect username
response = self.client.post(self.url,
{'username': 'demouser',
Expand All @@ -62,8 +62,8 @@ def test_authentication(self):
'media_file': video_file})
self.assertEqual(response.status_code, 401)

video_file.close()
# shouldn't be strictly necessary to close the file,
video_file.close()
# shouldn't be strictly necessary to close the file,
# but avoids ResourceWarnings about unclosed files

# test is user has correct permissions or not to upload
Expand All @@ -73,15 +73,15 @@ def test_permissions(self):
user.is_active = False
user.save()

video_file = open(self.video_file_path,'rb')
video_file = open(self.video_file_path, 'rb')

response = self.client.post(self.url,
{'username': 'demo',
'password': 'password',
'media_file': video_file})
self.assertEqual(response.status_code, 401)

video_file.close()
video_file.close()
# shouldn't be strictly necessary to close the file,
# but avoids ResourceWarnings about unclosed files

Expand All @@ -93,8 +93,8 @@ def test_permissions(self):
def test_upload(self):

'''
TODO - the test framework seems to only recognise the file as
'application/octet-stream', so upload ways fails as incorrect
TODO - the test framework seems to only recognise the file as
'application/octet-stream', so upload ways fails as incorrect
mime-type is found
# normal user
Expand All @@ -118,7 +118,7 @@ def test_upload(self):
# test file type
def test_filetype(self):

course_file = open(self.course_file_path,'rb')
course_file = open(self.course_file_path, 'rb')

# send zip file
response = self.client.post(self.url,
Expand All @@ -127,7 +127,7 @@ def test_filetype(self):
'media_file': course_file})
self.assertEqual(response.status_code, 400)

course_file.close()
course_file.close()
# shouldn't be strictly necessary to close the file,
# but avoids ResourceWarnings about unclosed files

Expand Down
7 changes: 4 additions & 3 deletions tests/api/test_register.py
Expand Up @@ -14,7 +14,8 @@ def setUp(self):

# check get method not allowed
def test_get_list_invalid(self):
self.assertHttpMethodNotAllowed(self.api_client.get(self.url, format='json'))
self.assertHttpMethodNotAllowed(self.api_client.get(self.url,
format='json'))

# check posting with no username
def test_post_no_username(self):
Expand Down Expand Up @@ -208,7 +209,7 @@ def test_email_in_use(self):

def test_self_registration_disabled_cant_view(self):
# turn off self registration
SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION,0)
SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION, 0)
data = {
'username': 'demo3',
'password': 'secret',
Expand All @@ -222,5 +223,5 @@ def test_self_registration_disabled_cant_view(self):
self.assertValidJSON(response.content)

# turn back on
SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION,1)
SettingProperties.set_int(constants.OPPIA_ALLOW_SELF_REGISTRATION, 1)

2 changes: 1 addition & 1 deletion tests/av/test_media_upload.py
Expand Up @@ -27,7 +27,7 @@ def setUp(self):

def test_upload_template(self):

media_file_content = open(self.media_file_path,'rb')
media_file_content = open(self.media_file_path, 'rb')
media_file = SimpleUploadedFile(media_file_content.name, media_file_content.read(), content_type="video/m4v")

self.client.login(username=ADMIN_USER['user'], password=ADMIN_USER['password'])
Expand Down
48 changes: 32 additions & 16 deletions tests/gamification/test_permissions.py
Expand Up @@ -18,45 +18,61 @@ def setUp(self):

def testCoursePointsEdit(self):
# admin
self.client.login(username=ADMIN_USER['user'], password=ADMIN_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[1]))
self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[1]))
self.assertEqual(response.status_code, 200)

# staff
self.client.login(username=STAFF_USER['user'], password=STAFF_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[1]))
self.client.login(username=STAFF_USER['user'],
password=STAFF_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[1]))
self.assertEqual(response.status_code, 200)

# teacher
self.client.login(username=TEACHER_USER['user'], password=TEACHER_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[1]))
self.client.login(username=TEACHER_USER['user'],
password=TEACHER_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[1]))
self.assertEqual(response.status_code, 403)

# user
self.client.login(username=NORMAL_USER['user'], password=NORMAL_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[1]))
self.client.login(username=NORMAL_USER['user'],
password=NORMAL_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[1]))
self.assertEqual(response.status_code, 403)

def testUnknownCoursePointsEdit(self):

# admin
self.client.login(username=ADMIN_USER['user'], password=ADMIN_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[55]))
self.client.login(username=ADMIN_USER['user'],
password=ADMIN_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[55]))
self.assertEqual(response.status_code, 404)

# staff
self.client.login(username=STAFF_USER['user'], password=STAFF_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[55]))
self.client.login(username=STAFF_USER['user'],
password=STAFF_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[55]))
self.assertEqual(response.status_code, 404)

# teacher
self.client.login(username=TEACHER_USER['user'], password=TEACHER_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[55]))
self.client.login(username=TEACHER_USER['user'],
password=TEACHER_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[55]))
self.assertEqual(response.status_code, 403)

# user
self.client.login(username=NORMAL_USER['user'], password=NORMAL_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',args=[55]))
self.client.login(username=NORMAL_USER['user'],
password=NORMAL_USER['password'])
response = self.client.get(reverse('oppia_gamification_edit_course',
args=[55]))
self.assertEqual(response.status_code, 403)


Expand Down

0 comments on commit 3ad1ced

Please sign in to comment.