Skip to content
Browse files

Added FLUENT_DASHBOARD_CMS_APP_NAMES / MODEL_ORDER

This improves the CMS integration, custom CMS modules can be associated
as "CMS" app, and will appear in the "CMS" application group.
  • Loading branch information...
1 parent 427e059 commit 920657591c6e98b48c9fdb9baecd48a0f8789221 @vdboor vdboor committed Nov 16, 2011
Showing with 86 additions and 35 deletions.
  1. +57 −10 docs/configuration.rst
  2. +2 −0 docs/installation.rst
  3. +11 −25 fluent_dashboard/appgroups.py
  4. +16 −0 fluent_dashboard/appsettings.py
View
67 docs/configuration.rst
@@ -7,6 +7,11 @@ A quick overvivew of the available settings:
.. code-block:: python
+ from django.utils.translation import ugettext_lazy as _
+
+
+ # Icon settings
+
FLUENT_DASHBOARD_ICON_THEME = 'oxygen'
FLUENT_DASHBOARD_APP_ICONS = {
@@ -21,7 +26,8 @@ A quick overvivew of the available settings:
FLUENT_DASHBOARD_DEFAULT_ICON = 'unknown.png'
- FLUENT_DASHBOARD_CMS_PAGE_MODEL = ('cms', 'page')
+
+ # Application grouping:
FLUENT_DASHBOARD_APP_GROUPS = (
(_('CMS'), {
@@ -56,14 +62,35 @@ A quick overvivew of the available settings:
}),
)
+
+ # CMS integration:
+
+ FLUENT_DASHBOARD_CMS_PAGE_MODEL = ('cms', 'page')
+
+ FLUENT_DASHBOARD_CMS_APP_NAMES = (
+ 'cms', # DjangoCMS
+ 'pages', # FeinCMS
+ 'fiber', # Django-Fiber
+ '*cms*', # wildcard match
+ )
+
+ FLUENT_DASHBOARD_CMS_MODEL_ORDER = {
+ 'page': 1,
+ 'object': 2,
+ 'layout': 3,
+ 'content': 4,
+ 'file': 5,
+ 'site': 99
+ }
+
The icon names/paths are parsed in the following way:
* When the icon is an absolute URL, it is used as-is.
* When the icon contains a slash, it is relative from the ``STATIC_URL``.
* When the icon has no slashes, it's relative to the theme url folder (typically `STATIC_URL`/ecms_dashboard/`themename`/),
-Full list of settings
----------------------
+Icon settings
+-------------
.. _FLUENT_DASHBOARD_ICON_THEME:
@@ -89,22 +116,19 @@ FLUENT_DASHBOARD_DEFAULT_ICON
In case a suitable icon is not found, this icon is used.
-.. _FLUENT_DASHBOARD_APP_GROUPS:
-FLUENT_DASHBOARD_CMS_PAGE_MODEL
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Application grouping
+--------------------
-The model used to display a link to the CMS pages.
-The value is a tuple of application name, and model name.
-This is used in the welcome text of the :class:`~fluent_dashboard.modules.PersonalModule`.
+.. _FLUENT_DASHBOARD_APP_GROUPS:
FLUENT_DASHBOARD_APP_GROUPS
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The application groups to display at the dashboard.
Each tuple has a title, and dictionary which can have the following fields:
-* **models:** which models should be included. Simple pattern based filtering is provided by `django-admin-tools`, based on :func:`fnmatch()`.
+* **models:** which models should be included. Simple pattern based filtering is provided by :func:`fnmatch()`.
* **collapsible:** whether the group can be collapsed to a single line. Default is ``False`` for all elements to reduce clutter.
* **module:** which dashboard module can be used. Possible values are:
@@ -118,3 +142,26 @@ By default, there is a section for "CMS", "Interactivity" and "Administration" f
The ``*`` selector without any application name, is special:
it matches all applications which are not placed in any other groups.
+CMS integration
+---------------
+
+FLUENT_DASHBOARD_CMS_PAGE_MODEL
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The model used to display a link to the CMS pages.
+The value is a tuple of application name, and model name.
+This is used in the welcome text of the :class:`~fluent_dashboard.modules.PersonalModule`.
+
+FLUENT_DASHBOARD_CMS_APP_NAMES
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A list of patterns to define which applications should be considered as "CMS" applications.
+These applications are sorted on top in the :class:`~fluent_dashboard.modules.CmsAppIconList`
+and `~fluent_dashboard.items.CmsModelList` classes. The default ``FLUENT_DASHBOARD_APP_GROUPS``
+also uses this setting to fill the "CMS" category.
+
+FLUENT_DASHBOARD_CMS_MODEL_ORDER
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+A dictionary of modelname/ordering items, to sort the models of CMS applications in a custom order.
+This can be used for example, to display the pages model first, and the files/images models next.
View
2 docs/installation.rst
@@ -38,3 +38,5 @@ Next, the `django-admin-tools` can be configured to use the ``fluent_dashboard``
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'fluent_dashboard.dashboard.FluentAppIndexDashboard'
ADMIN_TOOLS_MENU = 'fluent_dashboard.menu.FluentMenu'
+The Django admin dashboard should open now with the dashboard, configured with reasonable defaults.
+The application groups and icons can be customized with additional :doc:`configuration <configuration>`.
View
36 fluent_dashboard/appgroups.py
@@ -2,6 +2,7 @@
Splitting and organizing applications and models into groups.
This module is mostly meant for internal use.
"""
+from fnmatch import fnmatch
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
from fluent_dashboard import appsettings
@@ -13,21 +14,6 @@
if '*' in ALL_KNOWN_APPS:
ALL_KNOWN_APPS.remove('*') # Default for CMS group, but not useful here.
-CMS_APP_NAMES = (
- 'cms', # DjangoCMS
- 'pages', # FeinCMS
- 'fiber', # Django-Fiber
-)
-
-CMS_MODEL_ORDER = {
- 'page': 1,
- 'object': 2,
- 'layout': 3,
- 'content': 4,
- 'file': 5,
- 'site': 99
-)
-
MODULE_ALIASES = {
'AppList': 'admin_tools.dashboard.modules.AppList',
'AppIconList': 'fluent_dashboard.modules.AppIconList',
@@ -69,7 +55,7 @@ def sort_cms_models(cms_models):
Sort a set of CMS-related models in a custom (predefined) order.
"""
cms_models.sort(key=lambda model: (
- get_cms_model_order(model['name']) if is_cms_app(model['app_name']) else 100,
+ get_cms_model_order(model['name']) if is_cms_app(model['app_name']) else 999,
model['app_name'],
model['title']
))
@@ -79,21 +65,21 @@ def is_cms_app(app_name):
"""
Return whether the given application is a CMS app
"""
- return app_name in CMS_APP_NAMES or 'cms' in app_name
-
+ for pat in appsettings.FLUENT_DASHBOARD_CMS_APP_NAMES:
+ if fnmatch(app_name, pat):
+ return True
-def get_app_order(app_name):
- if is_cms_app(app_name):
- return 0
- else:
- return 1
+ return False
def get_cms_model_order(model_name):
- for name, order in CMS_MODEL_ORDER.iteritems():
+ """
+ Return a numeric ordering for a model name.
+ """
+ for name, order in appsettings.FLUENT_DASHBOARD_CMS_MODEL_ORDER.iteritems():
if name in model_name:
return order
- return 99
+ return 999
def get_class(import_path):
View
16 fluent_dashboard/appsettings.py
@@ -40,6 +40,22 @@
FLUENT_DASHBOARD_CMS_PAGE_MODEL = getattr(settings, "FLUENT_DASHBOARD_CMS_PAGE_MODEL", None)
+FLUENT_DASHBOARD_CMS_APP_NAMES = getattr(settings, "FLUENT_DASHBOARD_CMS_APP_NAMES", (
+ 'cms', # DjangoCMS
+ 'pages', # FeinCMS
+ 'fiber', # Django-Fiber
+ '*cms*', # wildcard match
+))
+
+FLUENT_DASHBOARD_CMS_MODEL_ORDER = getattr(settings, "FLUENT_DASHBOARD_CMS_MODEL_ORDER", {
+ 'page': 1,
+ 'object': 2,
+ 'layout': 3,
+ 'content': 4,
+ 'file': 5,
+ 'site': 99
+})
+
FLUENT_DASHBOARD_APP_ICONS.update(getattr(settings, 'FLUENT_DASHBOARD_APP_ICONS', {}))
FLUENT_DASHBOARD_APP_GROUPS = getattr(settings, 'FLUENT_DASHBOARD_APP_GROUPS', (

0 comments on commit 9206575

Please sign in to comment.
Something went wrong with that request. Please try again.