diff options
Diffstat (limited to 'examples/cloudfiles_project')
| -rw-r--r-- | examples/cloudfiles_project/__init__.py | 0 | ||||
| -rwxr-xr-x | examples/cloudfiles_project/manage.py | 11 | ||||
| -rw-r--r-- | examples/cloudfiles_project/photos/__init__.py | 0 | ||||
| -rw-r--r-- | examples/cloudfiles_project/photos/admin.py | 4 | ||||
| -rw-r--r-- | examples/cloudfiles_project/photos/models.py | 9 | ||||
| -rw-r--r-- | examples/cloudfiles_project/settings.py | 83 | ||||
| -rw-r--r-- | examples/cloudfiles_project/templates/base.html | 14 | ||||
| -rw-r--r-- | examples/cloudfiles_project/templates/photos/photo_list.html | 14 | ||||
| -rw-r--r-- | examples/cloudfiles_project/urls.py | 21 |
9 files changed, 156 insertions, 0 deletions
diff --git a/examples/cloudfiles_project/__init__.py b/examples/cloudfiles_project/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/cloudfiles_project/__init__.py diff --git a/examples/cloudfiles_project/manage.py b/examples/cloudfiles_project/manage.py new file mode 100755 index 0000000..5e78ea9 --- /dev/null +++ b/examples/cloudfiles_project/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import 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(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/examples/cloudfiles_project/photos/__init__.py b/examples/cloudfiles_project/photos/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/cloudfiles_project/photos/__init__.py diff --git a/examples/cloudfiles_project/photos/admin.py b/examples/cloudfiles_project/photos/admin.py new file mode 100644 index 0000000..74141c5 --- /dev/null +++ b/examples/cloudfiles_project/photos/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from cloudfiles_project.photos.models import Photo + +admin.site.register(Photo)
\ No newline at end of file diff --git a/examples/cloudfiles_project/photos/models.py b/examples/cloudfiles_project/photos/models.py new file mode 100644 index 0000000..0770a3d --- /dev/null +++ b/examples/cloudfiles_project/photos/models.py @@ -0,0 +1,9 @@ +from django.db import models +from backends.mosso import cloudfiles_upload_to + +class Photo(models.Model): + title = models.CharField(max_length=50) + image = models.ImageField(upload_to=cloudfiles_upload_to) + + def __unicode__(self): + return self.title
\ No newline at end of file diff --git a/examples/cloudfiles_project/settings.py b/examples/cloudfiles_project/settings.py new file mode 100644 index 0000000..6c18122 --- /dev/null +++ b/examples/cloudfiles_project/settings.py @@ -0,0 +1,83 @@ +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +CLOUDFILES_USERNAME = 'yourusername' +CLOUDFILES_API_KEY = 'yourapikey' +CLOUDFILES_CONTAINER = 'test-container' +CLOUDFILES_TTL = 600 +DEFAULT_FILE_STORAGE = 'backends.mosso.CloudFilesStorage' + +DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_NAME = 'local.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/New_York' + +# 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 + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '' + +# 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 = '/media/' + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/media/admin/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '5-7e5&o20#&@&h8t)7%n4a@)y7s3(jnv)qdd_azqzmo826d_u@' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', +) + +ROOT_URLCONF = 'cloudfiles_project.urls' + +TEMPLATE_DIRS = ( + 'templates', +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'cloudfiles_project.photos', +) diff --git a/examples/cloudfiles_project/templates/base.html b/examples/cloudfiles_project/templates/base.html new file mode 100644 index 0000000..8a8a137 --- /dev/null +++ b/examples/cloudfiles_project/templates/base.html @@ -0,0 +1,14 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title>django-cumulus example project</title> +</head> + +<body> +{% block content %}{% endblock %} + +</body> +</html> diff --git a/examples/cloudfiles_project/templates/photos/photo_list.html b/examples/cloudfiles_project/templates/photos/photo_list.html new file mode 100644 index 0000000..81a49a5 --- /dev/null +++ b/examples/cloudfiles_project/templates/photos/photo_list.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block content %} +<h1>Photos in database</h1> +{% if object_list %} +<ul>{% spaceless %} + {% for object in object_list %} + <li>{{ object.image.url }}</li> + {% endfor %} +{% endspaceless %}</ul> +{% else %} +<p>No photos exist.</p> +{% endif %} +{% endblock %} diff --git a/examples/cloudfiles_project/urls.py b/examples/cloudfiles_project/urls.py new file mode 100644 index 0000000..b566697 --- /dev/null +++ b/examples/cloudfiles_project/urls.py @@ -0,0 +1,21 @@ +from django.conf.urls.defaults import * +from django.conf import settings +from photos.models import Photo + +photo_dict = { + 'queryset': Photo.objects.all() +} + +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + (r'^admin/doc/', include('django.contrib.admindocs.urls')), + (r'^admin/(.*)', admin.site.root), + (r'^photos/$', 'django.views.generic.list_detail.object_list', photo_dict), +) + +if settings.DEBUG: + urlpatterns += patterns('', + (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), + )
\ No newline at end of file |
