Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmitchel3 committed Jul 13, 2015
0 parents commit 2c29fbe
Show file tree
Hide file tree
Showing 154 changed files with 17,559 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
include/
lib/
.DS_STORE
.Python
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Coding For Entrepreneurs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
![Try Django 1.8 Logo](https://cfe-static.s3.amazonaws.com/media/try-django-18/images/try_django_18.png)

Try Django 1.8 Tutorial Series
=========

Try Django 1.8 is an introduction to [Django](http://djangoproject.com) version 1.8. This series covers a variety of Django basics as well as Django 1.8 specific material. Created by Team CFE @ [http://joincfe.com](http://joincfe.com).

The tutorial videos are available on our [YouTube channel](http://joincfe.com/youtube) and ad-free on [Coding for Entrepreneurs](http://joincfe.com/projects).


The tutorial code below is the final code from the end of each tutorial video. Each link below is tied directly to the tutorial's title. Please note that some videos will not have code reference code.

## Tutorial Code
[Template Configuration](../../tree/4d21a37f1c20f18bbee65530dd48a6c8cd31d6df)

[Models](../../tree/a88a084fd396c67f168130565584495b59495e59)

[Admin](../../tree/1ac79ed3c1c721d2e12bfea7f30508e218c3e357)

[Model Form](../../tree/c9b24d93b33b5f34b6805df2f2f381e2499912e8)

[Form Validation](../../tree/d63785c9906cc9cb0f7efc6e27cf2179e8132690)

[View & Template Context](../../tree/661647c6e50d381cd2bd8780c62d805b5a7c5946)

[Forms in Views](../../tree/6ad56c45e8cdf963c650e5333d32577aee41b473)

[Setup Email](../../tree/fe28adf2786760931ad51ad85127afde71b0fbf4)

[Static files & Serve Static Files](../../tree/773144fabc00d85df492528985a86fccd82b2215)

[Adding Bootstrap to Django](../../tree/937ffbeeba11856260898ced85b9a6e86d5de9d9)

[Django Templates - Include, Inheritance, Blocks](../../tree/1c39291e88d3ba965655bb24de9ed655ccb86fda)

[Third Party Library - Django Crispy Forms](../../tree/7c546a2c5d8e8ecbedd3d27caf54189017021af2)

[Bootstrap Grid System](../../tree/7ee93dc0b3552544743f99fd25e0b891ba855d4b)

[Styling MVP Landing Part 1](../../tree/3286b0262d87e0259a0158a07641ecbcc63519ff)

[CSS with Blocks](../../tree/6404af614c316208adc28bee50d42aa1c52e524e)

[URL Names as Links](../../tree/f5e177f7e7d8b142a77f02f38b8eb89cbb669c29)

[Styling MVP Landing Part 2](../../tree/35c5a6eeb27bbda877548d5470410a6cb238f16e)

[Django Registration Redux *Start*](../../tree/0c71e7f565e0a5aeddb7c44bbb99bd90a9ad6722)

[Django Registration Redux - *Done*](../../tree/62696aa2d90725036b04e550d4056dbc86f7bbc9)

[Update Django Login URL to Custom URL](../../tree/4e0b620b55067d6e1b77e28faa07d04ace2de31b)

[Authentication Links in the Navbar](../../tree/023e7d53b4635a017c42a8f694a4d9203024d58b)

[Login Form in Bootstrap Navbar](../../tree/96b214261c97fa36cb0dd6952a7432478cef9d26)

[Styling MVP Landing Part 3](../../tree/537018c9ca1bc9eb5c9a836d2ba578cee19fe066)

[Logo Image in Navbar](../../tree/2ca0848f959bbfad855478e4ce2c524d20e320a4)

[Promo Video & Images](../../tree/b4a5151a07750b34c21d2e65a6af6c259ed441c5)

[Icons with Font Awesome](../../tree/e1f215fd493b34d957b38398e9cae4b22c02bee8)

[Content for Authenticated Users](../../tree/318281f6ba98dece8446555718a8a978a03d1ca8)

[QuerySet Basics](../../tree/0d50de62cac7b01465fd654400d7d2c2a012c7a8)

[Settings for Different Environments](../../tree/d8f6e8587b58217f4e1530a925cc7ec9b31a5f57)

[Using SSH with WebFaction](../../tree/e13aa28b0785f979c5c4278746486d739fc0d6a8)

[FTP for Production Settings](../../tree/dc30a0e33271af6141008bef2da9943adc2eacc7)

[Fix Static Settings](../../tree/7d24e9780c7b737aeeab7ddf9e2098c721ea5eb7)

[Final Code](../../tree/4ec82937b63e2e2c9441769dce7cc1a5bc393f28)

6 changes: 6 additions & 0 deletions deals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Webfaction Sign-Up Deals (full disclosure: these are affiliate links):


2 months for the price of 1 (50% off): http://bit.ly/1hxMgmn
1 year for the price of 6 months (50% off): http://bit.ly/cfe12
3 years, 65% off: http://bit.ly/cfe36
1 change: 1 addition & 0 deletions pip-selfcheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"last_check":"2015-07-13T18:37:50Z","pypi_version":"7.1.0"}
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trydjango18/settings/db_password.py
Binary file added src/db.sqlite3
Binary file not shown.
10 changes: 10 additions & 0 deletions src/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trydjango18.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file added src/newsletter/__init__.py
Empty file.
Binary file added src/newsletter/__init__.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions src/newsletter/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.contrib import admin

# Register your models here.

from .forms import SignUpForm
from .models import SignUp

class SignUpAdmin(admin.ModelAdmin):
list_display = ["__unicode__", "timestamp", "updated"]
form = SignUpForm
# class Meta:
# model = SignUp



admin.site.register(SignUp, SignUpAdmin)
Binary file added src/newsletter/admin.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions src/newsletter/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django import forms

from .models import SignUp

class ContactForm(forms.Form):
full_name = forms.CharField(required=False)
email = forms.EmailField()
message = forms.CharField()


class SignUpForm(forms.ModelForm):
class Meta:
model = SignUp
fields = ['full_name', 'email']
### exclude = ['full_name']

def clean_email(self):
email = self.cleaned_data.get('email')
email_base, provider = email.split("@")
domain, extension = provider.split('.')
# if not domain == 'USC':
# raise forms.ValidationError("Please make sure you use your USC email.")
if not extension == "edu":
raise forms.ValidationError("Please use a valid .EDU email address")
return email

def clean_full_name(self):
full_name = self.cleaned_data.get('full_name')
#write validation code.
return full_name
Binary file added src/newsletter/forms.pyc
Binary file not shown.
23 changes: 23 additions & 0 deletions src/newsletter/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='SignUp',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('email', models.EmailField(max_length=254)),
('full_name', models.CharField(max_length=120, null=True, blank=True)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
],
),
]
Binary file added src/newsletter/migrations/0001_initial.pyc
Binary file not shown.
Empty file.
Binary file added src/newsletter/migrations/__init__.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions src/newsletter/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models

