Python 3 fixes

This commit is contained in:
Sachi King 2017-04-22 18:43:13 +10:00
parent a2464bd95e
commit b156be1e7e
2 changed files with 3 additions and 4 deletions

View file

@ -299,10 +299,9 @@ class ReportView(object):
response = HttpResponse(content_type='text/csv') response = HttpResponse(content_type='text/csv')
writer = csv.writer(response) writer = csv.writer(response)
encode = lambda i: i.encode("utf8") if isinstance(i, unicode) else i writer.writerow(report.headings())
writer.writerow(list(encode(i) for i in report.headings()))
for row in report.rows(): for row in report.rows():
writer.writerow(list(encode(i) for i in row)) writer.writerow(row)
return response return response

View file

@ -12,7 +12,7 @@ def generate_access_code():
length = 6 length = 6
# all upper-case letters + digits 1-9 (no 0 vs O confusion) # all upper-case letters + digits 1-9 (no 0 vs O confusion)
chars = string.uppercase + string.digits[1:] chars = string.ascii_uppercase + string.digits[1:]
# 6 chars => 35 ** 6 = 1838265625 (should be enough for anyone) # 6 chars => 35 ** 6 = 1838265625 (should be enough for anyone)
return get_random_string(length=length, allowed_chars=chars) return get_random_string(length=length, allowed_chars=chars)