Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added bockus/bockus/__init__.py
Empty file.
1 change: 1 addition & 0 deletions bockus/bockus/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'kelseyhawley'
85 changes: 85 additions & 0 deletions bockus/bockus/settings/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""
Django settings for bockus project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "abc123"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'books',
'profiles',
'usercollections',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'bockus.urls'

WSGI_APPLICATION = 'bockus.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/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.6/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions bockus/bockus/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os

from base import *

SECRET_KEY = os.environ["SECRET_KEY"]

DEBUG = True
TEMPLATE_DEBUG = DEBUG

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "bockus",
"USER": "",
"PASSWORD": "",
"HOST": "localhost",
"PORT": "",
}
}

INSTALLED_APPS += ("debug_toolbar",)
12 changes: 12 additions & 0 deletions bockus/bockus/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'bockus.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
14 changes: 14 additions & 0 deletions bockus/bockus/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
WSGI config for bockus 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.6/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bockus.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Empty file added bockus/books/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions bockus/books/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
30 changes: 30 additions & 0 deletions bockus/books/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.db import models


COVER_TYPE_CHOICES = (
("Front", "Front"),
("Spine", "Spine"),
("Back", "Back"),
("Full", "Full - Front, Spine & Back"),
)

class Book(models.Model):
title = models.CharField(max_length=255)
author_first_name = models.CharField(max_length=100)
author_last_name = models.CharField(max_length=100)
summary = models.TextField()

def __str__(self):
return self.title + " by " + self.author_last_name + ", " + self.author_first_name

class Cover(models.Model):
book = models.ForeignKey(Book)
publisher = models.CharField(max_length=25)
publish_date = models.DateField()
# image = models.ImageField(upload_to="book_covers")
type = models.CharField(max_length=10, choices=COVER_TYPE_CHOICES)

def __str__(self):
return self.type + " - " + self.book.title + " by " + \
self.book.author_last_name + ", " + self.book.author_first_name

3 changes: 3 additions & 0 deletions bockus/books/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.
3 changes: 3 additions & 0 deletions bockus/books/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
10 changes: 10 additions & 0 deletions bockus/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", "bockus.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file.
3 changes: 3 additions & 0 deletions bockus/usercollections/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
32 changes: 32 additions & 0 deletions bockus/usercollections/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.db import models
from django.contrib.auth.models import User

from books.models import Book, Cover

class UserBook(models.Model):
user = models.ForeignKey(User)
book = models.ForeignKey(Book)
cover = models.ForeignKey(Cover)
rating = models.PositiveSmallIntegerField(max_length=5)

class Tag(models.Model):
name = models.CharField(max_length=25)

# create intermediary manytomany table
# https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany
books = models.ManyToManyField(UserBook, through="TaggedUserBook")

# self referencing ManyToMany stack-overflow question
# http://stackoverflow.com/questions/3880489/how-do-i-write-a-django-model-with-manytomany-relationsship-with-self-through-a
groups = models.ManyToManyField('self', through="TagGroup", symmetrical=False)


class TaggedUserBook(models.Model):
userBook = models.ForeignKey(UserBook)
tag = models.ForeignKey(Tag)
order_in_tag_list = models.PositiveIntegerField()

class TagGroup(models.Model):
parent = models.ForeignKey(Tag, related_name='parent')
child = models.ForeignKey(Tag, related_name='child')
order_in_parent_list = models.PositiveIntegerField()
3 changes: 3 additions & 0 deletions bockus/usercollections/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.
3 changes: 3 additions & 0 deletions bockus/usercollections/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Django==1.7
django-debug-toolbar==1.2.1
psycopg2==2.5.4
sqlparse==0.1.11
wsgiref==0.1.2