Commit 9e33fdae authored by J08nY's avatar J08nY

Sketch out list management views. Fix many setup issues.

parent b6df3c3c
......@@ -32,7 +32,6 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
......@@ -71,14 +70,14 @@ INSTALLED_APPS = [
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.openid',
'django_mailman3.lib.auth.fedora',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.gitlab',
'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.openid',
# 'django_mailman3.lib.auth.fedora',
# 'allauth.socialaccount.providers.github',
# 'allauth.socialaccount.providers.gitlab',
# 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.stackexchange',
# 'allauth.socialaccount.providers.twitter',
# 'allauth.socialaccount.providers.stackexchange',
]
MIDDLEWARE = [
......@@ -117,7 +116,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
......@@ -128,6 +126,47 @@ DATABASES = {
}
}
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
# Django Allauth
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
ACCOUNT_UNIQUE_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'openid': {
'SERVERS': [
dict(id='yahoo',
name='Yahoo',
openid_url='http://me.yahoo.com'),
],
},
'google': {
'SCOPE': ['profile', 'email'],
'AUTH_PARAMS': {'access_type': 'online'},
},
'facebook': {
'METHOD': 'oauth2',
'SCOPE': ['email'],
'FIELDS': [
'email',
'name',
'first_name',
'last_name',
'locale',
'timezone',
],
'VERSION': 'v2.4',
},
}
# Change this when you have a real email backend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
......@@ -148,10 +187,9 @@ AUTH_PASSWORD_VALIDATORS = [
]
LOGIN_URL = 'account_login'
LOGIN_REDIRECT_URL = 'list_index'
LOGIN_REDIRECT_URL = 'pgp_list_index'
LOGOUT_URL = 'account_logout'
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
......@@ -165,7 +203,6 @@ USE_L10N = True
USE_TZ = True
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
......@@ -175,3 +212,43 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file': {
'level': 'INFO',
# 'class': 'logging.handlers.RotatingFileHandler',
'class': 'logging.handlers.WatchedFileHandler',
'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'),
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['console', 'file'],
'level': 'INFO',
},
'django.request': {
'handlers': ['console', 'file'],
'level': 'ERROR',
},
'postorius': {
'handlers': ['console', 'file'],
'level': 'INFO',
},
},
'formatters': {
'simple': {
'format': '%(levelname)s: %(message)s'
},
'verbose': {
'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
},
},
}
......@@ -80,7 +80,7 @@
</a></li>
{% endif %}
<li role="separator" class="divider"></li>
<li><a href="{% url LOGOUT_URL %}?next={% url 'list_index' %}">
<li><a href="{% url LOGOUT_URL %}?next={% url 'pgp_list_index' %}">
<span class="glyphicon glyphicon-log-out"></span>
{% trans 'Logout' %}
</a></li>
......
{% extends "django_pgpmailman/base.html" %}
{% load i18n %}
{% block head_title %}
{% trans 'PGP List' %} - {{ block.super }}
{% endblock %}
{% block content %}
{% with mlist=pgp_list.mlist %}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='encryption_settings' nav_title='Encryption settings'%}
{% endwith %}
{% endblock content %}
......@@ -2,13 +2,12 @@
{% load i18n %}
{% block head_title %}
{% trans 'PGP List' %} - {{ block.super }}
{% trans 'PGP List' %} - {{ block.super }}
{% endblock %}
{% block content %}
{% with mlist=pgp_list.mlist %}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='key_management' nav_title='List key management' %}
<div class="page-header">
<h1>{% trans 'PGP enabled Mailing List' %}</h1>
</div>
{% endwith %}
{% endblock content %}
{% load i18n %}
{% if user.is_authenticated %}
<ul class="nav nav-pills">
<li role="presentation"
class="{% if nav_tab == 'info' %}active{% endif %}">
<a href="{% url 'pgp_list_summary' mlist.list_id %}">{% trans 'Info' %}</a>
</li>
<li role="presentation"
class="{% if nav_tab == 'key_management' %}active{% endif %}">
<a href="{% url 'pgp_list_key_management' mlist.list_id %}">{% trans 'Key management' %}</a>
</li>
<li role="presentation"
class="{% if nav_tab == 'encryption_settings' %}active{% endif %}">
<a href="{% url 'pgp_list_encryption_settings' mlist.list_id %}">{% trans 'Encryption settings' %}</a>
</li>
<li role="presentation"
class="{% if nav_tab == 'signature_settings' %}active{% endif %}">
<a href="{% url 'pgp_list_signature_settings' mlist.list_id %}">{% trans 'Signature settings' %}</a>
</li>
</ul>
{% else %}
{% endif %}
<div class="page-header">
{% if nav_tab == 'info' %}
<h1>{{ mlist.display_name }}
<small>{{ mlist.fqdn_listname }}</small>
</h1>
{% else %}
<h3>{{ nav_title }} {% if nav_subtitle %}
<small>{{ nav_subtitle }}</small>{% endif %}</h3>
{% endif %}
</div>
{% extends "django_pgpmailman/base.html" %}
{% load i18n %}
{% block head_title %}
{% trans 'PGP List' %} - {{ block.super }}
{% endblock %}
{% block content %}
{% with mlist=pgp_list.mlist %}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='signature_settings' nav_title='Signature settings' %}
{% endwith %}
{% endblock content %}
{% extends "django_pgpmailman/base.html" %}
{% load i18n %}
{% block head_title %}
{% trans 'PGP List' %} - {{ block.super }}
{% endblock %}
{% block content %}
{% with mlist=pgp_list.mlist %}
{% include 'django_pgpmailman/list/nav.html' with nav_tab='info' %}
<p>{{ mlist.settings.description }}</p>
{% if mlist.settings.info %}
<p>{{ mlist.settings.info }}</p>
{% endif %}
{% endwith %}
{% endblock content %}
{% extends "django_pgpmailman/base.html" %}
\ No newline at end of file
......@@ -19,15 +19,27 @@ from __future__ import absolute_import, unicode_literals
from django.conf.urls import url, include
from django_pgpmailman.views.list import (pgp_list_index, pgp_list_summary,
pgp_list_pubkey)
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)
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,
name='pgp_list_signature_settings'),
url(r'^encryption/$', pgp_list_encryption_settings,
name='pgp_list_encryption_settings'),
url(r'^pubkey$', pgp_list_pubkey, name='pgp_list_pubkey')
]
user_patterns = [
url(r'^$', pgp_user_profile, name='pgp_user_profile')
]
urlpatterns = [
url(r'^$', pgp_list_index, name='pgp_list_index'),
url(r'^lists/(?P<list_id>[^/]+)/', include(list_patterns))
url(r'^lists/(?P<list_id>[^/]+)/', include(list_patterns)),
url(r'^accounts/', include(user_patterns))
]
......@@ -26,12 +26,28 @@ from django_pgpmailman.plugin import get_pgp_plugin
def pgp_list_index(request):
return render(request, 'django_pgpmailman/index.html',
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',
return render(request, 'django_pgpmailman/list/summary.html',
{'pgp_list': get_pgp_plugin().get_list(list_id)})
def pgp_list_key_management(request, list_id):
return render(request, 'django_pgpmailman/list/key_management.html',
{'pgp_list': get_pgp_plugin().get_list(list_id)})
def pgp_list_encryption_settings(request, list_id):
return render(request, 'django_pgpmailman/list/encryption_settings.html',
{'pgp_list': get_pgp_plugin().get_list(list_id)})
def pgp_list_signature_settings(request, list_id):
return render(request, 'django_pgpmailman/list/signature_settings.html',
{'pgp_list': get_pgp_plugin().get_list(list_id)})
......
# -*- 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 django.shortcuts import render
def pgp_user_profile(request):
return render(request, 'django_pgpmailman/user/summary.html')
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