Skip to content

Commit

Permalink
Updated for Mailman 3.2.0
Browse files Browse the repository at this point in the history
Changes necessary to ingegrate COmanage Registry with Mailman 3.2.0.
  • Loading branch information
skoranda committed Feb 21, 2019
1 parent 5d463b4 commit e53f518
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion comanage-registry-mailman/core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apt-get update \
postgresql-client \
python3-dev \
&& pip install psycopg2 \
mailman==3.1.1 \
mailman==3.2 \
mailman-hyperkitty==1.1.0 \
pymysql \
&& adduser --system mailman
Expand Down
5 changes: 1 addition & 4 deletions comanage-registry-mailman/core/addresses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2011-2017 by the Free Software Foundation, Inc.
# Copyright (C) 2011-2018 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
Expand Down Expand Up @@ -196,9 +196,7 @@ def on_post(self, request, response):
Add a new address to the user record.
"""
assert self._user is not None

preferred = None

user_manager = getUtility(IUserManager)
validator = Validator(email=str,
display_name=str,
Expand All @@ -207,7 +205,6 @@ def on_post(self, request, response):
_optional=('display_name', 'absorb_existing', 'preferred'))
try:
data = validator(request)

# We cannot set the address to be preferred when it is
# created so remove it from the arguments here and
# set it below.
Expand Down
26 changes: 15 additions & 11 deletions comanage-registry-mailman/core/users.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2011-2017 by the Free Software Foundation, Inc.
# Copyright (C) 2011-2018 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
Expand Down Expand Up @@ -152,7 +152,8 @@ def create_user(api, arguments, response):
user.link(address)
else:
bad_request(
response, 'User already exists: {}'.format(error.address))
response,
'User already exists: {}'.format(error.address).encode())
return None
if password is None:
# This will have to be reset since it cannot be retrieved.
Expand Down Expand Up @@ -296,16 +297,16 @@ def on_patch(self, request, response):
return
try:
validator = PatchValidator(request, ATTRIBUTES)
validator.update(self._user, request)
except UnknownPATCHRequestError as error:
bad_request(
response, b'Unknown attribute: {0}'.format(error.attribute))
response,
'Unknown attribute: {0}'.format(error.attribute).encode())
except ReadOnlyPATCHRequestError as error:
bad_request(
response, b'Read-only attribute: {0}'.format(error.attribute))
except ValueError as error:
bad_request(response, str(error))
response,
'Read-only attribute: {0}'.format(error.attribute).encode())
else:
validator.update(self._user, request)
no_content(response)

def on_put(self, request, response):
Expand All @@ -318,10 +319,12 @@ def on_put(self, request, response):
validator.update(self._user, request)
except UnknownPATCHRequestError as error:
bad_request(
response, b'Unknown attribute: {0}'.format(error.attribute))
response,
'Unknown attribute: {0}'.format(error.attribute).encode())
except ReadOnlyPATCHRequestError as error:
bad_request(
response, b'Read-only attribute: {0}'.format(error.attribute))
response,
'Read-only attribute: {0}'.format(error.attribute).encode())
except ValueError as error:
bad_request(response, str(error))
else:
Expand Down Expand Up @@ -385,7 +388,7 @@ def on_post(self, request, response):
user = user_manager.get_user_by_id(user_id)
if user is None:
bad_request(response, 'No user with ID {}'.format(
self.api.from_uuid(user_id)))
self.api.from_uuid(user_id)).encode())
return
okay(response)
else:
Expand Down Expand Up @@ -420,7 +423,8 @@ def on_put(self, request, response):
user_id = arguments['user_id']
user = user_manager.get_user_by_id(user_id)
if user is None:
not_found(response, b'No user with ID {}'.format(user_id))
not_found(response,
'No user with ID {}'.format(user_id).encode())
return
okay(response)
else:
Expand Down
27 changes: 9 additions & 18 deletions comanage-registry-mailman/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM python:2.7-stretch
FROM python:3.6-stretch

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -29,35 +29,26 @@ RUN apt-get update \
postgresql-client \
sassc \
&& pip install --upgrade pip \
&& pip install django-allauth==0.35.0 \
django-appconf==1.0.2 \
django-compressor==2.2 \
django-extensions==2.0.7 \
django-gravatar2==1.4.2 \
django-haystack==2.8.1 \
django-mailman3==1.1.0 \
django-paintstore==0.2 \
django-picklefield==1.0.0 \
django-q==0.9.4 \
djangorestframework==3.8.2 \
&& pip install django==1.11 \
&& pip install mailmanclient==3.1.1 \
postorius==1.1.2 \
hyperkitty==1.1.4 \
django-mailman3==1.1.0 \
&& pip install django==2.1.5 \
&& pip install \
mailmanclient==3.2.1 \
postorius==1.2.3 \
hyperkitty==1.2.1 \
django-mailman3==1.2.0 \
whoosh \
uwsgi \
psycopg2 \
dj-database-url \
mysqlclient \
typing \
xapian-haystack \
&& adduser --system --no-create-home --group mailman

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web

# Overlay customized template for Postorius login
COPY login.html /usr/local/lib/python2.7/site-packages/django_mailman3/templates/account/
#COPY login.html /usr/local/lib/python2.7/site-packages/django_mailman3/templates/account/

RUN chown -R mailman:mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py
Expand Down
2 changes: 1 addition & 1 deletion comanage-registry-mailman/web/mailman-web/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys

Expand Down
19 changes: 15 additions & 4 deletions comanage-registry-mailman/web/mailman-web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

# Application definition

INSTALLED_APPS = (
INSTALLED_APPS = [
'hyperkitty',
'postorius',
'django_mailman3',
Expand All @@ -81,7 +81,6 @@
'django.contrib.staticfiles',
'rest_framework',
'django_gravatar',
'paintstore',
'compressor',
'haystack',
'django_extensions',
Expand All @@ -94,15 +93,24 @@
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.gitlab',
'allauth.socialaccount.providers.google',
)
]

# Optionally include paintstore, if it was installed with Hyperkitty.
# TODO: Remove this after a new version of Hyperkitty is released and
# neither the stable nor the rolling version needs it.
try:
import paintstore
INSTALLED_APPS.append('paintstore')
except ImportError:
pass


_MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
Expand Down Expand Up @@ -259,6 +267,7 @@

SOCIALACCOUNT_PROVIDERS = {}


# django-compressor
# https://pypi.python.org/pypi/django_compressor
#
Expand Down Expand Up @@ -378,6 +387,8 @@
'orm': 'default',
}

POSTORIUS_TEMPLATE_BASE_URL = os.environ.get('POSTORIUS_TEMPLATE_BASE_URL', 'http://mailman-web:8000')

try:
from settings_local import *
except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions comanage-registry-mailman/web/mailman-web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from django.conf.urls import include, url
from django.contrib import admin
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy
from django.views.generic import RedirectView

urlpatterns = [
Expand All @@ -31,5 +31,5 @@
url(r'', include('django_mailman3.urls')),
url(r'^accounts/', include('allauth.urls')),
# Django admin
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
]

0 comments on commit e53f518

Please sign in to comment.