Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
03f1bb9
updated for upgrade to django1.9
j1z0 Aug 20, 2016
35aacd2
splitting chapter 05 into three so moving everything accordingly
j1z0 Aug 20, 2016
4aa2d3f
code for the end of chp06 / start of chp07
j1z0 Aug 23, 2016
d793ad6
removed extra files
j1z0 Aug 23, 2016
95e2609
move old chpo8 -> old, coppied new chp07 -> chp08
j1z0 Aug 23, 2016
14b3736
working on database upgrade chapter
j1z0 Aug 23, 2016
5eafdfd
removed migrations from earlier chapters
j1z0 Aug 23, 2016
9f9e398
updated requirements file
j1z0 Aug 23, 2016
32ae7f2
added migrations so site will work
j1z0 Aug 23, 2016
87ea475
moved files into place to start chp09 rework
j1z0 Aug 24, 2016
d7b65c3
test no longer mocking database
j1z0 Aug 25, 2016
7649bb2
tests passing after adding unpaidUser table
j1z0 Aug 25, 2016
8b2982c
got basic on_commit hook working
j1z0 Aug 25, 2016
9aa414e
tests for on_commit hook
j1z0 Aug 27, 2016
57da756
juggle chapters to start upgrade of chapter10
j1z0 Aug 27, 2016
1e19893
added bootstrap and jquery
j1z0 Aug 27, 2016
ebcfe06
putting starwars fonts in place
j1z0 Sep 24, 2016
21d9e40
bootstrap hello world in place
j1z0 Sep 24, 2016
2b675e3
added in static dir lookups for css / js files
j1z0 Sep 24, 2016
9adf410
moved around templates into proper folders
j1z0 Sep 24, 2016
0757e2d
got all exercises and everythign working for chp10
j1z0 Sep 24, 2016
933dbbf
bye bye flatpages, hello app -- jinja2 to come
j1z0 Oct 12, 2016
bc4333a
added about app
j1z0 Oct 12, 2016
62a4dfb
it ain't perty, but it works, jinja2 and dwt sleeping in the same bed
j1z0 Oct 17, 2016
e672e8a
made generic function to load templating library
j1z0 Oct 18, 2016
90acc57
named template file incorrectly
j1z0 Nov 6, 2016
e13ea67
got dirs ready for chapter11
j1z0 Nov 6, 2016
a5c04bd
working on chapter 11
j1z0 Nov 6, 2016
d8f68a7
got upto statusreport working
j1z0 Nov 7, 2016
c75edec
just before exercises chapter 11
j1z0 Nov 7, 2016
e272ca3
working on exercises
j1z0 Nov 7, 2016
94b7119
got everything working for chp11 + exercises
j1z0 Nov 8, 2016
cd5a077
got dirs ready for chp12 work
j1z0 Dec 3, 2016
88edce2
added drf
j1z0 Dec 3, 2016
fb8b7e2
StatusReportSerializer working; on to the view
j1z0 Dec 3, 2016
c24e594
got status_collection REST api working with functions
j1z0 Dec 4, 2016
01b072a
finished chapter 12 just before the exercises
j1z0 Dec 5, 2016
5704e75
working on exercises
j1z0 Dec 5, 2016
0bd8a0b
all exercises for chp12 done
j1z0 Dec 5, 2016
cdad89d
moved chapters for next chapter -- MIgrations
j1z0 Jan 1, 2017
d6a7822
got migrations chapter (code in chp14 done)
j1z0 Jan 2, 2017
b72da42
updated tests
j1z0 Jan 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions _chapters/appendixB/django_ecommerce/about/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import unicode_literals

from django.apps import AppConfig


class AboutConfig(AppConfig):
name = 'about'
31 changes: 31 additions & 0 deletions _chapters/appendixB/django_ecommerce/about/jinja2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.contrib.staticfiles.storage import staticfiles_storage
# django 1.10
# from django.urls import reverse
# django 1.9
from django.core.urlresolvers import reverse
from main.templatetags.main_marketing import marketing__aboutus
from django.template.loader import get_template

from jinja2 import Environment

def environment(**options):
env = Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
'marketing__aboutus': marketing__aboutus,
'site_header': site_header,
'site_footer': site_footer,
})
return env

def site_header():
template = get_template('__head_and_nav.html', using='django')
return template.render()

def site_footer():
template = get_template('__footer.html', using='django')
return template.render()



5 changes: 5 additions & 0 deletions _chapters/appendixB/django_ecommerce/about/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import unicode_literals

from django.db import models

# Create your models here.
6 changes: 6 additions & 0 deletions _chapters/appendixB/django_ecommerce/about/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.shortcuts import render

def about(request):
return render(request, "about/about.jinja2")


Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-08-23 08:35
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='ContactForm',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150)),
('email', models.EmailField(max_length=250)),
('topic', models.CharField(max_length=200)),
('message', models.CharField(max_length=1000)),
('timestamp', models.DateTimeField(auto_now_add=True)),
],
options={
'ordering': ['-timestamp'],
},
),
]
15 changes: 15 additions & 0 deletions _chapters/appendixB/django_ecommerce/contact/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.db import models


class ContactForm(models.Model):
name = models.CharField(max_length=150)
email = models.EmailField(max_length=250)
topic = models.CharField(max_length=200)
message = models.CharField(max_length=1000)
timestamp = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.email

class Meta:
ordering = ['-timestamp']
29 changes: 29 additions & 0 deletions _chapters/appendixB/django_ecommerce/contact/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.http import HttpResponseRedirect
from .forms import ContactView
from django.contrib import messages
from django.shortcuts import render
from payments.models import User


def contact(request):
if request.method == 'POST':
form = ContactView(request.POST)
if form.is_valid():
our_form = form.save(commit=False)
our_form.save()
messages.add_message(
request, messages.INFO, 'Your message has been sent. Thank you.'
)
return HttpResponseRedirect('/')
else:
form = ContactView()

context = {'form': form}

return render(
request,
'contact/contact.html',
context,
)


89 changes: 89 additions & 0 deletions _chapters/appendixB/django_ecommerce/db_backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[
{
"model": "contenttypes.contenttype",
"pk": 1,
"fields": {
"app_label": "auth",
"model": "permission"
}
},
{
"model": "contenttypes.contenttype",
"pk": 2,
"fields": {
"app_label": "auth",
"model": "group"
}
},
{
"model": "contenttypes.contenttype",
"pk": 3,
"fields": {
"app_label": "auth",
"model": "user"
}
},
{
"model": "contenttypes.contenttype",
"pk": 4,
"fields": {
"app_label": "contenttypes",
"model": "contenttype"
}
},
{
"model": "contenttypes.contenttype",
"pk": 5,
"fields": {
"app_label": "sessions",
"model": "session"
}
},
{
"model": "contenttypes.contenttype",
"pk": 6,
"fields": {
"app_label": "sites",
"model": "site"
}
},
{
"model": "contenttypes.contenttype",
"pk": 7,
"fields": {
"app_label": "admin",
"model": "logentry"
}
},
{
"model": "contenttypes.contenttype",
"pk": 8,
"fields": {
"app_label": "flatpages",
"model": "flatpage"
}
},
{
"model": "contenttypes.contenttype",
"pk": 9,
"fields": {
"app_label": "contact",
"model": "contactform"
}
},
{
"model": "contenttypes.contenttype",
"pk": 10,
"fields": {
"app_label": "payments",
"model": "user"
}
},
{
"model": "sites.site",
"pk": 1,
"fields": {
"domain": "example.com",
"name": "example.com"
}
}]
172 changes: 172 additions & 0 deletions _chapters/appendixB/django_ecommerce/django_ecommerce/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Django settings for django_ecommerce project.

import os

DEBUG = True
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
SITE_ROOT = os.path.dirname(PROJECT_ROOT)
STRIPE_SECRET = 'sk_test_4QBquf6d5EzsnJC1fTI2GBGm'
STRIPE_PUBLISHABLE = 'pk_test_4QBqqGvCk9gaNn3pl1cwxcAS'

ADMINS = (
# ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_db',
'USER': 'djangousr',
'PASSWORD': 'your_password_here',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []

# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'

# 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

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

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''

# 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 = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (os.path.join(SITE_ROOT, 'static'),)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '!(1ty%c5a)0l0(p)kxl2igmbobx_64hqh&tv1=+s9@!@zez4o^'

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'django_ecommerce.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'django_ecommerce.wsgi.application'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'django.contrib.admin',
'contact',
'payments',
'about',
)

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'

# 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,
},
}
}

TEMPLATES = [
{
'BACKEND' : 'django.template.backends.jinja2.Jinja2',
'DIRS': [
os.path.join(SITE_ROOT, 'templates','jinja2'),
],
'OPTIONS' : {
'environment' : 'about.jinja2.environment',
},
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(SITE_ROOT, 'templates'),],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'debug': True,
},
},
]
Loading