Commits

Carl Meyer  committed 3a0a0a3

added test_project

  • Participants
  • Parent commits fe7facb

Comments (0)

Files changed (10)

File test_project/README.txt

+A bare-bones Django project for live-testing django-adminfiles; particularly
+Javascript functionality that can't easily be unit-tested.
+
+If I get really ambitious one day I might stick some Selenium scripts in
+here.

File test_project/__init__.py

Empty file added.

File test_project/fixtures/initial_data.json

+[
+    {
+        "pk": 1, 
+        "model": "auth.user", 
+        "fields": {
+            "username": "admin", 
+            "first_name": "", 
+            "last_name": "", 
+            "is_active": true, 
+            "is_superuser": true, 
+            "is_staff": true, 
+            "last_login": "2010-04-28 00:07:07", 
+            "groups": [], 
+            "user_permissions": [], 
+            "password": "sha1$52a46$4677c471a12ce2b2320a94adc0846506293b5afd", 
+            "email": "carl@oddbird.net", 
+            "date_joined": "2010-04-28 00:07:07"
+        }
+    }
+]

File test_project/manage.py

+#!/usr/bin/env python
+import sys, os
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+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)

File test_project/run_test_project.sh

+#!/bin/bash
+
+./manage.py syncdb --noinput
+pushd media
+ln -s ../../adminfiles/media/adminfiles .
+popd
+./manage.py runserver
+rm adminfiles-test.db
+rm media/adminfiles

File test_project/settings.py

+import os
+BASE = os.path.dirname(os.path.abspath(__file__))
+
+DEBUG = True
+
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = os.path.join(BASE, 'adminfiles-test.db')
+
+MEDIA_ROOT = os.path.join(BASE, 'media')
+MEDIA_URL = '/media/'
+ADMIN_MEDIA_PREFIX = '/media/admin/'
+SECRET_KEY = '6wk#pb((9+oudihdco6m@#1hmr1qp#k+7a=p7c@#z91_^=en-!'
+
+ROOT_URLCONF = 'test_project.urls'
+
+FIXTURE_DIRS = [
+    os.path.join(BASE, 'fixtures')
+    ]
+
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.admin',
+    'adminfiles',
+    'sorl.thumbnail',
+    'testapp',
+)

File test_project/testapp/__init__.py

Empty file added.

File test_project/testapp/admin.py

+from django.contrib import admin
+
+from adminfiles.admin import FilePickerAdmin
+
+from test_project.testapp.models import Article
+
+class ArticleAdmin(FilePickerAdmin):
+    adminfiles_fields = ['content']
+
+admin.site.register(Article, ArticleAdmin)

File test_project/testapp/models.py

+from django.db import models
+
+class Article(models.Model):
+    title = models.CharField(max_length=100)
+    content = models.TextField()
+    
+    def __unicode__(self):
+        return self.title

File test_project/urls.py

+from django.conf.urls.defaults import *
+from django.conf import settings
+
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+    (r'^admin/', include(admin.site.urls)),
+    (r'^adminfiles/', include('adminfiles.urls')),
+)
+
+if settings.DEBUG:
+    urlpatterns += patterns('',
+        (r'^media/(?P<path>.*)$', 'django.views.static.serve',
+            {'document_root': settings.MEDIA_ROOT}),
+    )