Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
0113b6cd
Commit
0113b6cd
authored
Jun 04, 2016
by
Enrico Zini
Browse files
Added an option to download all signed statements in a mbox
parent
d0706227
Changes
3
Show whitespace changes
Inline
Side-by-side
process/templates/process/show.html
View file @
0113b6cd
...
...
@@ -117,6 +117,7 @@
{% else %}
(no mail archive yet)
{% endif %}
<a
href=
"{% url 'process_download_statements' pk=process.pk %}"
>
(signed statements mbox)
</a>
</td>
</tr>
...
...
process/urls.py
View file @
0113b6cd
...
...
@@ -25,4 +25,5 @@ urlpatterns = [
url
(
r
'^(?P<pk>\d+)/mailbox/download$'
,
views
.
MailArchive
.
as_view
(),
name
=
"process_mailbox_download"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/mailbox$'
,
views
.
DisplayMailArchive
.
as_view
(),
name
=
"process_mailbox_show"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/update_keycheck$'
,
views
.
UpdateKeycheck
.
as_view
(),
name
=
"process_update_keycheck"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/download_statements$'
,
views
.
DownloadStatements
.
as_view
(),
name
=
"process_download_statements"
),
# TODO: test
]
process/views.py
View file @
0113b6cd
...
...
@@ -420,3 +420,32 @@ class UpdateKeycheck(RequirementMixin, View):
key
.
update_key
()
key
.
update_check_sigs
()
return
redirect
(
self
.
requirement
.
get_absolute_url
())
class
DownloadStatements
(
VisitProcessMixin
,
View
):
def
get
(
self
,
request
,
*
args
,
**
kw
):
import
mailbox
import
email.utils
import
tempfile
import
time
with
tempfile
.
NamedTemporaryFile
(
mode
=
"wb+"
)
as
outfile
:
mbox
=
mailbox
.
mbox
(
path
=
outfile
.
name
,
create
=
True
)
for
req
in
self
.
process
.
requirements
.
all
():
for
stm
in
req
.
statements
.
all
():
msg
=
mailbox
.
Message
()
msg
[
"From"
]
=
email
.
utils
.
formataddr
((
stm
.
uploaded_by
.
fullname
,
stm
.
uploaded_by
.
email
))
msg
[
"Subject"
]
=
"Signed statement for "
+
req
.
get_type_display
()
msg
[
"Date"
]
=
email
.
utils
.
formatdate
(
time
.
mktime
(
stm
.
uploaded_time
.
timetuple
()))
msg
.
set_payload
(
stm
.
statement
,
"utf-8"
)
mbox
.
add
(
msg
)
mbox
.
close
()
outfile
.
seek
(
0
)
data
=
outfile
.
read
()
res
=
http
.
HttpResponse
(
data
,
content_type
=
"text/plain"
)
res
[
"Content-Disposition"
]
=
"attachment; filename={}.mbox"
.
format
(
self
.
person
.
lookup_key
)
return
res
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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