mirror of
https://github.com/jazzband/django-authority.git
synced 2026-05-28 16:58:18 +00:00
Added example project
This commit is contained in:
parent
d0ebca03a2
commit
96a80d27a1
11 changed files with 158 additions and 0 deletions
0
example/__init__.py
Normal file
0
example/__init__.py
Normal file
4
example/development.py
Normal file
4
example/development.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
from example.settings import *
|
||||
DEBUG=True
|
||||
TEMPLATE_DEBUG=DEBUG
|
||||
0
example/exampleapp/__init__.py
Normal file
0
example/exampleapp/__init__.py
Normal file
7
example/exampleapp/admin.py
Normal file
7
example/exampleapp/admin.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.flatpages.models import FlatPage
|
||||
from django.contrib.flatpages.admin import FlatPageAdmin
|
||||
from authority.admin import PermissionInline
|
||||
|
||||
admin.site.unregister(FlatPage)
|
||||
admin.site.register(FlatPage, FlatPageAdmin, inlines=[PermissionInline])
|
||||
3
example/exampleapp/models.py
Normal file
3
example/exampleapp/models.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
6
example/exampleapp/permissions.py
Normal file
6
example/exampleapp/permissions.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.contrib.flatpages.models import FlatPage
|
||||
from authority.permissions import BasePermission
|
||||
|
||||
class FlatPagePermission(BasePermission):
|
||||
model = FlatPage
|
||||
label = 'flatpage_permission'
|
||||
23
example/exampleapp/tests.py
Normal file
23
example/exampleapp/tests.py
Normal file
|
|
@ -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
|
||||
"""}
|
||||
|
||||
2
example/production.py
Normal file
2
example/production.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
from example.settings import *
|
||||
82
example/settings.py
Normal file
82
example/settings.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import os
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@domain.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASE_ENGINE = 'sqlite3'
|
||||
DATABASE_NAME = os.path.join(PROJECT_ROOT, 'example.db')
|
||||
DATABASE_USER = ''
|
||||
DATABASE_PASSWORD = ''
|
||||
DATABASE_HOST = ''
|
||||
DATABASE_PORT = ''
|
||||
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
# Absolute path to the directory that holds media.
|
||||
# Example: "/home/media/media.lawrence.com/"
|
||||
MEDIA_ROOT = os.path.join(PROJECT_ROOT, '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 = '/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 = '/admin_media/'
|
||||
|
||||
# Don't share this with anybody.
|
||||
SECRET_KEY = 'ljlv2lb2d&)#by6th=!v=03-c^(o4lop92i@z4b3f1&ve0yx6d'
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.core.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.request',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'example.urls'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.flatpages',
|
||||
'django.contrib.admin',
|
||||
'authority',
|
||||
'example.exampleapp',
|
||||
)
|
||||
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.load_template_source',
|
||||
'django.template.loaders.app_directories.load_template_source',
|
||||
)
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(PROJECT_ROOT, "templates"),
|
||||
)
|
||||
|
||||
# Use local_settings.py for things to override privately
|
||||
try:
|
||||
from local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
10
example/templates/flatpages/default.html
Normal file
10
example/templates/flatpages/default.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{% load permissions_tags %}
|
||||
{{ flatpage.content }}
|
||||
|
||||
{% permission_form flatpage "add_flatpage" %}
|
||||
|
||||
{% get_permissions_for flatpage %}
|
||||
|
||||
{% for perm in permissions %}
|
||||
<p>{{ perm.user }}: {{ perm }} {% permission_delete_link perm %}</p>
|
||||
{% endfor %}
|
||||
21
example/urls.py
Normal file
21
example/urls.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
from django.conf.urls.defaults import patterns, include, handler500
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
handler500 # Pyflakes
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^admin/', include(admin.site.urls)),
|
||||
(r'^perms/', include('authority.urls')),
|
||||
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += patterns('',
|
||||
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
|
||||
'document_root': settings.MEDIA_ROOT,
|
||||
}),
|
||||
)
|
||||
Loading…
Reference in a new issue