Permalink
Browse files

Added travis.yml and example app

  • Loading branch information...
1 parent 08a4fb0 commit 5434e5fafa4b460bdb3e76cf7fec64c83a76e5ad @jsoa jsoa committed Jul 9, 2012
View
@@ -0,0 +1,16 @@
+language: python
+python:
+ - "2.6"
+ - "2.7"
+env:
+ - DJANGO_VERSION=1.2.7
+ - DJANGO_VERSION=1.3.1
+ - DJANGO_VERSION=1.4
+install:
+ - pip install Django==$DJANGO_VERSION
+ - pip install -e .
+script:
+ - ./example/manage.py test positions
+branches:
+ only:
+ - master
View
No changes.
View
@@ -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)
No changes.
@@ -0,0 +1,112 @@
+import datetime
+from django.db import models
+from django.contrib.contenttypes import generic
+from django.contrib.contenttypes.models import ContentType
+
+class DummyEntry(models.Model):
+ title = models.CharField(max_length=200)
+ body = models.TextField()
+ publish_date = models.DateTimeField(default=datetime.datetime.now)
+ author = models.CharField(max_length=200)
+
+ def __unicode__(self):
+ return self.title
+
+
+class DummyBookmark(models.Model):
+ url = models.URLField()
+ name = models.CharField(max_length=200)
+
+
+class DummyVideo(models.Model):
+ url = models.URLField()
+ name = models.CharField(max_length=200)
+
+
+class DummyImage(models.Model):
+ url = models.URLField()
+ name = models.CharField(max_length=200)
+
+
+class RelatedContent(models.Model):
+ entry = models.ForeignKey(DummyEntry)
+ content_type = models.ForeignKey(ContentType)
+ object_id = models.IntegerField()
+ content_object = generic.GenericForeignKey('content_type', 'object_id')
+ add_date = models.DateTimeField(default=datetime.datetime.now)
+
+
+
+def get_or_create_example():
+ bm_ctype = ContentType.objects.get_for_model(DummyBookmark)
+ vi_ctype = ContentType.objects.get_for_model(DummyVideo)
+ im_ctype = ContentType.objects.get_for_model(DummyImage)
+ en_ctype = ContentType.objects.get_for_model(DummyEntry)
+
+ entry, cr = DummyEntry.objects.get_or_create(
+ title="This is an example entry",
+ body="This is only an example entry",
+ author="John Smith")
+
+ bm1, cr = DummyBookmark.objects.get_or_create(
+ url="http://google.com",
+ name="Google")
+
+ bm2, cr = DummyBookmark.objects.get_or_create(
+ url="http://djangoproject.com",
+ name="Django Web Framework")
+
+ vid1, cr = DummyVideo.objects.get_or_create(
+ url="http://www.youtube.com/watch?v=K24mFGlJij0&playnext=1&list=PL4A64BDBA5F9629AE",
+ name="Django's Caravan - Gypsy Jazz Guitar - Leigh Jackson")
+
+ vid2, cr = DummyVideo.objects.get_or_create(
+ url="http://www.youtube.com/watch?v=_cZfMLVdvxI&feature=related",
+ name="\"All Of Me,\" gypsy jazz style")
+
+ img1, cr = DummyImage.objects.get_or_create(
+ url="http://www.flickr.com/photos/alisonlyons/5678882139/",
+ name="Fair Exchange From alison lyons photography")
+
+ img2, cr = DummyImage.objects.get_or_create(
+ url="http://www.flickr.com/photos/amury/5683581351/",
+ name="Pray for Japan. From kaneko_ryo")
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=bm_ctype,
+ object_id=bm1.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=bm_ctype,
+ object_id=bm2.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=vi_ctype,
+ object_id=vid1.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=vi_ctype,
+ object_id=vid2.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=im_ctype,
+ object_id=img1.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=im_ctype,
+ object_id=img2.pk)
+
+ RelatedContent.objects.get_or_create(
+ entry=entry,
+ content_type=en_ctype,
+ object_id=entry.pk)
+
+ return {'entry': entry,
+ 'related_content': RelatedContent.objects.all()}
+
No changes.
No changes.
View
@@ -0,0 +1,94 @@
+# Django settings for example project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+import os, sys
+APP = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+PROJ_ROOT = os.path.abspath(os.path.dirname(__file__))
+sys.path.append(APP)
+
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'dev.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.
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'dev.db'
+ }
+}
+
+# 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/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
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = os.path.abspath(os.path.join('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 = '/static/'
+
+# 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/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'g2_39yupn*6j4p*cg2%w643jiq-1n_annua*%i8+rq0dx9p=$n'
+
+# 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.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'example.urls'
+
+TEMPLATE_DIRS = (
+ os.path.abspath(os.path.join('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.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'positions',
+ 'sample_app',
+)
@@ -0,0 +1,50 @@
+{% load renderit_tags %}
+
+<h1>{{ main_user }}</h1>
+{% renderit main_user %}
+
+<hr/>
+{% renderit main_user as myuservar %}
+
+<hr/>
+
+{% renderit main_user with varname as varname %}
+
+<hr/>
+
+{% renderit int_value something %}
+
+<hr/>
+
+{% renderit float_value with prefix=one %}
+
+<hr/>
+
+{% renderit string_value something with group=two %}
+
+<hr/>
+
+{% renderit unicode_value two three with group=main_user.username prefix=pre %}
+
+<hr/>
+
+{% renderit custom_class two three with group=four prefix=pre concat=__ %}
+
+<hr/>
+
+{% renderit one two with group=three as myvar %}
+
+<hr/>
+<hr/>
+<h1>Generic Content Type Exampl</h1>
+
+<h2>{{ entry.title }}</h2>
+<h4>By {{ entry.author }} on {{ entry.publish_date }}
+<hr/>
+{{ entry.body }}
+
+<h4> Related Material</h4>
+{% for obj in related_content %}
+ {% renderit obj.content_object %}
+{% endfor %}
+
@@ -0,0 +1 @@
+<h3>Content Specific (Bookmark) - {{ obj.name }}</h3>
@@ -0,0 +1 @@
+<h3>Content Specific (Entry) - {{ obj }}</h3>
@@ -0,0 +1 @@
+<h3>Content Specific (Image) - {{ obj.name }}</h3>
@@ -0,0 +1 @@
+<h3>Content Specific (Video) - {{ obj.name }}</h3>
View
@@ -0,0 +1,43 @@
+from django.conf.urls.defaults import *
+
+from django.contrib import admin
+from django.views.generic.simple import direct_to_template
+from django.conf import settings
+from django.contrib.auth.models import User
+
+from sample_app.models import get_or_create_example
+
+admin.autodiscover()
+
+main_user = User.objects.all()[0]
+
+int_value = 231
+float_value = 112.232
+
+string_value = "this is something"
+
+unicode_value = u"This is something else"
+
+class c(object):
+ var1 = 123
+ var2 = "custom"
+
+context = {'main_user': main_user,
+ 'int_value': int_value,
+ 'float_value': float_value,
+ 'string_value': string_value,
+ 'unicode_value': unicode_value,
+ 'custom_class': c}
+
+context.update(get_or_create_example())
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+ (r'^positions/', include('positions.urls')),
+ url(r'^$',
+ direct_to_template,
+ {'template': 'index.html',
+ 'extra_context': context}),
+)
+
+

0 comments on commit 5434e5f

Please sign in to comment.