Commit b828b87a authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'refactor/underscores' into 'master'

Prevent overriding underscore variable



See merge request !14
parents 14e4f334 9ccf766a
......@@ -44,7 +44,7 @@ def index(request):
def get_miscellaneous_document(request, pk):
document = get_object_or_404(MiscellaneousDocument, pk=int(pk))
_, ext = os.path.splitext(document.file.path)
ext = os.path.splitext(document.file.path)[1]
# TODO verify if we need to check a permission instead.
# This depends on how we're dealing with ex-members.
if document.members_only and not request.user.is_authenticated():
......@@ -60,7 +60,7 @@ def get_association_document(request, document_type, year):
file = {'policy-document': documents.policy_document,
'annual-report': documents.annual_report,
'financial-report': documents.financial_report}[document_type]
_, ext = os.path.splitext(file.path)
ext = os.path.splitext(file.path)[1]
filename = '{}-{}-{}{}'.format(year, int(year)+1, document_type, ext)
return sendfile(request, file.path,
attachment=True, attachment_filename=filename)
......@@ -78,7 +78,7 @@ def get_general_meeting_document(request, pk, document_pk):
@login_required
def get_general_meeting_minutes(request, pk):
meeting = get_object_or_404(GeneralMeeting, pk=int(pk))
_, ext = os.path.splitext(meeting.minutes.path)
ext = os.path.splitext(meeting.minutes.path)[1]
filename = '{}-minutes{}'.format(meeting.datetime.date(), ext)
return sendfile(request, meeting.minutes.path,
attachment=True, attachment_filename=filename)
......@@ -19,6 +19,6 @@ def become_a_member(request):
def get_become_a_member_document(request, pk):
document = get_object_or_404(models.BecomeAMemberDocument, pk=int(pk))
_, ext = os.path.splitext(document.file.path)
ext = os.path.splitext(document.file.path)[1]
return sendfile(request, document.file.path, attachment=True,
attachment_filename=slugify(document.name) + ext)
......@@ -4,6 +4,6 @@ import os
def validate_file_extension(file, exts=['.txt', '.pdf', '.jpg', '.png']):
_, ext = os.path.splitext(file.name)
ext = os.path.splitext(file.name)[1]
if not ext.lower() in exts:
raise ValidationError("File extension not allowed.")
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