homepage shows new apps, old ones in legacy (#5357)
This commit is contained in:
parent
b776e3b6f7
commit
52a2d4f4cc
28
README
28
README
|
@ -51,3 +51,31 @@ manage.py options
|
|||
Activate multi-tenant mode. The python-entrouvert package
|
||||
must be installed.
|
||||
|
||||
|
||||
LICENSES
|
||||
========
|
||||
|
||||
Passerelle
|
||||
Copyright (C) 2013-2014 Entr'ouvert <info@entrouvert.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Affero General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License along
|
||||
with this program (LICENSE file). If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
icons
|
||||
-----
|
||||
|
||||
icon-concerto.svg license:
|
||||
Creative Commons – Attribution (CC BY 3.0) http://creativecommons.org/licenses/by/3.0/us/
|
||||
"Family" designed by Ahmed Elzahra http://www.thenounproject.com/trochilidae/
|
||||
from the Noun Project http://www.thenounproject.com/
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
Passerelle
|
||||
{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Welcome' %}</h2>
|
||||
{% endblock %}
|
||||
|
@ -22,10 +18,10 @@ Passerelle provides an uniform access to multiple data sources and services.
|
|||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
{% for a in apps %}
|
||||
<p>
|
||||
<a href="{{ a.url }}">{% trans a.name %}</a>
|
||||
</p>
|
||||
{% endfor %}
|
||||
<ul class="apps">
|
||||
{% for a in apps %}
|
||||
<li class="{{ a.get_icon_class }}"><a href="{{ a.get_absolute_url }}">{{ a.get_verbose_name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{% extends "passerelle/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block more-user-links %}
|
||||
{{ block.super }}
|
||||
<a href="">{% trans 'Legacy' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>{% trans 'Legacy data sources and services' %}</h3>
|
||||
<ul class="apps">
|
||||
{% for a in legacy_apps %}
|
||||
<li class="ressources"><a href="../{{ a.url }}">{% trans a.name %}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
|
@ -6,7 +6,7 @@ from django.contrib import admin
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.static import serve as static_serve
|
||||
|
||||
from .views import APPS_PATTERNS, HomePageView, ManageView, ManageAddView
|
||||
from .views import HomePageView, ManageView, ManageAddView, LEGACY_APPS_PATTERNS, LegacyPageView
|
||||
from .urls_utils import decorated_includes
|
||||
from .base.urls import access_urlpatterns
|
||||
|
||||
|
@ -24,6 +24,7 @@ admin.autodiscover()
|
|||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', HomePageView.as_view(), name='homepage'),
|
||||
url(r'^legacy/$', LegacyPageView.as_view(), name='legacy'),
|
||||
|
||||
url(r'^manage/$', login_required(ManageView.as_view()), name='manage-home'),
|
||||
url(r'^manage/add$', login_required(ManageAddView.as_view()), name='add-connector'),
|
||||
|
@ -77,7 +78,7 @@ urlpatterns = patterns('',
|
|||
)
|
||||
|
||||
# activate URL for installed apps only
|
||||
for app, d in APPS_PATTERNS.items():
|
||||
for app, d in LEGACY_APPS_PATTERNS.items():
|
||||
if 'passerelle.%s' % app in settings.INSTALLED_APPS:
|
||||
urlpatterns += patterns('',
|
||||
url(r'^%s/' % d['url'], include('passerelle.%s.urls' % app),
|
||||
|
|
|
@ -4,26 +4,6 @@ from django.db import models
|
|||
|
||||
from passerelle.base.models import BaseResource
|
||||
|
||||
APPS_PATTERNS = {
|
||||
'datasources': {'url': 'data', 'name': 'Data Sources'},
|
||||
'repost': {'url': 'repost', 'name': 'Re-Post'},
|
||||
'register': {'url': r'register', 'name': 'Register'},
|
||||
'queue': {'url': r'queue', 'name': 'Queues'},
|
||||
}
|
||||
|
||||
|
||||
class HomePageView(TemplateView):
|
||||
template_name = 'passerelle/homepage.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(HomePageView, self).get_context_data(**kwargs)
|
||||
context['apps'] = []
|
||||
for app in (app for app in settings.INSTALLED_APPS if app.startswith('passerelle.')):
|
||||
app = app.split('.')[1]
|
||||
if app in APPS_PATTERNS:
|
||||
context['apps'].append(APPS_PATTERNS[app])
|
||||
return context
|
||||
|
||||
|
||||
def get_all_apps():
|
||||
# TODO: once the legacy connectors are ported, the test on get_icon_class
|
||||
|
@ -32,6 +12,19 @@ def get_all_apps():
|
|||
hasattr(x, 'get_icon_class')]
|
||||
|
||||
|
||||
|
||||
class HomePageView(TemplateView):
|
||||
template_name = 'passerelle/homepage.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(HomePageView, self).get_context_data(**kwargs)
|
||||
# get all app instances
|
||||
context['apps'] = []
|
||||
for app in get_all_apps():
|
||||
context['apps'].extend(app.objects.all())
|
||||
return context
|
||||
|
||||
|
||||
class ManageView(TemplateView):
|
||||
template_name = 'passerelle/manage.html'
|
||||
|
||||
|
@ -51,3 +44,25 @@ class ManageAddView(TemplateView):
|
|||
context = super(ManageAddView, self).get_context_data(**kwargs)
|
||||
context['apps'] = get_all_apps()
|
||||
return context
|
||||
|
||||
|
||||
# legacy
|
||||
LEGACY_APPS_PATTERNS = {
|
||||
'datasources': {'url': 'data', 'name': 'Data Sources'},
|
||||
'repost': {'url': 'repost', 'name': 'Re-Post'},
|
||||
'register': {'url': r'register', 'name': 'Register'},
|
||||
'queue': {'url': r'queue', 'name': 'Queues'},
|
||||
}
|
||||
|
||||
class LegacyPageView(TemplateView):
|
||||
template_name = 'passerelle/legacy.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(LegacyPageView, self).get_context_data(**kwargs)
|
||||
# legacy apps (categories)
|
||||
context['legacy_apps'] = []
|
||||
for app in (app for app in settings.INSTALLED_APPS
|
||||
if app.startswith('passerelle.')
|
||||
and app.split('.')[1] in LEGACY_APPS_PATTERNS):
|
||||
context['legacy_apps'].append(LEGACY_APPS_PATTERNS[app.split('.')[1]])
|
||||
return context
|
||||
|
|
Loading…
Reference in New Issue