# -*- 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 . 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