From 0f6843b08dcf3010e037e99f70f87616be591868 Mon Sep 17 00:00:00 2001 From: James Tauber Date: Sun, 5 Feb 2012 13:53:49 -0500 Subject: [PATCH] pinax account project --- symposion_project/__init__.py | 8 + symposion_project/apps/__init__.py | 0 symposion_project/apps/about/__init__.py | 0 symposion_project/apps/about/models.py | 3 + symposion_project/apps/about/urls.py | 11 + symposion_project/apps/about/views.py | 1 + symposion_project/fixtures/initial_data.json | 10 + symposion_project/manage.py | 20 ++ symposion_project/requirements/base.txt | 25 +++ symposion_project/requirements/project.txt | 7 + symposion_project/settings.py | 204 ++++++++++++++++++ symposion_project/static/README | 13 ++ symposion_project/templates/_footer.html | 4 + .../templates/about/what_next.html | 38 ++++ symposion_project/templates/homepage.html | 44 ++++ symposion_project/templates/site_base.html | 19 ++ symposion_project/urls.py | 29 +++ symposion_project/wsgi.py | 11 + 18 files changed, 447 insertions(+) create mode 100644 symposion_project/__init__.py create mode 100644 symposion_project/apps/__init__.py create mode 100644 symposion_project/apps/about/__init__.py create mode 100644 symposion_project/apps/about/models.py create mode 100644 symposion_project/apps/about/urls.py create mode 100644 symposion_project/apps/about/views.py create mode 100644 symposion_project/fixtures/initial_data.json create mode 100755 symposion_project/manage.py create mode 100644 symposion_project/requirements/base.txt create mode 100644 symposion_project/requirements/project.txt create mode 100644 symposion_project/settings.py create mode 100644 symposion_project/static/README create mode 100644 symposion_project/templates/_footer.html create mode 100644 symposion_project/templates/about/what_next.html create mode 100644 symposion_project/templates/homepage.html create mode 100644 symposion_project/templates/site_base.html create mode 100644 symposion_project/urls.py create mode 100644 symposion_project/wsgi.py diff --git a/symposion_project/__init__.py b/symposion_project/__init__.py new file mode 100644 index 00000000..ccd713a2 --- /dev/null +++ b/symposion_project/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +__about__ = """ +This project takes the zero_project and adds basic account management +functionality such as sign up, log in, password change/reset and email +confirmation. It is a foundation suitable for most sites that have user +accounts. +""" diff --git a/symposion_project/apps/__init__.py b/symposion_project/apps/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/symposion_project/apps/about/__init__.py b/symposion_project/apps/about/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/symposion_project/apps/about/models.py b/symposion_project/apps/about/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/symposion_project/apps/about/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/symposion_project/apps/about/urls.py b/symposion_project/apps/about/urls.py new file mode 100644 index 00000000..3b5c17ea --- /dev/null +++ b/symposion_project/apps/about/urls.py @@ -0,0 +1,11 @@ +from django.conf.urls.defaults import * +from django.views.generic.simple import direct_to_template + + +urlpatterns = patterns("", + url(r"^$", direct_to_template, {"template": "about/about.html"}, name="about"), + url(r"^terms/$", direct_to_template, {"template": "about/terms.html"}, name="terms"), + url(r"^privacy/$", direct_to_template, {"template": "about/privacy.html"}, name="privacy"), + url(r"^dmca/$", direct_to_template, {"template": "about/dmca.html"}, name="dmca"), + url(r"^what_next/$", direct_to_template, {"template": "about/what_next.html"}, name="what_next"), +) diff --git a/symposion_project/apps/about/views.py b/symposion_project/apps/about/views.py new file mode 100644 index 00000000..60f00ef0 --- /dev/null +++ b/symposion_project/apps/about/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/symposion_project/fixtures/initial_data.json b/symposion_project/fixtures/initial_data.json new file mode 100644 index 00000000..891f3860 --- /dev/null +++ b/symposion_project/fixtures/initial_data.json @@ -0,0 +1,10 @@ +[ + { + "pk": 1, + "model": "sites.site", + "fields": { + "domain": "example.com", + "name": "example.com" + } + } +] diff --git a/symposion_project/manage.py b/symposion_project/manage.py new file mode 100755 index 00000000..378e3b0b --- /dev/null +++ b/symposion_project/manage.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +import sys + +try: + import pinax +except ImportError: + sys.stderr.write("Error: Can't import Pinax. Make sure you are in a " + "virtual environment that has\nPinax installed.\n") + sys.exit(1) +else: + import pinax.env + +from django.core.management import execute_from_command_line + + +pinax.env.setup_environ(__file__) + + +if __name__ == "__main__": + execute_from_command_line() diff --git a/symposion_project/requirements/base.txt b/symposion_project/requirements/base.txt new file mode 100644 index 00000000..ba75d619 --- /dev/null +++ b/symposion_project/requirements/base.txt @@ -0,0 +1,25 @@ +# base.txt is a pip requirements file which describes the necessary +# distributions required to run this project. If you need something that is +# project specific not listed here use project.txt. You can, of course, update +# versions of distributions here if needed. + +--extra-index-url=http://dist.pinaxproject.com/dev/ +--extra-index-url=http://dist.pinaxproject.com/alpha/ +--extra-index-url=http://dist.pinaxproject.com/fresh-start/ + +Django==1.3.1 +Pinax + +django-debug-toolbar==0.9.1 +django-staticfiles==1.1.2 +django_compressor==1.0.1 + +django-mailer==0.2a1 +django-email-confirmation==0.2 +django-timezones==0.2 +pytz==2011n +django-openid==0.3a1 +python-openid==2.2.5 +metron==0.1 + +pinax-theme-bootstrap==0.1.5 diff --git a/symposion_project/requirements/project.txt b/symposion_project/requirements/project.txt new file mode 100644 index 00000000..6d8b1485 --- /dev/null +++ b/symposion_project/requirements/project.txt @@ -0,0 +1,7 @@ +# project.txt is a pip requirements file which describes the distributions +# required by your project to run. + +--requirement=base.txt + +# Put project-specific requirements here. +# See http://pip-installer.org/requirement-format.html for more information. \ No newline at end of file diff --git a/symposion_project/settings.py b/symposion_project/settings.py new file mode 100644 index 00000000..c84b830a --- /dev/null +++ b/symposion_project/settings.py @@ -0,0 +1,204 @@ +# -*- coding: utf-8 -*- +# Django settings for account project + +import os.path +import posixpath + +PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +# tells Pinax to serve media through the staticfiles app. +SERVE_MEDIA = DEBUG + +# django-compressor is turned off by default due to deployment overhead for +# most users. See for more information +COMPRESS = False + +INTERNAL_IPS = [ + "127.0.0.1", +] + +ADMINS = [ + # ("Your Name", "your_email@domain.com"), +] + +MANAGERS = ADMINS + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", # Add "postgresql_psycopg2", "postgresql", "mysql", "sqlite3" or "oracle". + "NAME": "dev.db", # Or path to database file if using sqlite3. + "USER": "", # Not used with sqlite3. + "PASSWORD": "", # Not used with sqlite3. + "HOST": "", # Set to empty string for localhost. Not used with sqlite3. + "PORT": "", # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = "US/Eastern" + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = "en-us" + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = os.path.join(PROJECT_ROOT, "site_media", "media") + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = "/site_media/media/" + +# Absolute path to the directory that holds static files like app media. +# Example: "/home/media/media.lawrence.com/apps/" +STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static") + +# URL that handles the static files like app media. +# Example: "http://media.lawrence.com" +STATIC_URL = "/site_media/static/" + +# Additional directories which hold static files +STATICFILES_DIRS = [ + os.path.join(PROJECT_ROOT, "static"), +] + +STATICFILES_FINDERS = [ + "staticfiles.finders.FileSystemFinder", + "staticfiles.finders.AppDirectoriesFinder", + "staticfiles.finders.LegacyAppDirectoriesFinder", + "compressor.finders.CompressorFinder", +] + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = posixpath.join(STATIC_URL, "admin/") + +# Subdirectory of COMPRESS_ROOT to store the cached media files in +COMPRESS_OUTPUT_DIR = "cache" + +# Make this unique, and don't share it with anybody. +SECRET_KEY = "8*br)9@fs!4nzg-imfrsst&oa2udy6z-fqtdk0*e5c1=wn)(t3" + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = [ + "django.template.loaders.filesystem.load_template_source", + "django.template.loaders.app_directories.load_template_source", +] + +MIDDLEWARE_CLASSES = [ + "django.middleware.common.CommonMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django_openid.consumer.SessionConsumer", + "django.contrib.messages.middleware.MessageMiddleware", + "pinax.apps.account.middleware.LocaleMiddleware", + "pinax.middleware.security.HideSensistiveFieldsMiddleware", + "debug_toolbar.middleware.DebugToolbarMiddleware", +] + +ROOT_URLCONF = "symposion_project.urls" + +TEMPLATE_DIRS = [ + os.path.join(PROJECT_ROOT, "templates"), +] + +TEMPLATE_CONTEXT_PROCESSORS = [ + "django.contrib.auth.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", + "django.core.context_processors.request", + "django.contrib.messages.context_processors.messages", + + "staticfiles.context_processors.static", + + "pinax.core.context_processors.pinax_settings", + + "pinax.apps.account.context_processors.account", +] + +INSTALLED_APPS = [ + # Django + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.sites", + "django.contrib.messages", + "django.contrib.humanize", + + "pinax.templatetags", + + # theme + "pinax_theme_bootstrap", + + # external + "staticfiles", + "compressor", + "debug_toolbar", + "mailer", + "django_openid", + "timezones", + "emailconfirmation", + "metron", + + # Pinax + "pinax.apps.account", + "pinax.apps.signup_codes", + + # project + "about", +] + +FIXTURE_DIRS = [ + os.path.join(PROJECT_ROOT, "fixtures"), +] + +MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage" + +EMAIL_BACKEND = "mailer.backend.DbBackend" + +ACCOUNT_OPEN_SIGNUP = True +ACCOUNT_USE_OPENID = False +ACCOUNT_REQUIRED_EMAIL = False +ACCOUNT_EMAIL_VERIFICATION = False +ACCOUNT_EMAIL_AUTHENTICATION = False +ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False + +AUTHENTICATION_BACKENDS = [ + "pinax.apps.account.auth_backends.AuthenticationBackend", +] + +LOGIN_URL = "/account/login/" # @@@ any way this can be a url name? +LOGIN_REDIRECT_URLNAME = "what_next" +LOGOUT_REDIRECT_URLNAME = "home" + +EMAIL_CONFIRMATION_DAYS = 2 +EMAIL_DEBUG = DEBUG + +DEBUG_TOOLBAR_CONFIG = { + "INTERCEPT_REDIRECTS": False, +} + +# local_settings.py can be used to override environment-specific settings +# like database and email that differ between development and production. +try: + from local_settings import * +except ImportError: + pass diff --git a/symposion_project/static/README b/symposion_project/static/README new file mode 100644 index 00000000..cd444f3c --- /dev/null +++ b/symposion_project/static/README @@ -0,0 +1,13 @@ +This directory is used to store static assets for your project. User media files +(FileFields/ImageFields) are not stored here. + +The convention for this directory is: + + * css/ — stores CSS files + * js/ — stores Javascript files + * img/ — stores image files + +This directory is accessed at /site_media/static/ in runserver when SERVE_MEDIA +is True. It is built with build_static for production environments. + +See http://pinaxproject.com/docs/dev/media.html for more information. \ No newline at end of file diff --git a/symposion_project/templates/_footer.html b/symposion_project/templates/_footer.html new file mode 100644 index 00000000..79a20fd5 --- /dev/null +++ b/symposion_project/templates/_footer.html @@ -0,0 +1,4 @@ +{% load i18n %} + \ No newline at end of file diff --git a/symposion_project/templates/about/what_next.html b/symposion_project/templates/about/what_next.html new file mode 100644 index 00000000..6ac3b548 --- /dev/null +++ b/symposion_project/templates/about/what_next.html @@ -0,0 +1,38 @@ +{% extends "site_base.html" %} + +{% load i18n %} +{% load ifsetting_tag %} + +{% block head_title %}{% trans "What Next?" %}{% endblock %} + +{% block body %} +

