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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# -*- 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.contrib.auth.decorators import login_required
from django.core.files.base import ContentFile
from django.http import HttpResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.generic import FormView
from django_pgpmailman.decorators import list_view
from django_pgpmailman.forms import ListSignatureSettingsForm
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})
@list_view
def pgp_list_summary(request, pgp_list):
return render(request, 'django_pgpmailman/list/summary.html',
{'pgp_list': pgp_list})
@method_decorator(login_required, name='dispatch')
@method_decorator(list_view, name='dispatch')
class ListSignatureSettingsView(FormView):
form_class = ListSignatureSettingsForm
template_name = 'django_pgpmailman/list/signature_settings.html'
def form_valid(self, form):
pass
# TODO: proper list owner auth
@login_required
@list_view
def pgp_list_key_management(request, pgp_list):
return render(request, 'django_pgpmailman/list/key_management.html',
{'pgp_list': pgp_list})
# TODO: proper list owner auth
@login_required
@list_view
def pgp_list_encryption_settings(request, pgp_list):
return render(request, 'django_pgpmailman/list/encryption_settings.html',
{'pgp_list': pgp_list})
# TODO: proper list owner auth
@login_required
@list_view
def pgp_list_signature_settings(request, pgp_list):
return render(request, 'django_pgpmailman/list/signature_settings.html',
{'pgp_list': pgp_list})
@list_view
def pgp_list_pubkey(request, pgp_list):
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
|