Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-pgpmailman
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
J08nY
django-pgpmailman
Commits
bfc7f14b
Commit
bfc7f14b
authored
Aug 20, 2017
by
J08nY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic user address index.
parent
9d23d95c
Pipeline
#11021885
failed with stage
in 3 minutes and 5 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
20 deletions
+126
-20
decorators.py
src/django_pgpmailman/decorators.py
+17
-3
models.py
src/django_pgpmailman/models.py
+13
-2
plugin.py
src/django_pgpmailman/plugin.py
+22
-6
summary.html
..._pgpmailman/templates/django_pgpmailman/user/summary.html
+33
-1
urls.py
src/django_pgpmailman/urls.py
+3
-2
list.py
src/django_pgpmailman/views/list.py
+2
-2
user.py
src/django_pgpmailman/views/user.py
+36
-4
No files found.
src/django_pgpmailman/decorators.py
View file @
bfc7f14b
...
...
@@ -21,14 +21,14 @@ from django.http import Http404
from
six
import
wraps
from
six.moves.urllib_error
import
HTTPError
from
django_pgpmailman.plugin
import
get_p
gp_plugin
from
django_pgpmailman.plugin
import
get_p
lugin
,
get_client
def
list_view
(
fn
):
@
wraps
(
fn
)
def
wrapper
(
request
,
*
args
,
**
kwargs
):
try
:
pgp_list
=
get_p
gp_p
lugin
()
.
get_list
(
kwargs
.
pop
(
'list_id'
))
pgp_list
=
get_plugin
()
.
get_list
(
kwargs
.
pop
(
'list_id'
))
except
HTTPError
:
raise
Http404
return
fn
(
request
,
pgp_list
,
*
args
,
**
kwargs
)
...
...
@@ -39,7 +39,7 @@ def list_view(fn):
def
list_class_view
(
fn
):
@
wraps
(
fn
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
pgp_list
=
get_p
gp_p
lugin
()
.
get_list
(
kwargs
.
pop
(
'list_id'
))
self
.
pgp_list
=
get_plugin
()
.
get_list
(
kwargs
.
pop
(
'list_id'
))
return
fn
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
...
...
@@ -68,3 +68,17 @@ def member_role_required(*roles):
return
wrapped
return
wrapper
def
user_class_view
(
fn
):
@
wraps
(
fn
)
def
wrapper
(
self
,
request
,
*
args
,
**
kwargs
):
client
=
get_client
()
user
=
request
.
user
try
:
self
.
mm_user
=
client
.
get_user
(
address
=
user
.
email
)
except
HTTPError
:
self
.
mm_user
=
client
.
create_user
(
user
.
email
,
user
.
get_full_name
())
return
fn
(
self
,
request
,
*
args
,
**
kwargs
)
return
wrapper
src/django_pgpmailman/models.py
View file @
bfc7f14b
...
...
@@ -20,7 +20,8 @@ from __future__ import absolute_import, unicode_literals
from
itertools
import
chain
from
mailmanclient._client
import
MailingList
,
RESTObject
from
mailmanclient
import
Address
,
MailingList
from
mailmanclient.restbase.base
import
RESTObject
from
pgpy
import
PGPKey
from
pgpy.errors
import
PGPError
...
...
@@ -32,7 +33,7 @@ class PGPMailingList(RESTObject):
'strip_original_sig'
,
'sign_outgoing'
,
'nonencrypted_msg_action'
,
'encrypt_outgoing'
,
'key_change_workflow'
,
'key_signing_allowed'
)
_read_only_properties
=
(
'self_link'
,
'list_id'
)
_properties
=
list
(
chain
(
_writable_properties
,
_read_only_properties
))
_properties
=
tuple
(
chain
(
_writable_properties
,
_read_only_properties
))
@
property
def
mlist
(
self
):
...
...
@@ -68,3 +69,13 @@ class PGPMailingList(RESTObject):
self
.
_connection
.
call
(
self
.
_url
+
'/pubkey'
,
data
=
dict
(
public_key
=
str_key
),
method
=
'PUT'
)
class
PGPAddress
(
RESTObject
):
_read_only_properties
=
(
'self_link'
,
'email'
,
'key_fingerprint'
,
'key_confirmed'
)
_properties
=
_read_only_properties
@
property
def
address
(
self
):
return
Address
(
self
.
_connection
,
'addresses/{}'
.
format
(
self
.
email
))
src/django_pgpmailman/plugin.py
View file @
bfc7f14b
...
...
@@ -20,7 +20,7 @@ from operator import itemgetter
from
django.conf
import
settings
from
mailmanclient._client
import
Plugin
,
Client
from
django_pgpmailman.models
import
PGPMailingList
from
django_pgpmailman.models
import
PGPMailingList
,
PGPAddress
class
PGPPlugin
(
Plugin
):
...
...
@@ -42,16 +42,32 @@ class PGPPlugin(Plugin):
response
,
content
=
self
.
call
(
'lists/
%
s'
%
list_identifier
)
return
PGPMailingList
(
self
.
_connection
,
content
[
'self_link'
],
content
)
@
property
def
addresses
(
self
):
response
,
content
=
self
.
call
(
'addresses'
)
if
'entries'
not
in
content
:
return
[]
return
[
PGPAddress
(
self
.
_connection
,
entry
[
'self_link'
],
entry
)
for
entry
in
sorted
(
content
[
'entries'
],
key
=
itemgetter
(
'email'
))]
def
get_address
(
self
,
email
):
response
,
content
=
self
.
call
(
'addresses/
%
s'
%
email
)
return
PGPAddress
(
self
.
_connection
,
content
[
'self_link'
],
content
)
def
get_client
():
return
Client
(
'
%
s/3.1'
%
settings
.
MAILMAN_REST_API_URL
,
settings
.
MAILMAN_REST_API_USER
,
settings
.
MAILMAN_REST_API_PASS
)
plugin
=
None
def
get_p
gp_p
lugin
():
def
get_plugin
():
global
plugin
if
not
plugin
:
client
=
Client
(
'
%
s/3.1'
%
settings
.
MAILMAN_REST_API_URL
,
settings
.
MAILMAN_REST_API_USER
,
settings
.
MAILMAN_REST_API_PASS
)
client
=
get_client
()
plugin
=
PGPPlugin
(
client
.
get_plugin
(
settings
.
MAILMAN_PGP_PLUGIN_NAME
))
return
plugin
src/django_pgpmailman/templates/django_pgpmailman/user/summary.html
View file @
bfc7f14b
{% extends "django_pgpmailman/base.html" %}
\ No newline at end of file
{% extends "django_pgpmailman/base.html" %}
{% load i18n %}
{% block head_title %}
{% trans 'PGP User settings' %} - {{ block.super }}
{% endblock %}
{% block content %}
{% if addresses|length > 0 %}
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered table-striped"
>
<thead>
<tr>
<th>
{% trans 'Email' %}
</th>
<th>
{% trans 'Key fingerprint' %}
</th>
<th>
{% trans 'Key confirmed' %}
</th>
</tr>
</thead>
<tbody>
{% for address in addresses %}
<tr>
<td>
{{ address.email }}
</td>
<td>
{{ address.key_fingerprint }}
</td>
<td>
{{ address.key_confirmed }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>
{% trans "You currently don't have any PGP enabled addresses. Subscribe to a PGP enabled list to setup one." %}
</p>
{% endif %}
{% endblock %}
\ No newline at end of file
src/django_pgpmailman/urls.py
View file @
bfc7f14b
...
...
@@ -23,7 +23,7 @@ from django_pgpmailman.views.list import (
pgp_list_index
,
pgp_list_summary
,
ListSignatureSettingsView
,
ListEncryptionSettingsView
,
ListMiscSettingsView
,
ListKeyManagementView
,
ListPubkey
,
ListPrivkey
)
from
django_pgpmailman.views.user
import
pgp_user_profile
from
django_pgpmailman.views.user
import
UserSummaryView
list_patterns
=
[
url
(
r'^$'
,
pgp_list_summary
,
name
=
'pgp_list_summary'
),
...
...
@@ -44,7 +44,8 @@ list_patterns = [
]
user_patterns
=
[
url
(
r'^$'
,
pgp_user_profile
,
name
=
'pgp_user_profile'
)
url
(
r'^$'
,
UserSummaryView
.
as_view
(),
name
=
'pgp_user_profile'
)
]
urlpatterns
=
[
...
...
src/django_pgpmailman/views/list.py
View file @
bfc7f14b
...
...
@@ -36,12 +36,12 @@ from django_pgpmailman.forms import (ListSignatureSettingsForm,
ListEncryptionSettingsForm
,
ListMiscSettingsForm
,
ListKeyManagementForm
)
from
django_pgpmailman.plugin
import
get_p
gp_p
lugin
from
django_pgpmailman.plugin
import
get_plugin
def
pgp_list_index
(
request
):
return
render
(
request
,
'django_pgpmailman/index.html'
,
{
'lists'
:
get_p
gp_p
lugin
()
.
lists
})
{
'lists'
:
get_plugin
()
.
lists
})
@
list_view
...
...
src/django_pgpmailman/views/user.py
View file @
bfc7f14b
...
...
@@ -16,9 +16,41 @@
# 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
django.contrib.auth.decorators
import
login_required
from
django.shortcuts
import
render
from
django.utils.decorators
import
method_decorator
from
django.views.generic
import
TemplateView
from
six.moves.urllib_error
import
HTTPError
from
django_pgpmailman.decorators
import
user_class_view
from
django_pgpmailman.plugin
import
get_plugin
@
login_required
def
pgp_user_profile
(
request
):
return
render
(
request
,
'django_pgpmailman/user/summary.html'
)
class
UserSummaryView
(
TemplateView
):
template_name
=
'django_pgpmailman/user/summary.html'
@
method_decorator
(
login_required
)
@
user_class_view
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
return
super
(
UserSummaryView
,
self
)
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
data
=
super
(
UserSummaryView
,
self
)
.
get_context_data
(
**
kwargs
)
addresses
=
[]
for
address
in
self
.
mm_user
.
addresses
:
try
:
addresses
.
append
(
get_plugin
()
.
get_address
(
address
.
email
))
except
HTTPError
:
pass
data
[
'addresses'
]
=
addresses
return
data
#
# class UserSummaryView(FormView):
# template_name = 'django_pgpmailman/user/summary.html'
#
# @method_decorator(login_required)
# @user_class_view
# def dispatch(self, request, *args, **kwargs):
# return super(UserSummaryView, self).dispatch(request, *args, **kwargs)
#
# def get_form_class(self):
# return formset_factory(AddressForm, )
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment