Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a project example to make testing easier

  • Loading branch information...
commit 30c060350efd5bd46e36e770473c50115bc5c7b7 1 parent a5a295d
@yml yml authored
Showing with 308 additions and 0 deletions.
  1. +8 −0 project_example/README
  2. +11 −0 project_example/manage.py
  3. 0  project_example/project_example/__init__.py
  4. 0  project_example/project_example/apps/__init__.py
  5. 0  project_example/project_example/apps/test_salmonella/__init__.py
  6. +12 −0 project_example/project_example/apps/test_salmonella/admin.py
  7. +5 −0 project_example/project_example/apps/test_salmonella/models.py
  8. +16 −0 project_example/project_example/apps/test_salmonella/tests.py
  9. +1 −0  project_example/project_example/apps/test_salmonella/views.py
  10. 0  project_example/project_example/conf/__init__.py
  11. +21 −0 project_example/project_example/conf/local/__init__.py
  12. +12 −0 project_example/project_example/conf/local/urls.py
  13. +19 −0 project_example/project_example/conf/test/__init__.py
  14. +9 −0 project_example/project_example/conf/test/urls.py
  15. +121 −0 project_example/project_example/settings.py
  16. +5 −0 project_example/project_example/templates/404.html
  17. +16 −0 project_example/project_example/templates/500.html
  18. +17 −0 project_example/project_example/templates/base.html
  19. +13 −0 project_example/project_example/urls.py
  20. +8 −0 project_example/requirements.pip
  21. +14 −0 project_example/setup.py
View
8 project_example/README
@@ -0,0 +1,8 @@
+This a django project example that can be used to quickly undertsand how
+`django-salmonella` can be used.
+
+In order to get started :
+
+* Create a virtualenv
+* Install Salmonella
+* Install this project example
View
11 project_example/manage.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE",
+ "project_example.conf.local")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
View
0  project_example/project_example/__init__.py
No changes.
View
0  project_example/project_example/apps/__init__.py
No changes.
View
0  project_example/project_example/apps/test_salmonella/__init__.py
No changes.
View
12 project_example/project_example/apps/test_salmonella/admin.py
@@ -0,0 +1,12 @@
+from django.contrib import admin
+
+from salmonella.admin import SalmonellaMixin
+
+from .models import SalmonellaTest
+
+class SalmonellaTestAdmin(SalmonellaMixin, admin.ModelAdmin):
+ salmonella_fields = ('user',)
+
+
+
+admin.site.register(SalmonellaTest, SalmonellaTestAdmin)
View
5 project_example/project_example/apps/test_salmonella/models.py
@@ -0,0 +1,5 @@
+from django.db import models
+
+
+class SalmonellaTest(models.Model):
+ user = models.ForeignKey('auth.User')
View
16 project_example/project_example/apps/test_salmonella/tests.py
@@ -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)
View
1  project_example/project_example/apps/test_salmonella/views.py
@@ -0,0 +1 @@
+# Create your views here.
View
0  project_example/project_example/conf/__init__.py
No changes.
View
21 project_example/project_example/conf/local/__init__.py
@@ -0,0 +1,21 @@
+from project_example.settings import * # pylint: disable=W0614,W0401
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ ('You', 'your@email'),
+)
+MANAGERS = ADMINS
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(VAR_ROOT, 'dev.db'),
+ }
+}
+
+ROOT_URLCONF = 'project_example.conf.local.urls'
+
+INSTALLED_APPS += (
+)
View
12 project_example/project_example/conf/local/urls.py
@@ -0,0 +1,12 @@
+from django.conf.urls.defaults import patterns, include
+from django.conf.urls.static import static
+from django.conf import settings
+
+
+urlpatterns = patterns('',
+ (r'', include('project_example.urls')),
+)
+
+if settings.MEDIA_ROOT:
+ urlpatterns += static(settings.MEDIA_URL,
+ document_root=settings.MEDIA_ROOT)
View
19 project_example/project_example/conf/test/__init__.py
@@ -0,0 +1,19 @@
+from project_example.settings import * # pylint: disable=W0614,W0401
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ }
+}
+ROOT_URLCONF = 'project_example.conf.test.urls'
+
+INSTALLED_APPS += (
+ 'django.contrib.admin'
+ 'django_nose',
+)
+
+TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
View
9 project_example/project_example/conf/test/urls.py
@@ -0,0 +1,9 @@
+from django.conf.urls.defaults import patterns, include
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'', include('project_example.urls')),
+ (r'^admin/', include(admin.site.urls)),
+)
View
121 project_example/project_example/settings.py
@@ -0,0 +1,121 @@
+# Import global settings to make it easier to extend settings.
+from django.conf.global_settings import * # pylint: disable=W0614,W0401
+
+#==============================================================================
+# Generic Django project settings
+#==============================================================================
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+SITE_ID = 1
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+TIME_ZONE = 'UTC'
+USE_TZ = True
+USE_I18N = True
+USE_L10N = True
+LANGUAGE_CODE = 'en'
+LANGUAGES = (
+ ('en', 'English'),
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'baa5(pf=j&zb0a6=(as673air8u(ino%ss@+v@k9expf3gn84g'
+
+INSTALLED_APPS = (
+ 'project_example.apps.test_salmonella',
+ 'salmonella',
+
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'django.contrib.admin',
+ 'django.contrib.admindocs',
+
+)
+
+#==============================================================================
+# Calculation of directories relative to the project module location
+#==============================================================================
+
+import os
+import sys
+import project_example as project_module
+
+PROJECT_DIR = os.path.dirname(os.path.realpath(project_module.__file__))
+
+PYTHON_BIN = os.path.dirname(sys.executable)
+ve_path = os.path.dirname(os.path.dirname(os.path.dirname(PROJECT_DIR)))
+# Assume that the presence of 'activate_this.py' in the python bin/
+# directory means that we're running in a virtual environment.
+if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')):
+ # We're running with a virtualenv python executable.
+ VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
+elif ve_path and os.path.exists(os.path.join(ve_path, 'bin',
+ 'activate_this.py')):
+ # We're running in [virtualenv_root]/src/[project_name].
+ VAR_ROOT = os.path.join(ve_path, 'var')
+else:
+ # Set the variable root to the local configuration location (which is
+ # ignored by the repository).
+ VAR_ROOT = os.path.join(PROJECT_DIR, 'conf', 'local')
+
+if not os.path.exists(VAR_ROOT):
+ os.mkdir(VAR_ROOT)
+
+#==============================================================================
+# Project URLS and media settings
+#==============================================================================
+
+ROOT_URLCONF = 'project_example.urls'
+
+LOGIN_URL = '/login/'
+LOGOUT_URL = '/logout/'
+LOGIN_REDIRECT_URL = '/'
+
+STATIC_URL = '/static/'
+MEDIA_URL = '/uploads/'
+
+STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
+MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
+
+STATICFILES_DIRS = (
+ os.path.join(PROJECT_DIR, 'static'),
+)
+
+#==============================================================================
+# Templates
+#==============================================================================
+
+TEMPLATE_DIRS = (
+ os.path.join(PROJECT_DIR, 'templates'),
+)
+
+TEMPLATE_CONTEXT_PROCESSORS += (
+)
+
+#==============================================================================
+# Middleware
+#==============================================================================
+
+MIDDLEWARE_CLASSES += (
+)
+
+#==============================================================================
+# Auth / security
+#==============================================================================
+
+AUTHENTICATION_BACKENDS += (
+)
+
+#==============================================================================
+# Miscellaneous project settings
+#==============================================================================
+
+#==============================================================================
+# Third party app settings
+#==============================================================================
View
5 project_example/project_example/templates/404.html
@@ -0,0 +1,5 @@
+{% extends "base.html" %}
+
+{% block content %}
+ Not Found
+{% endblock %}
View
16 project_example/project_example/templates/500.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+<head>
+ <title>{% block head_title %}{% endblock %}</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+</head>
+<body>
+
+<div id="container">
+ Server Error
+</div>
+
+</body>
+</html>
View
17 project_example/project_example/templates/base.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+<head>
+ <title>{% block head_title %}{% endblock %}</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+</head>
+<body>
+
+<div id="container">
+ {% block content %}
+ {% endblock %}
+</div>
+
+</body>
+</html>
View
13 project_example/project_example/urls.py
@@ -0,0 +1,13 @@
+from django.conf.urls.defaults import patterns, url, include
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ #url('', include('project_example.apps.'))
+ (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ (r'^admin/', include(admin.site.urls)),
+
+
+ url(r'^admin/salmonella/', include('salmonella.urls')),
+)
View
8 project_example/requirements.pip
@@ -0,0 +1,8 @@
+# This file collects all required third-party applications that are needed
+# to run this project. Later you can install all these apps in a row
+# using pip. Example::
+#
+# pip install -r requirements.pip
+
+django==1.4
+
View
14 project_example/setup.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+from setuptools import setup, find_packages
+
+setup(
+ name='project_example',
+ version='1.0',
+ description="",
+ author="Lincoln Loop",
+ author_email='info@lincolnloop.com',
+ url='',
+ packages=find_packages(),
+ package_data={'project_example': ['static/*.*', 'templates/*.*']},
+ scripts=['manage.py'],
+)
Please sign in to comment.
Something went wrong with that request. Please try again.