Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

First attempt #1

Merged
merged 4 commits into from Jul 28, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
*.pyc
*.db
*.log
local_settings.py
test_project/things/
test_project/templates/
_templates
_static
_build
.~lock*
static/
media/
Empty file added sponsors_project/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions sponsors_project/manage.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)

import settings

if __name__ == "__main__":
execute_manager(settings)
4 changes: 4 additions & 0 deletions sponsors_project/requirements/project.txt
@@ -0,0 +1,4 @@
Django==1.3
-e git://github.com/audreyr/django-startcbv#egg=django-startcbv-0.1.0-dev
South==0.7.3

146 changes: 146 additions & 0 deletions sponsors_project/settings.py
@@ -0,0 +1,146 @@
# Django settings for pyladies_sponsors project.

import os.path

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@example.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.
# 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 = '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

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

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
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: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
STATIC_ROOT = os.path.realpath(os.path.join(PROJECT_ROOT, "static"))

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

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, "static_origin"),
)

# 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 = '5xi_6wuhe&+009whp*+yz#d=&1%j5p$u5=+)y$dm2!4$e)lc_6'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

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',
)

ROOT_URLCONF = 'sponsors_project.urls'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, "templates"),
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'startcbv',
'south',
'sponsors',
)

# 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.
# 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,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
Empty file.
12 changes: 12 additions & 0 deletions sponsors_project/sponsors/admin.py
@@ -0,0 +1,12 @@
from django.contrib import admin

from sponsors.models import Sponsor

class SponsorAdmin(admin.ModelAdmin):
list_display = ('name', 'slug', 'pub_date')
fields = ['name', 'slug', 'pub_date']
prepopulated_fields = {"slug": ("name",)}
save_on_top = True
search_fields = ['name']

admin.site.register(Sponsor, SponsorAdmin)
14 changes: 14 additions & 0 deletions sponsors_project/sponsors/models.py
@@ -0,0 +1,14 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _

class Sponsor(models.Model):
"""
Sponsor model
"""
name = models.CharField(_('Name'), max_length=200)
slug = models.SlugField()
pub_date = models.DateField(_('Date Published'))

def __unicode__(self):
return u'%s' % self.name

19 changes: 19 additions & 0 deletions sponsors_project/sponsors/urls.py
@@ -0,0 +1,19 @@
from django.conf.urls.defaults import *
from django.views.generic import DetailView, ListView
from sponsors.models import Sponsor

urlpatterns = patterns('sponsors.views',
url(regex=r'^$',
view=ListView.as_view(
queryset=Sponsor.objects.order_by('-pub_date'),
context_object_name='latest_sponsor_list',
template_name='sponsors/sponsor_list.html'),
name='sponsor_list',
),
url(regex=r'^(?P<slug>[-\w]+)/$',
view=DetailView.as_view(
model=Sponsor,
template_name='sponsors/sponsor_detail.html'),
name='sponsor_detail',
),
)
1 change: 1 addition & 0 deletions sponsors_project/sponsors/views.py
@@ -0,0 +1 @@
# Create your views here.