Sanj
12 years ago
commit
8ae8526541
15 changed files with 517 additions and 0 deletions
@ -0,0 +1,18 @@ |
|||
from django.db import models |
|||
import datetime |
|||
|
|||
class BaseModel(models.Model): |
|||
changed = models.DateTimeField(null=True, editable=False) |
|||
created = models.DateTimeField(null=True, editable=False) |
|||
|
|||
def save(self, *args, **kwargs): |
|||
if not self.id: |
|||
self.created = datetime.datetime.today() |
|||
self.changed = datetime.datetime.today() |
|||
if self.created == None: |
|||
self.created = self.changed |
|||
super(BaseModel, self).save(*args, **kwargs) |
|||
|
|||
class Meta: |
|||
abstract = True |
|||
|
@ -0,0 +1,23 @@ |
|||
""" |
|||
This file demonstrates two different styles of tests (one doctest and one |
|||
unittest). These will both pass when you run "manage.py test". |
|||
|
|||
Replace these with more appropriate tests for your application. |
|||
""" |
|||
|
|||
from django.test import TestCase |
|||
|
|||
class SimpleTest(TestCase): |
|||
def test_basic_addition(self): |
|||
""" |
|||
Tests that 1 + 1 always equals 2. |
|||
""" |
|||
self.failUnlessEqual(1 + 1, 2) |
|||
|
|||
__test__ = {"doctest": """ |
|||
Another way to test that 1 + 1 is equal to 2. |
|||
|
|||
>>> 1 + 1 == 2 |
|||
True |
|||
"""} |
|||
|
@ -0,0 +1 @@ |
|||
# Create your views here. |
@ -0,0 +1,22 @@ |
|||
from django.contrib import admin |
|||
from models import * |
|||
|
|||
''' |
|||
class SubdomainInline(admin.StackedInline): |
|||
model = Subdomain |
|||
|
|||
class DomainAliasInline(admin.StackedInline): |
|||
model = DomainAlias |
|||
|
|||
class ServerAdmin(admin.ModelAdmin): |
|||
pass |
|||
''' |
|||
|
|||
class ContentAdmin(admin.ModelAdmin): |
|||
save_on_top = True |
|||
# inlines = [SubdomainInline, DomainAliasInline] |
|||
# list_display = ('url', 'server', 'manage_nameserver', 'domain_registrar', 'email', 'is_active') |
|||
# list_editable = ('server', 'manage_nameserver', 'domain_registrar', 'email', 'is_active') |
|||
|
|||
|
|||
admin.site.register(Content, ContentAdmin) |
@ -0,0 +1,215 @@ |
|||
# This is an auto-generated Django model module. |
|||
# You'll have to do the following manually to clean this up: |
|||
# * Rearrange models' order |
|||
# * Make sure each model has one field with primary_key=True |
|||
# Feel free to rename the models, but don't rename db_table values or field names. |
|||
# |
|||
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]' |
|||
# into your database. |
|||
|
|||
from django.db import models |
|||
|
|||
class Acrolike(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
title = models.CharField(max_length=765) |
|||
|
|||
class Meta: |
|||
db_table = u'acrolike' |
|||
|
|||
class Acronym(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
name = models.CharField(max_length=765, blank=True) |
|||
c = models.CharField(max_length=150, blank=True) |
|||
a = models.CharField(max_length=150, blank=True) |
|||
m = models.CharField(max_length=150, blank=True) |
|||
p = models.CharField(max_length=150, blank=True) |
|||
|
|||
class Meta: |
|||
db_table = u'acronym' |
|||
|
|||
class Audios(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
filename = models.CharField(max_length=765) |
|||
title = models.CharField(max_length=765, blank=True) |
|||
description = models.TextField(blank=True) |
|||
|
|||
class Meta: |
|||
db_table = u'audios' |
|||
|
|||
class Comments(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
comment = models.TextField() |
|||
name = models.CharField(max_length=450, blank=True) |
|||
email = models.CharField(max_length=765, blank=True) |
|||
personid = models.ForeignKey("People", null=True, db_column='personID', blank=True) # Field name made lowercase. |
|||
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. |
|||
datemodified = models.DateTimeField(null=True, db_column='dateModified', blank=True) # Field name made lowercase. |
|||
parentid = models.ForeignKey("Comments", null=True, db_column='parentID', blank=True) # Field name made lowercase. |
|||
contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. |
|||
ip = models.CharField(max_length=150, db_column='IP', blank=True) # Field name made lowercase. |
|||
|
|||
class Meta: |
|||
db_table = u'comments' |
|||
|
|||
class Content(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
shortname = models.CharField(max_length=765, db_column='shortName') # Field name made lowercase. |
|||
title = models.CharField(max_length=765) |
|||
header = models.TextField(blank=True) |
|||
body = models.TextField(blank=True) |
|||
schedule = models.TextField(blank=True) |
|||
schedulebutton = models.CharField(max_length=765, db_column='scheduleButton', blank=True) # Field name made lowercase. |
|||
optbtn2 = models.CharField(max_length=381, db_column='optBtn2', blank=True) # Field name made lowercase. |
|||
opttext2 = models.TextField(db_column='optText2', blank=True) # Field name made lowercase. |
|||
optbtn3 = models.CharField(max_length=381, db_column='optBtn3', blank=True) # Field name made lowercase. |
|||
opttext3 = models.TextField(db_column='optText3', blank=True) # Field name made lowercase. |
|||
technotes = models.TextField() |
|||
image = models.CharField(max_length=450, blank=True) |
|||
postedby = models.CharField(max_length=150, db_column='postedBy', blank=True) # Field name made lowercase. |
|||
datestart = models.DateField(null=True, db_column='dateStart', blank=True) # Field name made lowercase. |
|||
dateend = models.DateField(null=True, db_column='dateEnd', blank=True) # Field name made lowercase. |
|||
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. |
|||
datemodified = models.DateTimeField(null=True, db_column='dateModified', blank=True) # Field name made lowercase. |
|||
type = models.ForeignKey("ContentTypes", db_column="type") |
|||
published = models.IntegerField() |
|||
related_content = models.ManyToManyField("Content", through="ContentContent", related_name="related_contents", blank=True) |
|||
keywords = models.ManyToManyField("Keywords", through="ContentKeyword", blank=True) |
|||
resources = models.ManyToManyField("Resources", through="ContentResource", blank=True) |
|||
view = models.ForeignKey("Views", null=True, blank=True, db_column="view") |
|||
parentid = models.ForeignKey("Content", db_column='parentId') # Field name made lowercase. |
|||
|
|||
def __unicode__(self): |
|||
return self.title |
|||
|
|||
class Meta: |
|||
db_table = u'content' |
|||
|
|||
class ContentContent(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
contentid1 = models.ForeignKey("Content", db_column='contentID1', related_name="related1") # Field name made lowercase. |
|||
contentid2 = models.ForeignKey("Content", db_column='contentID2', related_name="related2") # Field name made lowercase. |
|||
|
|||
class Meta: |
|||
db_table = u'content_content' |
|||
|
|||
class ContentKeyword(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. |
|||
keywordid = models.ForeignKey("Keywords", db_column='keywordID') # Field name made lowercase. |
|||
|
|||
class Meta: |
|||
db_table = u'content_keyword' |
|||
|
|||
class ContentResource(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. |
|||
resourceid = models.ForeignKey("Resources", db_column='resourceID') # Field name made lowercase. |
|||
|
|||
class Meta: |
|||
db_table = u'content_resource' |
|||
|
|||
class ContentTypes(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
name = models.CharField(max_length=765) |
|||
description = models.TextField(blank=True) |
|||
|
|||
def __unicode__(self): |
|||
return self.name |
|||
|
|||
class Meta: |
|||
db_table = u'content_types' |
|||
|
|||
class Keywords(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
name = models.CharField(max_length=765) |
|||
description = models.TextField(blank=True) |
|||
|
|||
def __unicode__(self): |
|||
return self.name |
|||
|
|||
class Meta: |
|||
db_table = u'keywords' |
|||
|
|||
class People(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
name = models.CharField(max_length=765, blank=True) |
|||
email = models.CharField(max_length=765, blank=True) |
|||
location = models.CharField(max_length=765, blank=True) |
|||
login = models.CharField(max_length=300, blank=True) |
|||
password = models.CharField(max_length=48, blank=True) |
|||
href = models.CharField(max_length=765, blank=True) |
|||
bio = models.TextField(blank=True) |
|||
content = models.ManyToManyField("Content", through="PersonContent", blank=True) |
|||
resources = models.ManyToManyField("Resources", through="PersonResource", blank=True) |
|||
type = models.IntegerField() |
|||
|
|||
def __unicode__(self): |
|||
return "%s: %s" (self.name, self.email, ) |
|||
class Meta: |
|||
db_table = u'people' |
|||
|
|||
class PersonContent(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
personid = models.ForeignKey("People", db_column='personID') # Field name made lowercase. |
|||
contentid = models.ForeignKey("Content", db_column='contentID') # Field name made lowercase. |
|||
level = models.IntegerField() |
|||
|
|||
class Meta: |
|||
db_table = u'person_content' |
|||
|
|||
class PersonResource(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
personid = models.ForeignKey("People", db_column='personID') # Field name made lowercase. |
|||
resourceid = models.ForeignKey("Resources", db_column='resourceID') # Field name made lowercase. |
|||
|
|||
class Meta: |
|||
db_table = u'person_resource' |
|||
|
|||
class Resources(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
type = models.IntegerField() |
|||
href = models.CharField(max_length=765) |
|||
description = models.TextField(blank=True) |
|||
mime = models.CharField(max_length=30, blank=True) |
|||
width = models.IntegerField(null=True, blank=True) |
|||
height = models.IntegerField(null=True, blank=True) |
|||
istech = models.IntegerField(db_column='isTech') # Field name made lowercase. |
|||
dateadded = models.DateTimeField(db_column='dateAdded') # Field name made lowercase. |
|||
orderno = models.IntegerField(null=True, db_column='orderNo', blank=True) # Field name made lowercase. |
|||
|
|||
def __unicode__(self): |
|||
return "%d: %s" % (self.id, self.href) |
|||
|
|||
class Meta: |
|||
db_table = u'resources' |
|||
|
|||
class Videos(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
sha1 = models.CharField(max_length=150) |
|||
href = models.CharField(max_length=765) |
|||
title = models.TextField(blank=True) |
|||
description = models.TextField(blank=True) |
|||
width = models.IntegerField(null=True, blank=True) |
|||
height = models.IntegerField(null=True, blank=True) |
|||
duration = models.IntegerField(null=True, blank=True) |
|||
thumbno = models.IntegerField(db_column='thumbNo') # Field name made lowercase. |
|||
image = models.CharField(max_length=765, blank=True) |
|||
contentid = models.ForeignKey("Content", null=True, blank=True) |
|||
|
|||
def __unicode__(self): |
|||
return self.title |
|||
|
|||
class Meta: |
|||
db_table = u'videos' |
|||
|
|||
class Views(models.Model): |
|||
id = models.IntegerField(primary_key=True) |
|||
name = models.CharField(max_length=765) |
|||
href = models.CharField(max_length=765, blank=True) |
|||
|
|||
def __unicode__(self): |
|||
return self.name |
|||
|
|||
class Meta: |
|||
db_table = u'views' |
|||
|
@ -0,0 +1,16 @@ |
|||
""" |
|||
This file demonstrates writing tests using the unittest module. These will pass |
|||
when you run "manage.py test". |
|||
|
|||
Replace this with more appropriate tests for your application. |
|||
""" |
|||
|
|||
from django.test import TestCase |
|||
|
|||
|
|||
class SimpleTest(TestCase): |
|||
def test_basic_addition(self): |
|||
""" |
|||
Tests that 1 + 1 always equals 2. |
|||
""" |
|||
self.assertEqual(1 + 1, 2) |
@ -0,0 +1 @@ |
|||
# Create your views here. |
Binary file not shown.
@ -0,0 +1,25 @@ |
|||
#!/usr/bin/env python |
|||
#!/usr/bin/env python |
|||
import os |
|||
|
|||
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) |
|||
os.chdir(root_dir) |
|||
|
|||
#using virtualenv's activate_this.py to reorder sys.path |
|||
activate_this = os.path.join(root_dir, '..', 'bin', 'activate_this.py') |
|||
execfile(activate_this, dict(__file__=activate_this)) |
|||
|
|||
|
|||
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) |
@ -0,0 +1 @@ |
|||
p7a5=kpn0=az0f@yy&6zo1v@ol950#8vfje^kpth0c5a!(7pk! |
@ -0,0 +1,177 @@ |
|||
# Django settings for campdjango project. |
|||
import os |
|||
from os.path import join |
|||
|
|||
DEBUG = True |
|||
TEMPLATE_DEBUG = DEBUG |
|||
|
|||
JSON_DEBUG = False |
|||
APPEND_SLASH = True |
|||
#XSENDFILE = False |
|||
|
|||
ADMINS = ( |
|||
('Sanjay Bhangar', 'b@pad.ma'), |
|||
# ('Your Name', 'your_email@example.com'), |
|||
) |
|||
|
|||
MANAGERS = ADMINS |
|||
|
|||
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) |
|||
|
|||
DATABASES = { |
|||
'default': { |
|||
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. |
|||
'NAME': 'camp', # Or path to database file if using sqlite3. |
|||
'USER': 'root', # 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 = 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 = ( |
|||
# Put strings here, like "/home/html/static" or "C:/www/django/static". |
|||
# Always use forward slashes, even on Windows. |
|||
# Don't forget to use absolute paths, not relative paths. |
|||
) |
|||
|
|||
# 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', |
|||
) |
|||
|
|||
# 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 = 'campdjango.urls' |
|||
|
|||
TEMPLATE_DIRS = ( |
|||
join(PROJECT_ROOT, 'templates') |
|||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". |
|||
# Always use forward slashes, even on Windows. |
|||
# Don't forget to use absolute paths, not relative paths. |
|||
) |
|||
|
|||
INSTALLED_APPS = ( |
|||
'django.contrib.auth', |
|||
'django.contrib.contenttypes', |
|||
'django.contrib.sessions', |
|||
'django.contrib.sites', |
|||
'django.contrib.messages', |
|||
'django.contrib.staticfiles', |
|||
# Uncomment the next line to enable the admin: |
|||
'django.contrib.admin', |
|||
# Uncomment the next line to enable admin documentation: |
|||
'django.contrib.admindocs', |
|||
'django_extensions', |
|||
'camp', |
|||
) |
|||
|
|||
# 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, |
|||
}, |
|||
} |
|||
} |
|||
|
|||
#overwrite default settings with local settings |
|||
try: |
|||
from local_settings import * |
|||
except ImportError: |
|||
pass |
|||
|
|||
# Make this unique, creates random key first at first time. |
|||
try: |
|||
SECRET_KEY |
|||
except NameError: |
|||
SECRET_FILE = os.path.join(PROJECT_ROOT, 'secret.txt') |
|||
try: |
|||
SECRET_KEY = open(SECRET_FILE).read().strip() |
|||
except IOError: |
|||
try: |
|||
from random import choice |
|||
SECRET_KEY = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) |
|||
secret = file(SECRET_FILE, 'w') |
|||
secret.write(SECRET_KEY) |
|||
secret.close() |
|||
except IOError: |
|||
Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE) |
@ -0,0 +1,18 @@ |
|||
from django.conf.urls.defaults import patterns, include, url |
|||
|
|||
# Uncomment the next two lines to enable the admin: |
|||
from django.contrib import admin |
|||
admin.autodiscover() |
|||
|
|||
urlpatterns = patterns('', |
|||
# Examples: |
|||
# url(r'^$', 'domains.views.home', name='home'), |
|||
# url(r'^domains/', include('domains.foo.urls')), |
|||
|
|||
# Uncomment the admin/doc line below to enable admin documentation: |
|||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), |
|||
|
|||
# Uncomment the next line to enable the admin: |
|||
url(r'^admin/', include(admin.site.urls)), |
|||
) |
|||
|
Loading…
Reference in new issue