aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/django_pgpmailman/forms.py27
-rw-r--r--src/django_pgpmailman/templates/django_pgpmailman/list/encryption_settings.html8
-rw-r--r--src/django_pgpmailman/templates/django_pgpmailman/list/misc_settings.html16
-rw-r--r--src/django_pgpmailman/templates/django_pgpmailman/list/nav.html4
-rw-r--r--src/django_pgpmailman/templates/django_pgpmailman/list/signature_settings.html9
-rw-r--r--src/django_pgpmailman/urls.py12
-rw-r--r--src/django_pgpmailman/views/list.py60
7 files changed, 105 insertions, 31 deletions
diff --git a/src/django_pgpmailman/forms.py b/src/django_pgpmailman/forms.py
index 17b5380..7fcd3a9 100644
--- a/src/django_pgpmailman/forms.py
+++ b/src/django_pgpmailman/forms.py
@@ -132,3 +132,30 @@ class ListEncryptionSettingsForm(forms.Form):
'done before executing the signature checks. `Defer` '
'lets the message pass-through to signature checks.')
)
+
+
+key_change_choices = (('pgp-key-change-workflow', _('Default')),
+ ('pgp-key-change-mod-workflow',
+ _('Default, then moderate')))
+member_role_choices = (('member', _('Member')),
+ ('owner', _('Owner')),
+ ('moderator', _('Moderator')),
+ ('nonmember', _('Nonmember')))
+
+
+class ListMiscSettingsForm(forms.Form):
+ key_change_workflow = forms.ChoiceField(
+ widget=forms.Select(),
+ choices=key_change_choices,
+ required=False,
+ label=_('Key change workflow'),
+ help_text=_('A workflow to use for the key change operation.')
+ )
+ key_signing_allowed = forms.MultipleChoiceField(
+ widget=forms.SelectMultiple(),
+ choices=member_role_choices,
+ required=False,
+ label=_('Key signing allowed'),
+ help_text=_('A set of member roles that are allowed to sign the '
+ 'lists public key via the `key sign` command.')
+ )
diff --git a/src/django_pgpmailman/templates/django_pgpmailman/list/encryption_settings.html b/src/django_pgpmailman/templates/django_pgpmailman/list/encryption_settings.html
index 37b03be..ea84f9a 100644
--- a/src/django_pgpmailman/templates/django_pgpmailman/list/encryption_settings.html
+++ b/src/django_pgpmailman/templates/django_pgpmailman/list/encryption_settings.html
@@ -7,9 +7,11 @@
{% endblock %}
{% 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' %}
+ <form action="{% url 'pgp_list_encryption_settings' pgp_list.list_id %}"
+ method="post"
+ class="form-horizontal">
{% bootstrap_form_horizontal form 3 8 'Save changes' %}
- {% endwith %}
+ </form>
{% endblock content %}
diff --git a/src/django_pgpmailman/templates/django_pgpmailman/list/misc_settings.html b/src/django_pgpmailman/templates/django_pgpmailman/list/misc_settings.html
new file mode 100644
index 0000000..2ea77f0
--- /dev/null
+++ b/src/django_pgpmailman/templates/django_pgpmailman/list/misc_settings.html
@@ -0,0 +1,16 @@
+{% extends "django_pgpmailman/base.html" %}
+{% load i18n %}
+{% load bootstrap_tags %}
+
+{% block head_title %}
+ {% trans 'PGP List' %} - {{ block.super }}
+{% endblock %}
+
+{% block content %}
+ {% include 'django_pgpmailman/list/nav.html' with nav_tab='misc_settings' nav_title='Miscellaneous settings' %}
+ <form action="{% url 'pgp_list_misc_settings' pgp_list.list_id %}"
+ method="post"
+ class="form-horizontal">
+ {% bootstrap_form_horizontal form 3 8 'Save changes' %}
+ </form>
+{% endblock content %}
diff --git a/src/django_pgpmailman/templates/django_pgpmailman/list/nav.html b/src/django_pgpmailman/templates/django_pgpmailman/list/nav.html
index 2cf9483..2162e69 100644
--- a/src/django_pgpmailman/templates/django_pgpmailman/list/nav.html
+++ b/src/django_pgpmailman/templates/django_pgpmailman/list/nav.html
@@ -17,6 +17,10 @@
class="{% if nav_tab == 'signature_settings' %}active{% endif %}">
<a href="{% url 'pgp_list_signature_settings' mlist.list_id %}">{% trans 'Signature settings' %}</a>
</li>
+ <li role="presentation"
+ class="{% if nav_tab == 'misc_settings' %}active{% endif %}">
+ <a href="{% url 'pgp_list_misc_settings' mlist.list_id %}">{% trans 'Miscellaneous settings' %}</a>
+ </li>
</ul>
{% else %}
diff --git a/src/django_pgpmailman/templates/django_pgpmailman/list/signature_settings.html b/src/django_pgpmailman/templates/django_pgpmailman/list/signature_settings.html
index b996327..06d3b52 100644
--- a/src/django_pgpmailman/templates/django_pgpmailman/list/signature_settings.html
+++ b/src/django_pgpmailman/templates/django_pgpmailman/list/signature_settings.html
@@ -7,9 +7,10 @@
{% endblock %}
{% block content %}
- {% with mlist=pgp_list.mlist %}
- {% include 'django_pgpmailman/list/nav.html' with nav_tab='signature_settings' nav_title='Signature settings' %}
-
+ {% include 'django_pgpmailman/list/nav.html' with nav_tab='signature_settings' nav_title='Signature settings' %}
+ <form action="{% url 'pgp_list_signature_settings' pgp_list.list_id %}"
+ method="post"
+ class="form-horizontal">
{% bootstrap_form_horizontal form 3 8 'Save changes' %}
- {% endwith %}
+ </form>
{% endblock content %}
diff --git a/src/django_pgpmailman/urls.py b/src/django_pgpmailman/urls.py
index 6a2df63..abfff27 100644
--- a/src/django_pgpmailman/urls.py
+++ b/src/django_pgpmailman/urls.py
@@ -21,16 +21,22 @@ 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,
- ListSignatureSettingsView, ListEncryptionSettingsView)
+ ListSignatureSettingsView, ListEncryptionSettingsView,
+ ListMiscSettingsView)
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/$', ListSignatureSettingsView.as_view(),
+ url(r'^signatures/$', ListSignatureSettingsView.as_view(
+ success_url='pgp_list_signature_settings'),
name='pgp_list_signature_settings'),
- url(r'^encryption/$', ListEncryptionSettingsView.as_view(),
+ url(r'^encryption/$', ListEncryptionSettingsView.as_view(
+ success_url='pgp_list_encryption_settings'),
name='pgp_list_encryption_settings'),
+ url(r'^misc/$',
+ ListMiscSettingsView.as_view(success_url='pgp_list_misc_settings'),
+ name='pgp_list_misc_settings'),
url(r'^pubkey$', pgp_list_pubkey, name='pgp_list_pubkey')
]
diff --git a/src/django_pgpmailman/views/list.py b/src/django_pgpmailman/views/list.py
index e5a7e8a..bbe2547 100644
--- a/src/django_pgpmailman/views/list.py
+++ b/src/django_pgpmailman/views/list.py
@@ -18,17 +18,21 @@
from __future__ import absolute_import, unicode_literals
+from django.contrib import messages
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.urls import reverse
from django.utils.decorators import method_decorator
+from django.utils.translation import ugettext_lazy as _
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,
- ListEncryptionSettingsForm)
+ ListEncryptionSettingsForm,
+ ListMiscSettingsForm)
from django_pgpmailman.plugin import get_pgp_plugin
@@ -66,6 +70,32 @@ class ListSettings(FormView):
self.pgp_list = get_pgp_plugin().get_list(kwargs['list_id'])
return super(ListSettings, self).dispatch(request, *args, **kwargs)
+ def form_valid(self, form):
+ if not form.changed_data:
+ return
+
+ for key in form.changed_data:
+ if form.cleaned_data[key] is not None:
+ setattr(self.pgp_list, key, form.cleaned_data[key])
+
+ try:
+ self.pgp_list.save()
+
+ if form.has_changed():
+ messages.success(
+ self.request, _('List settings have been updated.'))
+ else:
+ messages.info(self.request, _('List settings did not change.'))
+
+ except HTTPError as e:
+ messages.error(self.request, e.msg)
+
+ return super(ListSettings, self).form_valid(form)
+
+ def get_success_url(self):
+ return reverse(self.success_url,
+ kwargs=dict(list_id=self.pgp_list.list_id))
+
class ListSignatureSettingsView(ListSettings):
form_class = ListSignatureSettingsForm
@@ -75,40 +105,28 @@ class ListSignatureSettingsView(ListSettings):
'revoked_sig_action', 'invalid_sig_action',
'duplicate_sig_action')
- def form_valid(self, form):
- try:
-
- pass
- except HTTPError as e:
- pass
-
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
+class ListMiscSettingsView(ListSettings):
+ form_class = ListMiscSettingsForm
+ template_name = 'django_pgpmailman/list/misc_settings.html'
+ properties = ('key_change_workflow', 'key_signing_allowed')
-# 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 ListKeyManagementView(ListSettings):
+ pass
# 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',
+def pgp_list_key_management(request, pgp_list):
+ return render(request, 'django_pgpmailman/list/key_management.html',
{'pgp_list': pgp_list})