summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Noel <thomas@univnautes-idp.dev>2014-03-16 16:53:45 (GMT)
committerThomas Noel <thomas@univnautes-idp.dev>2014-03-16 16:53:45 (GMT)
commitdb40a4a857f08a49848f44c444cfa87956fe7e55 (patch)
tree450410088dc542213d62a24db4ca83609cbc11eb
parentc6574ff3ae5e707d002e6e02b17ef660e1f6bc96 (diff)
downloadunivnautes-idp-db40a4a857f08a49848f44c444cfa87956fe7e55.zip
univnautes-idp-db40a4a857f08a49848f44c444cfa87956fe7e55.tar.gz
univnautes-idp-db40a4a857f08a49848f44c444cfa87956fe7e55.tar.bz2
enable admin (public/tenants)
-rw-r--r--.gitignore1
-rw-r--r--README.md7
-rw-r--r--base/__init__.py0
-rw-r--r--base/admin.py13
-rw-r--r--base/models.py3
-rw-r--r--base/templates/base.html56
-rw-r--r--base/templates/univnautes-idp/homepage.html6
-rw-r--r--base/views.py1
-rw-r--r--univnautes_idp/dashboard.py123
-rw-r--r--univnautes_idp/settings.py25
-rw-r--r--univnautes_idp/urls_public.py12
11 files changed, 239 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index e9814da..774c3b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
settings.ini
+static
*.pyo
*.pyc
diff --git a/README.md b/README.md
index cdfe073..3a4f72e 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,13 @@ univnautes-idp : IdP multi-tenants pour UnivNautes
cp settings.ini.example /somewhere/settings.ini
export UNIVNAUTES_IDP_SETTINGS_INI=/somewhere/settings.ini
+
+# creation du schema public
python manage.py sync_schemas --shared --noinput
+python manage.py migrate_schemas
+python manage.py create-tenant univnautes-idp.dev.entrouvert.org public
+python manage.py createsuperuser -s public
+
python manage.py create-tenant xyz.univnautes-idp.dev.entrouvert.org xyz
+python manage.py createsuperuser -s xyz
diff --git a/base/__init__.py b/base/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/base/__init__.py
diff --git a/base/admin.py b/base/admin.py
new file mode 100644
index 0000000..c024810
--- /dev/null
+++ b/base/admin.py
@@ -0,0 +1,13 @@
+from django.contrib import admin
+from entrouvert.djommon.multitenant.models import Tenant, ClientSetting
+
+class TenantAdmin(admin.ModelAdmin):
+ list_display = ('schema_name', 'name', 'domain_url', 'is_active')
+
+class ClientSettingAdmin(admin.ModelAdmin):
+ list_display = ('tenant', 'name', 'value')
+
+admin.site.register(Tenant, TenantAdmin)
+admin.site.register(ClientSetting, ClientSettingAdmin)
+
+
diff --git a/base/models.py b/base/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/base/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/base/templates/base.html b/base/templates/base.html
new file mode 100644
index 0000000..df06fe6
--- /dev/null
+++ b/base/templates/base.html
@@ -0,0 +1,56 @@
+{% load i18n %}<!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" />
+ <link rel="stylesheet" href="{{ STATIC_URL }}authentic2/css/style.css" />
+ <link rel="stylesheet" href="{{ STATIC_URL }}jquery/css/jquery-ui.custom.css" />
+ <link rel="stylesheet" href="{{ STATIC_URL }}ulx/css/ulx.css" />
+ <title>{% block title %}User test{% endblock %}</title>
+ {{ openid_meta }}
+ {% block extra_scripts %}
+ {% endblock %}
+</head>
+
+<body {% block bodyargs %}{% endblock %} >
+ <div id="wrap">
+ <a href="/"><div id="header">
+ {% block header %}
+ <span>Tenant</span>
+ <h1>{{request.tenant.name|default:request.tenant.schema_name}}</h1>
+ {% endblock %}
+ </div></a>
+
+ <div id="splash"></div>
+
+ <div id="content">
+ {% if request.user.is_authenticated %}
+ <div id="user">
+ <p>
+ {% blocktrans with request.user.get_full_name as username %}Hello {{ username }}.{% endblocktrans %}
+ </p>
+ </div>
+ {% endif %}
+ {% block messages %}
+ {% if messages %}
+ <ul class="messages">
+ {% for message in messages %}
+ <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ {% endblock %}
+ {% block content %}{% endblock %}
+ </div>
+
+ <div id="footer">
+ {% block footer %}
+ Copyright &copy; 2014 Entr'ouvert
+ &mdash;
+ Powered by <strong>Authentic 2</strong> the Versatile Identity Management Server
+ {% endblock %}
+ </div>
+ </div>
+</body>
+
+</html>
diff --git a/base/templates/univnautes-idp/homepage.html b/base/templates/univnautes-idp/homepage.html
new file mode 100644
index 0000000..9aa641e
--- /dev/null
+++ b/base/templates/univnautes-idp/homepage.html
@@ -0,0 +1,6 @@
+{% extends 'base.html' %}
+{% load i18n %}
+
+{% block content %}
+<h1>Gestion des tenants</h1>
+{% endblock %}
diff --git a/base/views.py b/base/views.py
new file mode 100644
index 0000000..60f00ef
--- /dev/null
+++ b/base/views.py
@@ -0,0 +1 @@
+# Create your views here.
diff --git a/univnautes_idp/dashboard.py b/univnautes_idp/dashboard.py
new file mode 100644
index 0000000..d63173d
--- /dev/null
+++ b/univnautes_idp/dashboard.py
@@ -0,0 +1,123 @@
+"""
+This file was generated with the customdashboard management command, it
+contains the two classes for the main dashboard and app index dashboard.
+You can customize these classes as you want.
+
+To activate your index dashboard add the following to your settings.py::
+ ADMIN_TOOLS_INDEX_DASHBOARD = 'authentic2.dashboard.CustomIndexDashboard'
+
+And to activate the app index dashboard::
+ ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'authentic2.dashboard.CustomAppIndexDashboard'
+"""
+
+from django.utils.translation import ugettext_lazy as _
+from django.core.urlresolvers import reverse
+
+from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
+from admin_tools.utils import get_admin_site_name
+
+
+class CustomIndexDashboard(Dashboard):
+ """
+ Custom index dashboard for authentic2.
+ """
+ def init_with_context(self, context):
+ site_name = get_admin_site_name(context)
+
+ tenant = context.get('request').tenant.schema_name
+
+ # append a link list module for "quick links"
+ self.children.append(modules.LinkList(
+ _('Quick links'),
+ layout='inline',
+ draggable=False,
+ deletable=False,
+ collapsible=False,
+ children=[
+ [_('Return to site'), '/'],
+ [_('Change password'),
+ reverse('%s:password_change' % site_name)],
+ [_('Log out'), reverse('%s:logout' % site_name)],
+ ]
+ ))
+
+ # append an app list module for "Applications"
+ self.children.append(modules.ModelList(
+ _('Users and groups'),
+ models=('authentic2.models.User',
+ 'django.contrib.auth.models.*'),
+ ))
+
+ if tenant == 'public':
+ self.children.append(modules.ModelList(
+ _('Tenants'),
+ models=(
+ 'entrouvert.djommon.multitenant.models.*',
+ ),
+ ))
+ else:
+ self.children.append(modules.ModelList(
+ _('Services'),
+ models=(
+ 'authentic2.saml.models.LibertyProvider',
+ 'authentic2.saml.models.SPOptionsIdPPolicy',
+ 'authentic2.saml.models.IdPOptionsSPPolicy',
+ 'authentic2.idp.models.AttributePolicy',
+ 'authentic2.attribute_aggregator.models.AttributeList',
+ 'authentic2.attribute_aggregator.models.AttributeItem',
+ 'authentic2.attribute_aggregator.models.AttributeSource',
+ ),
+ ))
+
+ # append a recent actions module
+ self.children.append(modules.RecentActions(_('Recent Actions'), 5))
+
+ # append another link list module for "support".
+ self.children.append(modules.LinkList(
+ _('Support'),
+ children=[
+ {
+ 'title': _('Authentic2 documentation'),
+ 'url': 'http://pythonhosted.org/authentic2/',
+ 'external': True,
+ },
+ {
+ 'title': _('Authentic2 project'),
+ 'url': 'http://dev.entrouvert.org/projects/authentic/',
+ 'external': True,
+ },
+ {
+ 'title': _('Authentic Mailing List'),
+ 'url': 'http://listes.entrouvert.com/info/authentic',
+ 'external': True,
+ },
+ ]
+ ))
+
+
+class CustomAppIndexDashboard(AppIndexDashboard):
+ """
+ Custom app index dashboard for authentic2.
+ """
+
+ # we disable title because its redundant with the model list module
+ title = ''
+
+ def __init__(self, *args, **kwargs):
+ AppIndexDashboard.__init__(self, *args, **kwargs)
+
+ # append a model list module and a recent actions module
+ self.children += [
+ modules.ModelList(self.app_title, self.models),
+ modules.RecentActions(
+ _('Recent Actions'),
+ include_list=self.get_app_content_types(),
+ limit=5
+ )
+ ]
+
+ def init_with_context(self, context):
+ """
+ Use this method if you need to access the request context.
+ """
+ return super(CustomAppIndexDashboard, self).init_with_context(context)
diff --git a/univnautes_idp/settings.py b/univnautes_idp/settings.py
index bac61a0..45e946e 100644
--- a/univnautes_idp/settings.py
+++ b/univnautes_idp/settings.py
@@ -131,7 +131,6 @@ MIDDLEWARE_CLASSES = (
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
-ROOT_URLCONF = 'univnautes_idp.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'univnautes_idp.wsgi.application'
@@ -140,8 +139,13 @@ TEMPLATE_DIRS = tuple(config.get('dirs', 'template_dirs').split())
MULTITENANT_TEMPLATE_DIRS = tuple(config.get('dirs', 'multitenant_template_dirs').split())
SHARED_APPS = (
+ 'base',
'tenant_schemas',
'entrouvert.djommon.multitenant',
+ 'admin_tools',
+ 'admin_tools.theming',
+ 'admin_tools.menu',
+ 'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
@@ -152,6 +156,10 @@ SHARED_APPS = (
)
TENANT_APPS = (
+ 'admin_tools',
+ 'admin_tools.theming',
+ 'admin_tools.menu',
+ 'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
@@ -159,10 +167,6 @@ TENANT_APPS = (
'django.contrib.staticfiles',
'django.contrib.contenttypes',
'south',
- 'admin_tools',
- 'admin_tools.theming',
- 'admin_tools.menu',
- 'admin_tools.dashboard',
'registration',
'authentic2.nonce',
'authentic2.saml',
@@ -180,6 +184,11 @@ INSTALLED_APPS = SHARED_APPS + TENANT_APPS
INSTALLED_APPS += ('tenant_schemas', 'entrouvert.djommon.multitenant',)
TENANT_MODEL = 'multitenant.Tenant'
+PUBLIC_SCHEMA_NAME = 'public'
+
+ROOT_URLCONF = 'univnautes_idp.urls'
+PUBLIC_SCHEMA_URLCONF = 'univnautes_idp.urls_public'
+
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
@@ -267,9 +276,9 @@ ACCOUNT_ACTIVATION_DAYS = 3
PASSWORD_RESET_TIMEOUT_DAYS = 3
# Admin tools
-ADMIN_TOOLS_INDEX_DASHBOARD = 'authentic2.dashboard.CustomIndexDashboard'
-ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'authentic2.dashboard.CustomAppIndexDashboard'
-ADMIN_TOOLS_MENU = 'authentic2.menu.CustomMenu'
+ADMIN_TOOLS_INDEX_DASHBOARD = 'univnautes_idp.dashboard.CustomIndexDashboard'
+ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'univnautes_idp.dashboard.CustomAppIndexDashboard'
+#ADMIN_TOOLS_MENU = 'authentic2.menu.CustomMenu'
# AUTH systels
AUTH_SAML2 = False
diff --git a/univnautes_idp/urls_public.py b/univnautes_idp/urls_public.py
new file mode 100644
index 0000000..ec4ec37
--- /dev/null
+++ b/univnautes_idp/urls_public.py
@@ -0,0 +1,12 @@
+from django.conf.urls import patterns, url, include
+from django.views.generic import TemplateView
+from authentic2.urls import urlpatterns as authentic2_urlpatterns
+
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ url(r'^$', TemplateView.as_view(template_name="univnautes-idp/homepage.html")),
+ url(r'^admin/', include(admin.site.urls)),
+ url(r'^admin_tools/', include('admin_tools.urls')),
+)