# Create your models here.
class SignUp(models.Model):
email = models.EmailField()
full_name = models.CharField(max_length=120, blank=True, null=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)

def __unicode__(self): #Python 3.3 is __str__
return self.email
Binary file added src/newsletter/models.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions src/newsletter/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
100 changes: 100 additions & 0 deletions src/newsletter/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from django.conf import settings
from django.core.mail import send_mail
from django.shortcuts import render

from .forms import ContactForm, SignUpForm
from .models import SignUp

# Create your views here.
def home(request):
title = 'Sign Up Now'
form = SignUpForm(request.POST or None)
context = {
"title": title,
"form": form
}
if form.is_valid():
#form.save()
#print request.POST['email'] #not recommended
instance = form.save(commit=False)

full_name = form.cleaned_data.get("full_name")
if not full_name:
full_name = "New full name"
instance.full_name = full_name
# if not instance.full_name:
# instance.full_name = "Justin"
instance.save()
context = {
"title": "Thank you"
}

if request.user.is_authenticated() and request.user.is_staff:
#print(SignUp.objects.all())
# i = 1
# for instance in SignUp.objects.all():
# print(i)
# print(instance.full_name)
# i += 1

queryset = SignUp.objects.all().order_by('-timestamp') #.filter(full_name__iexact="Justin")
#print(SignUp.objects.all().order_by('-timestamp').filter(full_name__iexact="Justin").count())
context = {
"queryset": queryset
}

return render(request, "home.html", context)



def contact(request):
title = 'Contact Us'
title_align_center = True
form = ContactForm(request.POST or None)
if form.is_valid():
# for key, value in form.cleaned_data.iteritems():
# print key, value
# #print form.cleaned_data.get(key)
form_email = form.cleaned_data.get("email")
form_message = form.cleaned_data.get("message")
form_full_name = form.cleaned_data.get("full_name")
# print email, message, full_name
subject = 'Site contact form'
from_email = settings.EMAIL_HOST_USER
to_email = [from_email, 'youotheremail@email.com']
contact_message = "%s: %s via %s"%(
form_full_name,
form_message,
form_email)
some_html_message = """
<h1>hello</h1>
"""
send_mail(subject,
contact_message,
from_email,
to_email,
html_message=some_html_message,
fail_silently=True)

context = {
"form": form,
"title": title,
"title_align_center": title_align_center,
}
return render(request, "forms.html", context)
















Binary file added src/newsletter/views.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cffi==1.1.2
cryptography==0.9.3
Django==1.8.3
django-crispy-forms==1.4.0
django-registration-redux==1.2
enum34==1.0.4
idna==2.0
ipaddress==1.0.11
ndg-httpsclient==0.4.0
pyasn1==0.1.8
pycparser==2.14
pyOpenSSL==0.15.1
requests==2.7.0
six==1.9.0
wheel==0.24.0
5 changes: 5 additions & 0 deletions src/static_in_pro/our_static/css/bootstrap.min.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/static_in_pro/our_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.text-align-center {
text-align: center;
}
33 changes: 33 additions & 0 deletions src/static_in_pro/our_static/css/navbar-static-top.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
body {
min-height: 1000px;
}

.navbar-static-top {
margin-bottom: 19px;
background-color: #0E3D14;
border-color: #1A5F23;
}

.navbar-default .navbar-brand {
color: #FFF;
}

.navbar-default .navbar-brand:hover {
color: #777;
}

.navbar-default .navbar-nav>li>a:hover {
color: #999;
}

.navbar-default .navbar-toggle {
border-color: transparent !important;
}

.navbar-toggle:hover {
background-color: #1A5F23 !important;
}

.navbar-toggle {
background-color: #0E3D14 !important;
}
Empty file.
Binary file added src/static_in_pro/our_static/img/marketing1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/static_in_pro/our_static/js/bootstrap.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2c29fbe

Please sign in to comment.