Browse Source

Adicionado template para settings e suporte para databrowse.

0.2
Guilherme Gondim 17 years ago
parent
commit
bfdf66e261
  1. 50
      sigi/local_settings.template
  2. 103
      sigi/settings.py
  3. 38
      sigi/urls.py

50
sigi/local_settings.template

@ -0,0 +1,50 @@
# LOCAL SETTINGS -*- Mode: Python; -*-
# ---------------------------------------------------------------------
#
# Template of Django settings for local user. Copy to local_settings.py
# and make your necessary changes.
#
##################################
## TEMPLATE FOR DEVELOPMENT USE ##
##################################
#DEBUG = True
#TEMPLATE_DEBUG = DEBUG
####################################
## TEMPLATE FOR USE IN PRODUCTION ##
####################################
#DEBUG = False
#TEMPLATE_DEBUG = DEBUG
#MAINTENANCE = True
#ADMINS = (('root', 'root@localhost'),)
#MANAGERS = ADMINS
#SERVER_EMAIL = 'root@localhost'
#DEFAULT_FROM_EMAIL = 'noreply@localhost'
#SEND_BROKEN_LINK_EMAILS = True
#EMAIL_HOST = 'smtp.otherhost.net'
#INTERNAL_IPS = ('127.0.0.1',)
#DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql',
# 'mysql', 'sqlite3' or 'ado_mssql'.
#DATABASE_NAME = 'mydbname' # not used with SQLite
#DATABASE_USER = 'mydbuser' # not used with SQLite
#DATABASE_PASSWORD = 'mydbpassword' # not used with SQLite
#DATABASE_HOST = 'localhost' # not used with SQLite
#DATABASE_PORT = '' # Empty for default. Not used with SQLite.
#SESSION_EXPIRE_AT_BROWSER_CLOSE = True
#CACHE_BACKEND = 'file:///var/tmp/sigi_cache'
# Used to provide a seed in secret-key hashing algorithms. Set this to
# a random string - the longer, the better.
#SECRET_KEY = 'random-ascii-string'

103
sigi/settings.py

@ -1,84 +1,90 @@
# Django settings for SIGI project. #
# Default Django settings for SIGI.
#
# (!!!)
#
# DON'T CHANGE THIS FILE, USE local_settings.py. YOU GET A TEMPLATE IN
# local_settings.template (COPY HIM TO local_settings.py AND MAKE YOUR
# NECESSARY CHANGES.
#
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '../..')
PROJECT_DIR = BASE_DIR + '/sigi'
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
MAINTENANCE = False
ADMINS = ( # I can't determine this, use local_settings.py.
# ('Your Name', 'your_email@domain.com'), ADMINS = (('root', 'root@localhost'),)
)
MANAGERS = ADMINS MANAGERS = ADMINS
SERVER_EMAIL = 'root@localhost'
DEFAULT_FROM_EMAIL = 'noreply@localhost'
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. INTERNAL_IPS = ('127.0.0.1',)
DATABASE_NAME = 'devel.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_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.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Sao_Paulo'
# Language code for this installation. All choices can be found here: DATABASE_ENGINE = 'sqlite3'
# http://www.i18nguy.com/unicode/language-identifiers.html DATABASE_NAME = BASE_DIR + '/devel.db'
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Sao_Paulo'
LANGUAGE_CODE = 'pt-br'
SITE_ID = 1 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 USE_I18N = True
# Absolute path to the directory that holds media. MEDIA_ROOT = BASE_DIR + '/media/'
# Example: "/home/media/media.lawrence.com/" MEDIA_URL = '/media/'
MEDIA_ROOT = '' ADMIN_MEDIA_PREFIX = '/admin_media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a CACHE_BACKEND = 'dummy:///'
# trailing slash. CACHE_MIDDLEWARE_SECONDS = 60
# Examples: "http://foo.com/media/", "/media/". CACHE_MIDDLEWARE_KEY_PREFIX = 'sigi'
ADMIN_MEDIA_PREFIX = '/media/' CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False
# Make this unique, and don't share it with anybody. # Used to provide a seed in secret-key hashing algorithms. Set this to
SECRET_KEY = 'ns4w_j^t$*81bl%+3s6-l01&+lai01kz1si&720bmsu-#nmle8' # a random string in your local_settings.py - the longer, the better.
SECRET_KEY = 'set-this-in-your-local_settings.py!'
# List of callables that know how to import templates from various sources. # List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source', 'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source', )
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware', 'django.middleware.http.ConditionalGetMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.doc.XViewMiddleware', 'django.middleware.doc.XViewMiddleware',
) )
ROOT_URLCONF = 'sigi.urls' ROOT_URLCONF = 'sigi.urls'
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". PROJECT_DIR + '/templates',
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
) )
FIXTURE_DIRS = (PROJECT_DIR + '/fixtures',)
INSTALLED_APPS = ( INSTALLED_APPS = (
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.sites', 'django.contrib.sites',
'django.contrib.databrowse',
'django.contrib.admin', 'django.contrib.admin',
'extensions', # http://django-command-extensions.googlecode.com/ 'django_extensions', # http://django-command-extensions.googlecode.com/
'sigi.apps.casas', 'sigi.apps.casas',
'sigi.apps.contatos', 'sigi.apps.contatos',
'sigi.apps.convenios', 'sigi.apps.convenios',
@ -87,3 +93,14 @@ INSTALLED_APPS = (
'sigi.apps.parlamentares', 'sigi.apps.parlamentares',
'sigi.apps.servicos', 'sigi.apps.servicos',
) )
try:
from local_settings import *
except ImportError:
from warnings import warn
msg = "You don't have local_settings.py file, using defaults settings."
try:
# don't work in Python 2.4 or before
warn(msg, category=ImportWarning)
except NameError:
warn(msg)

38
sigi/urls.py

@ -1,8 +1,44 @@
from django.conf import settings
from django.conf.urls.defaults import * from django.conf.urls.defaults import *
from django.contrib import admin from django.contrib import admin
from django.contrib import databrowse
from django.db.models import get_models
admin.autodiscover() admin.autodiscover()
map(databrowse.site.register, get_models())
urlpatterns = patterns(
'',
(r'^(.*)', admin.site.root),
(r'^doc/', include('django.contrib.admindocs.urls')),
# databrowse
(r'^databrowse/(.*)', databrowse.site.root),
# bug report
#(r'^bug_report/$', 'sigi.views.bug_report'),
)
if settings.MAINTENANCE:
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root), (r'.*', 'sigi.views.service_unavailable')
) + urlpatterns
if settings.DEBUG:
urlpatterns += patterns(
'',
# static files
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
(r'^404/$', 'django.views.generic.simple.direct_to_template',
{'template': '404.html'}),
(r'^500/$', 'django.views.generic.simple.direct_to_template',
{'template': '500.html'}),
(r'^503/$', 'django.views.generic.simple.direct_to_template',
{'template': '503.html'}),
) )

Loading…
Cancel
Save