Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
b828b87a
Commit
b828b87a
authored
Jul 28, 2016
by
Thom Wiggers
📐
Browse files
Merge branch 'refactor/underscores' into 'master'
Prevent overriding underscore variable See merge request
!14
parents
14e4f334
9ccf766a
Changes
3
Hide whitespace changes
Inline
Side-by-side
website/documents/views.py
View file @
b828b87a
...
...
@@ -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
)
website/members/views.py
View file @
b828b87a
...
...
@@ -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
)
website/utils/validators.py
View file @
b828b87a
...
...
@@ -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."
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment