Changeset - 3334d6976ec9
[Not reviewed]
Merge
0 4 2
Christopher Neugebauer - 7 years ago 2017-08-18 17:51:33
chrisjrn@gmail.com
Merge branch 'master' into prod
6 files changed with 119 insertions and 7 deletions:
0 comments (0 inline, 0 general)
fixtures/sitetree.json
Show inline comments
...
 
@@ -304,98 +304,98 @@
 
        "url": "/sponsors/become-a-sponsor",
 
        "urlaspattern": false,
 
        "tree": 1,
 
        "hidden": false,
 
        "alias": null,
 
        "description": "",
 
        "inmenu": true,
 
        "inbreadcrumbs": true,
 
        "insitetree": true,
 
        "access_loggedin": false,
 
        "access_guest": false,
 
        "access_restricted": false,
 
        "access_perm_type": 1,
 
        "parent": 3,
 
        "sort_order": 22,
 
        "access_permissions": []
 
    }
 
},
 
{
 
    "model": "sitetree.treeitem",
 
    "pk": 24,
 
    "fields": {
 
        "title": "Program",
 
        "hint": "",
 
        "url": "/program",
 
        "urlaspattern": false,
 
        "tree": 1,
 
        "hidden": true,
 
        "alias": null,
 
        "description": "",
 
        "inmenu": true,
 
        "inbreadcrumbs": true,
 
        "insitetree": true,
 
        "access_loggedin": false,
 
        "access_guest": false,
 
        "access_restricted": false,
 
        "access_perm_type": 1,
 
        "parent": null,
 
        "sort_order": 7,
 
        "access_permissions": []
 
    }
 
},
 
{
 
    "model": "sitetree.treeitem",
 
    "pk": 25,
 
    "fields": {
 
        "title": "Log In",
 
        "hint": "",
 
        "url": "/account/login/",
 
        "urlaspattern": false,
 
        "url": "nbpy_login",
 
        "urlaspattern": true,
 
        "tree": 1,
 
        "hidden": false,
 
        "alias": null,
 
        "description": "",
 
        "inmenu": true,
 
        "inbreadcrumbs": true,
 
        "insitetree": true,
 
        "access_loggedin": false,
 
        "access_guest": true,
 
        "access_restricted": false,
 
        "access_perm_type": 1,
 
        "parent": null,
 
        "sort_order": 26,
 
        "access_permissions": []
 
    }
 
},
 
{
 
    "model": "sitetree.treeitem",
 
    "pk": 26,
 
    "fields": {
 
        "title": "My Account",
 
        "hint": "",
 
        "url": "/dashboard",
 
        "urlaspattern": false,
 
        "tree": 1,
 
        "hidden": false,
 
        "alias": null,
 
        "description": "",
 
        "inmenu": true,
 
        "inbreadcrumbs": true,
 
        "insitetree": true,
 
        "access_loggedin": true,
 
        "access_guest": false,
 
        "access_restricted": false,
 
        "access_perm_type": 1,
 
        "parent": null,
 
        "sort_order": 29,
 
        "access_permissions": []
 
    }
 
},
 
{
 
    "model": "sitetree.treeitem",
 
    "pk": 27,
 
    "fields": {
 
        "title": "Dashboard",
 
        "hint": "",
 
        "url": "/dashboard",
 
        "urlaspattern": false,
pinaxcon/account_hooks.py
Show inline comments
 
new file 100644
 
from account import hooks
 
from django.contrib.auth.models import User
 

	
 

	
 
class BetterAccountHookSet(hooks.AccountDefaultHookSet):
 

	
 
    def get_user_credentials(self, form, identifier_field):
 
        username = form.cleaned_data[identifier_field]
 

	
 
        # Find an actual username so we can authenticate
 
        print username,
 
        if identifier_field == "email":
 
            username = self.get_username_by_email(username)
 
        print username,
 

	
 
        return {
 
            "username": username,
 
            "password": form.cleaned_data["password"],
 
        }
 

	
 
    def get_username_by_email(self, email):
 
        try:
 
            return User.objects.get(email=email).username
 
        except User.DoesNotExist:
 
            return None
pinaxcon/settings.py
Show inline comments
 
import os
 
import dj_database_url
 

	
 

	
 
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
 
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
 
BASE_DIR = PACKAGE_ROOT
 

	
 
DEBUG = bool(int(os.environ.get("DEBUG", "1")))
 

	
 
DATABASES = {
 
    "default": {
 
        "ENGINE": "django.db.backends.sqlite3",
 
        "NAME": os.path.join(PROJECT_ROOT, "dev.db"),
 
    }
 
}
 

	
 
UNPREPEND_WWW = bool(os.environ.get("DJANGO_UNPREPEND_WWW", False))
 
UNPREPEND_WWW = bool(int(os.environ.get("DJANGO_UNPREPEND_WWW", "0")))
 

	
 
# HEROKU: Update database configuration with $DATABASE_URL.
 
import dj_database_url
 
db_from_env = dj_database_url.config()
 
DATABASES['default'].update(db_from_env)
 

	
 
ALLOWED_HOSTS = [".localhost", ".herokuapp.com", ".northbaypython.org"]
 
CANONICAL_HOST = os.environ.get("DJANGO_CANONICAL_HOST", None)
 

	
 
# If DEFAULT_FROM_EMAIL is not set, email will most likely break in prod.
 
from_email = os.environ.get("DJANGO_DEFAULT_FROM_EMAIL", None)
 
if from_email is not None:
 
    DEFAULT_FROM_EMAIL = from_email
 

	
 
# 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.
 
# On Unix systems, a value of None will cause Django to use the same
 
# timezone as the operating system.
 
# If running in a Windows environment this must be set to the same as your
 
# system time zone.
 
TIME_ZONE = os.environ.get("TZ", "America/Los_Angeles")
 

	
 

	
 
# Set the email address that will receive errors.
 
admin_email = os.environ.get("DJANGO_ADMIN_EMAIL", None)
 
if admin_email is not None:
 
    ADMINS = ("Webmaster", admin_email)
 

	
 

	
 
# Use SSLRedirectMiddleware
 
SSL_ON = os.environ.get("DJANGO_SSL_ON", True)
 
SSL_ALWAYS = os.environ.get("DJANGO_SSL_ALWAYS", False)
 

	
 
# 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 = int(os.environ.get("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
 

	
 
# If you set this to False, Django will not format dates, numbers and
 
# calendars according to the current locale.
 
USE_L10N = True
 

	
...
 
@@ -213,107 +213,111 @@ INSTALLED_APPS = [
 
    # stylesheets and js
 
    'compressor',
 
]
 

	
 
# A sample logging configuration. The only tangible logging
 
# performed by this configuration is to send an email to
 
# the site admins on every HTTP 500 error when DEBUG=False.
 
# See http://docs.djangoproject.com/en/dev/topics/logging for
 
# more details on how to customize your logging configuration.
 
LOGGING = {
 
    "version": 1,
 
    "disable_existing_loggers": False,
 
    "filters": {
 
        "require_debug_false": {
 
            "()": "django.utils.log.RequireDebugFalse"
 
        }
 
    },
 
    "handlers": {
 
        "mail_admins": {
 
            "level": "ERROR",
 
            "filters": ["require_debug_false"],
 
            "class": "django.utils.log.AdminEmailHandler"
 
        }
 
    },
 
    "loggers": {
 
        "django.request": {
 
            "handlers": ["mail_admins"],
 
            "level": "ERROR",
 
            "propagate": True,
 
        },
 
    }
 
}
 

	
 
COMPRESS_PRECOMPILERS = (
 
    ('text/x-scss', 'django_libsass.SassCompiler'),
 
)
 

	
 
FIXTURE_DIRS = [
 
    os.path.join(PROJECT_ROOT, "fixtures"),
 
]
 

	
 
# Heroku: Get email configuration from environment variables.
 

	
 
EMAIL_BACKEND = os.environ.get("DJANGO_EMAIL_BACKEND", "django.core.mail.backends.console.EmailBackend")  # noqa
 
EMAIL_HOST = os.environ.get("DJANGO_EMAIL_HOST", "")
 
EMAIL_PORT = int(os.environ.get("DJANGO_EMAIL_PORT", 25))
 
EMAIL_HOST_USER = os.environ.get("DJANGO_EMAIL_HOST_USER", "")
 
EMAIL_HOST_PASSWORD = os.environ.get("DJANGO_EMAIL_HOST_PASSWORD", "")
 
EMAIL_USE_TLS = bool(os.environ.get("DJANGO_EMAIL_USE_TLS", False))
 
EMAIL_USE_SSL = bool(os.environ.get("DJANGO_EMAIL_USE_SSL", False))
 
EMAIL_USE_TLS = bool(int(os.environ.get("DJANGO_EMAIL_USE_TLS", "0")))
 
EMAIL_USE_SSL = bool(int(os.environ.get("DJANGO_EMAIL_USE_SSL", "0")))
 

	
 
ACCOUNT_LOGIN_URL = "nbpy_login"
 
LOGIN_URL = "nbpy_login"
 

	
 
# We need to explicitly switch on signups.
 
ACCOUNT_OPEN_SIGNUP = bool(os.environ.get("DJANGO_ACCOUNT_OPEN_SIGNUP", False))
 
ACCOUNT_OPEN_SIGNUP = bool(int(os.environ.get("DJANGO_ACCOUNT_OPEN_SIGNUP", "0")))
 
ACCOUNT_EMAIL_UNIQUE = True
 
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False if DEBUG else True
 
ACCOUNT_LOGIN_REDIRECT_URL = "home"
 
ACCOUNT_LOGIN_REDIRECT_URL = "dashboard"
 
ACCOUNT_LOGOUT_REDIRECT_URL = "home"
 
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2
 
ACCOUNT_USE_AUTH_AUTHENTICATE = True
 
ACCOUNT_HOOKSET =  "pinaxcon.account_hooks.BetterAccountHookSet"
 

	
 
AUTHENTICATION_BACKENDS = [
 
    "symposion.teams.backends.TeamPermissionsBackend",
 
    "account.auth_backends.UsernameAuthenticationBackend",
 
]
 

	
 
CONFERENCE_ID = 1
 
PROPOSAL_FORMS = {
 
    "talk": "pinaxcon.proposals.forms.TalkProposalForm",
 
}
 
PINAX_PAGES_HOOKSET = "pinaxcon.hooks.PinaxPagesHookSet"
 
PINAX_BOXES_HOOKSET = "pinaxcon.hooks.PinaxBoxesHookSet"
 

	
 
PINAX_STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "your test public key")
 
PINAX_STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "your test secret key")
 
PINAX_STRIPE_SEND_EMAIL_RECEIPTS = False
 

	
 
SYMPOSION_SPEAKER_MODEL = "pinaxcon.proposals.models.ConferenceSpeaker"
 
SYMPOSION_SPEAKER_FORM = "pinaxcon.proposals.forms.ConferenceSpeakerForm"
 

	
 
# Registrasion Attendee profile model
 
ATTENDEE_PROFILE_MODEL = "pinaxcon.registrasion.models.AttendeeProfile"
 
# Registrasion attendee profile form -- must act on ATTENDEE_PROFILE_FORM
 
# You only need to provide this if you're customising the form from the default
 
# ATTENDEE_PROFILE_FORM = "pinaxcon.registrasion.forms.ProfileForm"
 

	
 
# Ticket product category -- used to identify which products must be available
 
# in order to register.
 
TICKET_PRODUCT_CATEGORY = 1
 

	
 

	
 
INVOICE_CURRENCY = "AUD"
 

	
 
# Use nose to run all tests
 
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
 

	
 

	
 
# Tell nose to measure coverage on the 'foo' and 'bar' apps
 
NOSE_ARGS = [
 
    '--with-coverage',
 
    '--cover-package=registrasion.controllers,registrasion.models',
 
]
 

	
 
MARKDOWN_DEUX_STYLES = {
 
    "default": {
 
        "safe_mode": False,
 
    },
 
}
pinaxcon/templates/account_login.html
Show inline comments
 
new file 100644
 
{% extends "page_with_title_and_lede.html" %}
 

	
 
{% load bootstrap %}
 
{% load i18n %}
 

	
 
{% block head_title %}Log In{% endblock %}
 

	
 
{% block heading %}Log In or Sign Up{% endblock %}
 

	
 
{% block body_class %}login{% endblock %}
 

	
 
{% block content %}
 

	
 
  <div class="container">
 
    <div class="row">
 
      <div class="col-md-4">
 

	
 
        <form action="{% url 'account_login' %}" method="POST">
 
          <div class="panel panel-primary">
 
            <div class="panel-heading">
 
              <h3 class="panel-title">
 
                Log into an existing account
 
              </h3>
 
            </div>
 
            <div class="panel-body">
 
              {% csrf_token %}
 
              {{ login_form|bootstrap }}
 
            </div>
 
            <div class="panel-footer">
 
              <button role="submit" class="btn btn-primary">Log In</button>
 
            </div>
 
          </div>
 
        </form>
 

	
 
      </div>
 
      {% if signup_open %}
 
        <div class="col-md-4">
 
          <form action="{% url 'account_signup' %}" method="POST">
 
            <div class="panel panel-default">
 
              <div class="panel-heading">
 
                <h3 class="panel-title">
 
                  Sign up for a new account
 
                </h3>
 
              </div>
 
              <div class="panel-body">
 
                {% csrf_token %}
 
                {{ signup_form|bootstrap }}
 
              </div>
 
              <div class="panel-footer">
 
                <button role="submit" class="btn btn-primary">Sign Up</button>
 
              </div>
 
            </div>
 
          </form>
 
        </div>
 
      {% endif %}
 
    </div>
 
  </div>
 

	
 
{% endblock %}
pinaxcon/urls.py
Show inline comments
...
 
@@ -7,77 +7,80 @@ from django.views.generic import RedirectView
 

	
 
from django.contrib import admin
 

	
 
from pinaxcon import views
 

	
 
import symposion.views
 

	
 

	
 
