Commit 70cf9c14 authored by J08nY's avatar J08nY

Add Encryption and Signature views as FormViews, populate them initally.

parent ba165c59
......@@ -50,7 +50,7 @@ class ListSignatureSettingsForm(forms.Form):
'Whether to sign the outgoing postings of a mailing list'
'by the list key.')
)
strip_original_signature = forms.NullBooleanField(
strip_original_sig = forms.NullBooleanField(
widget=NullBooleanRadioSelect(choices=boolean_choices),
required=False,
label=_('Strip sender signature'),
......
{% extends "django_pgpmailman/base.html" %}
{% load i18n %}
{% load bootstrap_tags %}
{% block head_title %}
{% trans 'PGP List' %} - {{ block.super }}
......@@ -7,7 +8,8 @@
{% block content %}
{% with mlist=pgp_list.mlist %}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='encryption_settings' nav_title='Encryption settings'%}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='encryption_settings' nav_title='Encryption settings' %}
{% bootstrap_form_horizontal form 3 8 'Save changes' %}
{% endwith %}
{% endblock content %}
......@@ -21,15 +21,15 @@ from django.conf.urls import url, include
from django_pgpmailman.views.list import (
pgp_list_index, pgp_list_summary, pgp_list_pubkey, pgp_list_key_management,
pgp_list_signature_settings, pgp_list_encryption_settings)
ListSignatureSettingsView, ListEncryptionSettingsView)
from django_pgpmailman.views.user import pgp_user_profile
list_patterns = [
url(r'^$', pgp_list_summary, name='pgp_list_summary'),
url(r'^key/$', pgp_list_key_management, name='pgp_list_key_management'),
url(r'^signatures/$', pgp_list_signature_settings,
url(r'^signatures/$', ListSignatureSettingsView.as_view(),
name='pgp_list_signature_settings'),
url(r'^encryption/$', pgp_list_encryption_settings,
url(r'^encryption/$', ListEncryptionSettingsView.as_view(),
name='pgp_list_encryption_settings'),
url(r'^pubkey$', pgp_list_pubkey, name='pgp_list_pubkey')
]
......
......@@ -24,9 +24,11 @@ from django.http import HttpResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.generic import FormView
from six.moves.urllib.error import HTTPError
from django_pgpmailman.decorators import list_view
from django_pgpmailman.forms import ListSignatureSettingsForm
from django_pgpmailman.forms import (ListSignatureSettingsForm,
ListEncryptionSettingsForm)
from django_pgpmailman.plugin import get_pgp_plugin
......@@ -42,29 +44,63 @@ def pgp_list_summary(request, pgp_list):
{'pgp_list': pgp_list})
@method_decorator(login_required, name='dispatch')
@method_decorator(list_view, name='dispatch')
class ListSignatureSettingsView(FormView):
# TODO: proper list owner auth
class ListSettings(FormView):
properties = None
def get_initial(self):
result = {}
for key in self.properties:
result[key] = getattr(self.pgp_list, key, None)
return result
def get_context_data(self, **kwargs):
data = super(ListSettings, self).get_context_data(
**kwargs)
data['pgp_list'] = self.pgp_list
data['mlist'] = self.pgp_list.mlist
return data
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
self.pgp_list = get_pgp_plugin().get_list(kwargs['list_id'])
return super(ListSettings, self).dispatch(request, *args, **kwargs)
class ListSignatureSettingsView(ListSettings):
form_class = ListSignatureSettingsForm
template_name = 'django_pgpmailman/list/signature_settings.html'
properties = ('sign_outgoing', 'strip_original_sig', 'unsigned_msg_action',
'inline_pgp_action', 'expired_sig_action',
'revoked_sig_action', 'invalid_sig_action',
'duplicate_sig_action')
def form_valid(self, form):
pass
try:
pass
except HTTPError as e:
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})
class ListEncryptionSettingsView(ListSettings):
form_class = ListEncryptionSettingsForm
template_name = 'django_pgpmailman/list/encryption_settings.html'
properties = ('nonencrypted_msg_action', 'encrypt_outgoing')
def form_valid(self, form):
try:
pass
except HTTPError as e:
pass
# 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',
def pgp_list_key_management(request, pgp_list):
return render(request, 'django_pgpmailman/list/key_management.html',
{'pgp_list': pgp_list})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment