blob: b99e3327fe56f0ccbd6867db086dae73c1b4a640 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# -*- coding: utf-8 -*-
# Copyright (C) 2017 Jan Jancar
#
# This file is a part of the Django Mailman PGP plugin.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, unicode_literals
from django.core.files.base import ContentFile
from django.http import HttpResponse
from django.shortcuts import render
from django_pgpmailman.plugin import get_pgp_plugin
def pgp_list_index(request):
return render(request, 'django_pgpmailman/index.html',
{'lists': get_pgp_plugin().lists})
def pgp_list_summary(request, list_id):
return render(request, 'django_pgpmailman/summary.html',
{'pgp_list': get_pgp_plugin().get_list(list_id)})
def pgp_list_pubkey(request, list_id):
pgp_list = get_pgp_plugin().get_list(list_id)
pubkey = pgp_list.pubkey
pubkey_file = ContentFile(str(pubkey))
response = HttpResponse(pubkey_file, 'application/pgp-keys')
response['Content-Length'] = pubkey_file.size
response[
'Content-Disposition'] = 'attachment; filename="%s.asc"' % pgp_list.list_id
return response
|