{% trans "What Next?" %}

+ + {% if user.is_authenticated %} +

Here are some things to do to get started with this site:

+ +
+
verify an email address
+
so you can receive notifications, reset your password and so people can find you more easily.
+ + {% ifsetting ACCOUNT_OPEN_SIGNUP %} + {% else %} + {% if user.is_staff %} +
invite more people to the site [admin only]
+
so more people can share in the fun.
+ {% endif %} + {% endifsetting %} +
+ {% else %} + {% url acct_login as login_url %} + +

+ {% ifsetting ACCOUNT_OPEN_SIGNUP %} + {% url acct_signup as signup_url %} + {% blocktrans %}Start by signing up and logging in.{% endblocktrans %} + {% else %} + {% blocktrans %}Start by logging in.{% endblocktrans %} + {% endifsetting %} +

+ {% endif %} +{% endblock %} diff --git a/symposion_project/templates/homepage.html b/symposion_project/templates/homepage.html new file mode 100644 index 00000000..962af389 --- /dev/null +++ b/symposion_project/templates/homepage.html @@ -0,0 +1,44 @@ +{% extends "banner_base.html" %} + +{% load i18n %} +{% load ifsetting_tag %} + +{% block head_title %}{% trans "Welcome" %}{% endblock %} + +{% block body_class %}home{% endblock %} + +{% block banner %} +

