diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index c98b29a..0000000 --- a/example/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -postorius.db -admin -static -venv diff --git a/example/README.rst b/example/README.rst deleted file mode 100644 index 0b4ee63..0000000 --- a/example/README.rst +++ /dev/null @@ -1,33 +0,0 @@ -=============================== -Running the example application -=============================== - -Assuming you use virtualenv, follow these steps to download and run the -postorius example application in this directory: - -:: - - $ git clone https://gitlab.com/mailman/postorius.git - $ cd postorius/example - $ virtualenv venv - $ . venv/bin/activate - $ pip install -r requirements.txt - -Now we need to create the database tables and an admin user. -Run the following and when prompted to create a -superuser choose yes and follow the instructions: - -:: - - $ python manage.py migrate - $ python manage.py createsuperuser - - -Now you need to run the Django development server: - -:: - - $ python manage.py runserver - -You should then be able to open your browser on http://127.0.0.1:8000 and see -postorius running. diff --git a/example/__init__.py b/example/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/example/__init__.py +++ /dev/null diff --git a/example/manage.py b/example/manage.py deleted file mode 100755 index 83bf642..0000000 --- a/example/manage.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python2 -# -*- coding: utf-8 -*- -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. -# -# This file is part of Postorius. -# -# Postorius 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. -# -# Postorius 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 -# Postorius. If not, see . -import os -import sys - -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - - from django.core.management import execute_from_command_line - - execute_from_command_line(sys.argv) diff --git a/example/requirements.txt b/example/requirements.txt deleted file mode 100644 index dabc187..0000000 --- a/example/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Django>1.8,<1.10 -# before a release replace it with the version about to be released -git+ssh://git@gitlab.com/mailman/postorius.git diff --git a/example/settings.py b/example/settings.py deleted file mode 100644 index 672bf9b..0000000 --- a/example/settings.py +++ /dev/null @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. -# -# This file is part of Postorius. -# -# Postorius 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. -# -# Postorius 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 -# Postorius. If not, see . - -""" -Django settings for postorius project. - -For more information on this file, see -https://docs.djangoproject.com/en/1.9/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.9/ref/settings/ -""" - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -import os - -BASE_DIR = os.path.dirname(os.path.abspath(__file__)) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ADMINS = ( - #('Admin', 'webmaster@example.com'), -) - -ALLOWED_HOSTS = [] - -# Mailman API credentials -MAILMAN_REST_API_URL = 'http://localhost:8001' -MAILMAN_REST_API_USER = 'restadmin' -MAILMAN_REST_API_PASS = 'restpass' - - -# Application definition - -INSTALLED_APPS = ( - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'postorius', - 'django_browserid', -) - -MIDDLEWARE_CLASSES = ( - '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', - 'postorius.middleware.PostoriusMiddleware', -) - -# Set `postorius.urls` as main url config if Postorius -# is the only app you want to serve. -ROOT_URLCONF = 'urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', - 'django.template.context_processors.csrf', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - 'postorius.context_processors.postorius', - ], - }, - }, -] - -WSGI_APPLICATION = 'wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/1.9/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'postorius.db'), - } -} - -# Password validation -# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - -# Internationalization -# https://docs.djangoproject.com/en/1.9/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.9/howto/static-files/ - - -# 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. -# Example: "/var/www/example.com/static/" -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/' - -LOGIN_URL = 'user_login' -LOGIN_REDIRECT_URL = 'list_index' -LOGOUT_URL = 'user_logout' - - -# Use the email username as identifier, but truncate it because -# the User.username field is only 30 chars long. -def username(email): - return email.rsplit('@', 1)[0][:30] -BROWSERID_USERNAME_ALGO = username - - -# Compatibility with Bootstrap 3 -from django.contrib.messages import constants as messages -MESSAGE_TAGS = { - messages.ERROR: 'danger' -} - - -AUTHENTICATION_BACKENDS = ( - 'django_browserid.auth.BrowserIDBackend', - 'django.contrib.auth.backends.ModelBackend', -) - - -# From Address for emails sent to users -DEFAULT_FROM_EMAIL = 'postorius@localhost.local' -# From Address for emails sent to admins -SERVER_EMAIL = 'root@localhost.local' - -# These can be set to override the defaults but are not mandatory: -# EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt' -# EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed' - - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler' - }, - }, - 'loggers': { - 'django': { - 'handlers': ['console'], - 'level': 'INFO', - }, - 'django_browserid': { - 'handlers': ['console'], - 'level': 'DEBUG', - }, - }, -} diff --git a/example/urls.py b/example/urls.py deleted file mode 100644 index 3dad76c..0000000 --- a/example/urls.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. -# -# This file is part of Postorius. -# -# Postorius 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. -# -# Postorius 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 -# Postorius. If not, see . - - -from django.conf.urls import include, url - -# Uncomment the next two lines to enable the admin: -from django.contrib import admin -admin.autodiscover() - -# Import mailman urls and set urlpatterns if you want to hook -# mailman_django into an existing django site. -# Otherwise set ROOT_URLCONF in settings.py to -# `mailman_django.urls`. -# from mailman_django import urls as mailman_urls - -urlpatterns = [ - url(r'^admin/', include(admin.site.urls)), - url('', include('django_browserid.urls')), - url(r'^$', 'postorius.views.list.list_index'), - url(r'^postorius/', include('postorius.urls')), -] diff --git a/example/wsgi.py b/example/wsgi.py deleted file mode 100755 index 9580f2f..0000000 --- a/example/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for meh project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - -application = get_wsgi_application() diff --git a/example_project/.gitignore b/example_project/.gitignore new file mode 100644 index 0000000..c98b29a --- /dev/null +++ b/example_project/.gitignore @@ -0,0 +1,4 @@ +postorius.db +admin +static +venv diff --git a/example_project/README.rst b/example_project/README.rst new file mode 100644 index 0000000..0b4ee63 --- /dev/null +++ b/example_project/README.rst @@ -0,0 +1,33 @@ +=============================== +Running the example application +=============================== + +Assuming you use virtualenv, follow these steps to download and run the +postorius example application in this directory: + +:: + + $ git clone https://gitlab.com/mailman/postorius.git + $ cd postorius/example + $ virtualenv venv + $ . venv/bin/activate + $ pip install -r requirements.txt + +Now we need to create the database tables and an admin user. +Run the following and when prompted to create a +superuser choose yes and follow the instructions: + +:: + + $ python manage.py migrate + $ python manage.py createsuperuser + + +Now you need to run the Django development server: + +:: + + $ python manage.py runserver + +You should then be able to open your browser on http://127.0.0.1:8000 and see +postorius running. diff --git a/example_project/__init__.py b/example_project/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example_project/__init__.py diff --git a/example_project/manage.py b/example_project/manage.py new file mode 100755 index 0000000..83bf642 --- /dev/null +++ b/example_project/manage.py @@ -0,0 +1,27 @@ +#!/usr/bin/python2 +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of Postorius. +# +# Postorius 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. +# +# Postorius 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 +# Postorius. If not, see . +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/example_project/requirements.txt b/example_project/requirements.txt new file mode 100644 index 0000000..dabc187 --- /dev/null +++ b/example_project/requirements.txt @@ -0,0 +1,3 @@ +Django>1.8,<1.10 +# before a release replace it with the version about to be released +git+ssh://git@gitlab.com/mailman/postorius.git diff --git a/example_project/settings.py b/example_project/settings.py new file mode 100644 index 0000000..672bf9b --- /dev/null +++ b/example_project/settings.py @@ -0,0 +1,220 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of Postorius. +# +# Postorius 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. +# +# Postorius 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 +# Postorius. If not, see . + +""" +Django settings for postorius project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.9/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ADMINS = ( + #('Admin', 'webmaster@example.com'), +) + +ALLOWED_HOSTS = [] + +# Mailman API credentials +MAILMAN_REST_API_URL = 'http://localhost:8001' +MAILMAN_REST_API_USER = 'restadmin' +MAILMAN_REST_API_PASS = 'restpass' + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'postorius', + 'django_browserid', +) + +MIDDLEWARE_CLASSES = ( + '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', + 'postorius.middleware.PostoriusMiddleware', +) + +# Set `postorius.urls` as main url config if Postorius +# is the only app you want to serve. +ROOT_URLCONF = 'urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.template.context_processors.csrf', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + 'postorius.context_processors.postorius', + ], + }, + }, +] + +WSGI_APPLICATION = 'wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'postorius.db'), + } +} + +# Password validation +# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + + +# 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. +# Example: "/var/www/example.com/static/" +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/' + +LOGIN_URL = 'user_login' +LOGIN_REDIRECT_URL = 'list_index' +LOGOUT_URL = 'user_logout' + + +# Use the email username as identifier, but truncate it because +# the User.username field is only 30 chars long. +def username(email): + return email.rsplit('@', 1)[0][:30] +BROWSERID_USERNAME_ALGO = username + + +# Compatibility with Bootstrap 3 +from django.contrib.messages import constants as messages +MESSAGE_TAGS = { + messages.ERROR: 'danger' +} + + +AUTHENTICATION_BACKENDS = ( + 'django_browserid.auth.BrowserIDBackend', + 'django.contrib.auth.backends.ModelBackend', +) + + +# From Address for emails sent to users +DEFAULT_FROM_EMAIL = 'postorius@localhost.local' +# From Address for emails sent to admins +SERVER_EMAIL = 'root@localhost.local' + +# These can be set to override the defaults but are not mandatory: +# EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt' +# EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed' + + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler' + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'INFO', + }, + 'django_browserid': { + 'handlers': ['console'], + 'level': 'DEBUG', + }, + }, +} diff --git a/example_project/urls.py b/example_project/urls.py new file mode 100644 index 0000000..3dad76c --- /dev/null +++ b/example_project/urls.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of Postorius. +# +# Postorius 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. +# +# Postorius 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 +# Postorius. If not, see . + + +from django.conf.urls import include, url + +# Uncomment the next two lines to enable the admin: +from django.contrib import admin +admin.autodiscover() + +# Import mailman urls and set urlpatterns if you want to hook +# mailman_django into an existing django site. +# Otherwise set ROOT_URLCONF in settings.py to +# `mailman_django.urls`. +# from mailman_django import urls as mailman_urls + +urlpatterns = [ + url(r'^admin/', include(admin.site.urls)), + url('', include('django_browserid.urls')), + url(r'^$', 'postorius.views.list.list_index'), + url(r'^postorius/', include('postorius.urls')), +] diff --git a/example_project/wsgi.py b/example_project/wsgi.py new file mode 100755 index 0000000..9580f2f --- /dev/null +++ b/example_project/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for meh project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + +application = get_wsgi_application()