urlpatterns = [
 
    url(r"^$", TemplateView.as_view(template_name="static_pages/homepage.html"), name="home"),
 

	
 
    # about
 
    url(r"^about/north-bay-python$", TemplateView.as_view(template_name="static_pages/about/north_bay_python.html"), name="about/north-bay-python"),
 
    # TODO add /about/the-mystic
 
    # TODO add /about/petaluma
 
    url(r"^about/team$", TemplateView.as_view(template_name="static_pages/about/team.html"), name="about/team"),
 
    url(r"^about/colophon$", TemplateView.as_view(template_name="static_pages/about/colophon.html"), name="about/colophon"),
 

	
 
    # program
 
    # TODO add /program/sessions
 
    # TODO add /program/events
 
    url(r"^program/call-for-proposals$", TemplateView.as_view(template_name="static_pages/program/call_for_proposals.html"), name="program/call-for-proposals"),
 
    url(r"^program/selection-process$", TemplateView.as_view(template_name="static_pages/program/selection_process.html"), name="program/selection-process"),
 

	
 
    # attend
 
    # TODO add /attend/buy-a-ticket
 
    # TODO add /attend/volunteer
 
    # TODO add /attend/financial-assistance
 
    # TODO add /attend/how-to-pitch-your-manager
 
    # TODO add /attend/how-to-get-here
 
    # TODO add /attend/where-to-stay
 
    url(r"^code-of-conduct$", TemplateView.as_view(template_name="static_pages/code_of_conduct/code_of_conduct.html"), name="code-of-conduct"),
 
    url(r"^code-of-conduct/harassment-incidents$", TemplateView.as_view(template_name="static_pages/code_of_conduct/harassment_procedure_attendee.html"), name="code-of-conduct/harassment-incidents"),
 
    url(r"^code-of-conduct/harassment-staff-procedures$", TemplateView.as_view(template_name="static_pages/code_of_conduct/harassment_procedure_staff.html"), name="code-of-conduct/harassment-staff-procedures"),
 
    url(r"^terms-and-conditions$", TemplateView.as_view(template_name="static_pages/terms_and_conditions.html"), name="terms-and-conditions"),
 

	
 
    # sponsor
 
    url(r"^sponsors/prospectus$", RedirectView.as_view(url=_static("assets/northbaypython_prospectus.pdf")), name="sponsors/prospectus"),
 
    url(r"^northbaypython_prospectus.pdf$", RedirectView.as_view(url=_static("assets/northbaypython_prospectus.pdf")), name="northbaypython_prospectus.pdf"),
 
    url(r"^sponsors/become-a-sponsor$", TemplateView.as_view(template_name="static_pages/sponsors/become_a_sponsor.html"), name="sponsors/become-a-sponsor"),
 

	
 
    # news
 
    url(r"^news$", TemplateView.as_view(template_name="static_pages/news.html"), name="news"),
 

	
 
    # Django, Symposion, and Registrasion URLs
 

	
 
    url(r"^admin/", include(admin.site.urls)),
 

	
 
    url(r"^login$", views.account_login, name="nbpy_login"),
 
    # Override the default account_login view with one that takes email addys
 
    url(r"^account/login/$", views.EmailLoginView.as_view(), name="account_login"),
 
    url(r"^account/", include("account.urls")),
 

	
 
    url(r"^dashboard/", symposion.views.dashboard, name="dashboard"),
 

	
 
    url(r"^speaker/", include("symposion.speakers.urls")),
 
    url(r"^proposals/", include("symposion.proposals.urls")),
 
    url(r"^sponsors/", include("symposion.sponsorship.urls")),
 
    url(r"^reviews/", include("symposion.reviews.urls")),
 
    url(r"^schedule/", include("symposion.schedule.urls")),
 

	
 
    url(r"^teams/", include("symposion.teams.urls")),
 

	
 
    # Demo payment gateway and related features
 
    url(r"^register/pinaxcon/", include("pinaxcon.registrasion.urls")),
 

	
 
    # Demo payment gateway and related features
 
    url(r"^register/payments/", include("registripe.urls")),
 

	
 
    # Required by registrasion
 
    url(r'^register/', include('registrasion.urls')),
 
    url(r'^nested_admin/', include('nested_admin.urls')),
 

	
 
    # Catch-all MUST go last.
 
    #url(r"^", include("pinax.pages.urls")),
 
]
 

	
 
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
 

	
 
handler500 = views.server_error
pinaxcon/views.py
Show inline comments
 
from django.conf import settings
 
from django.http import HttpResponseServerError
 
from django.shortcuts import render
 
from django.template import RequestContext
 
from django.template import Template
 
from django.template.loader import get_template
 
from django.views import defaults
 

	
 
from account.forms import LoginEmailForm, LoginUsernameForm, SignupForm
 
from account.views import LoginView
 

	
 
def server_error(request, template_name=defaults.ERROR_500_TEMPLATE_NAME):
 
    t = Template("{%% include '%s' %%}" % template_name)
 
    return HttpResponseServerError(t.render(RequestContext(request)))
 

	
 

	
 
def account_login(request):
 

	
 
    d = {
 
        "login_form": LoginEmailForm(),
 
        "signup_form": SignupForm(),
 
        "signup_open": getattr(settings, "ACCOUNT_OPEN_SIGNUP", True),
 
    }
 

	
 
    print d["signup_open"], settings.ACCOUNT_OPEN_SIGNUP
 
    return render(request, "account_login.html", d)
 

	
 

	
 
class EmailLoginView(LoginView):
 
    form_class = LoginEmailForm
0 comments (0 inline, 0 general)