{% trans "Welcome to Pinax" %}

+

+ {% blocktrans %} + Pinax is a Django + project intended to provide a starting point for websites. By + integrating numerous reusable Django apps to take care of the + things that many sites have in common, it lets you focus on what + makes your site different. + {% endblocktrans %} +

+ +

About Account Project

+

+ {% blocktrans %} + This project takes the zero_project and adds basic account management + functionality such as sign up, log in, password change/reset and email + confirmation. It is a foundation suitable for most sites that have user + accounts. + {% endblocktrans %} +

+ + {% if user.is_authenticated %} + {% url what_next as what_next_url %} +

{% blocktrans %}Wondering What Next?{% endblocktrans %}

+ {% else %} + {% url acct_login as login_url %} + {% ifsetting ACCOUNT_OPEN_SIGNUP %} + {% url acct_signup as signup_url %} +

{% blocktrans %}You can Log In or Sign Up to try out the site.{% endblocktrans %}

+ {% else %} +

{% blocktrans %}You can Log In to try out the site.{% endblocktrans %}

+ {% endifsetting %} + {% endif %} +{% endblock %} diff --git a/symposion_project/templates/site_base.html b/symposion_project/templates/site_base.html new file mode 100644 index 00000000..6c811b81 --- /dev/null +++ b/symposion_project/templates/site_base.html @@ -0,0 +1,19 @@ +{% extends "theme_base.html" %} + +{% load metron_tags %} +{% load i18n %} + +{% block extra_head_base %} + {% block extra_head %}{% endblock %} +{% endblock %} + +{% block footer %} + +{% endblock %} + +{% block extra_body_base %} + {% analytics %} + {% block extra_body %}{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/symposion_project/urls.py b/symposion_project/urls.py new file mode 100644 index 00000000..e8feb4b1 --- /dev/null +++ b/symposion_project/urls.py @@ -0,0 +1,29 @@ +from django.conf import settings +from django.conf.urls.defaults import * +from django.views.generic.simple import direct_to_template + +from django.contrib import admin +admin.autodiscover() + +from pinax.apps.account.openid_consumer import PinaxConsumer + + +handler500 = "pinax.views.server_error" + + +urlpatterns = patterns("", + url(r"^$", direct_to_template, { + "template": "homepage.html", + }, name="home"), + url(r"^admin/invite_user/$", "pinax.apps.signup_codes.views.admin_invite_user", name="admin_invite_user"), + url(r"^admin/", include(admin.site.urls)), + url(r"^about/", include("about.urls")), + url(r"^account/", include("pinax.apps.account.urls")), + url(r"^openid/", include(PinaxConsumer().urls)), +) + + +if settings.SERVE_MEDIA: + urlpatterns += patterns("", + url(r"", include("staticfiles.urls")), + ) diff --git a/symposion_project/wsgi.py b/symposion_project/wsgi.py new file mode 100644 index 00000000..726e2a7b --- /dev/null +++ b/symposion_project/wsgi.py @@ -0,0 +1,11 @@ +from django.core.handlers.wsgi import WSGIHandler + +import pinax.env + + +# setup the environment for Django and Pinax +pinax.env.setup_environ(__file__) + + +# set application for WSGI processing +application = WSGIHandler() \ No newline at end of file