Browse Source

Update documentation

Denis K 9 years ago
parent
commit
c86114d3fd

+ 2 - 1
docs/autocomplete.rst

@@ -37,4 +37,5 @@ Example from Django JET demo site:
 
 
 Now all your admin select boxes will perform AJAX queries to load available options while you type.
 Now all your admin select boxes will perform AJAX queries to load available options while you type.
 
 
-.. note:: This work for both ForeignKey and ManyToManyField fields.
+.. note::
+    This work for both ForeignKey and ManyToManyField fields.

+ 3 - 2
docs/config_file.rst

@@ -14,7 +14,8 @@ Possible built-in themes are:
 * default
 * default
 * green
 * green
 
 
-.. note:: More themes are incoming in future.
+.. note::
+    More themes are incoming in future.
 
 
 To change theme use parameter:
 To change theme use parameter:
 
 
@@ -48,5 +49,5 @@ Same as **JET_INDEX_DASHBOARD**, but for application pages
 
 
 .. code:: python
 .. code:: python
 
 
-    JET_APP_INDEX_DASHBOARD = g'jet.dashboard.DefaultAppIndexDashboard'
+    JET_APP_INDEX_DASHBOARD = 'jet.dashboard.DefaultAppIndexDashboard'
 
 

+ 5 - 4
docs/dashboard.rst

@@ -2,8 +2,9 @@
 Dashboard
 Dashboard
 =========
 =========
 
 
-Django JET Dashboard tries to be as compatible as possible with django-admin-tools dashboard so that
-django-admint-tools modules could be easily ported to Django JET. In most cases in will be enough to
-change python imports in dashboard.py and remove extending in modules templates.
+.. toctree::
+   :maxdepth: 2
 
 
-More info incoming.
+   dashboard_getting_started
+   dashboard_modules
+   dashboard_base

+ 11 - 0
docs/dashboard_base.rst

@@ -0,0 +1,11 @@
+============
+Base Classes
+============
+
+.. _Dashboard:
+.. autoclass:: jet.dashboard.dashboard.Dashboard
+   :members:
+
+.. _Dashboard Module:
+.. autoclass:: jet.dashboard.modules.DashboardModule
+   :members:

+ 65 - 0
docs/dashboard_getting_started.rst

@@ -0,0 +1,65 @@
+===============
+Getting Started
+===============
+
+.. note::
+   Django JET Dashboard tries to be as compatible as possible with django-admin-tools dashboard so that
+   django-admin-tools modules could be easily ported to Django JET. In most cases in will be enough to
+   change python imports and remove extending in modules templates.
+
+Dashboard represents ``Dashboard`` class instance with ``DashboardModule`` class instances as its children.
+Any custom **Dashboard** class should inherit ``jet.dashboard.dashboard.Dashboard``
+and use ``init_with_context`` to fill it with widgets. You should add your widgets
+to ``children`` and ``available_children`` attributes.
+
+
+Set Up Custom Dashboard
+-----------------------
+
+* Create ``dashboard.py`` in any suitable location (e.g., in your project root) with the following content:
+
+   .. code-block:: python
+
+      from django.utils.translation import ugettext_lazy as _
+      from jet.dashboard import modules
+      from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
+
+
+      class CustomIndexDashboard(Dashboard):
+          columns = 3
+
+          def init_with_context(self, context):
+              self.available_children.append(modules.LinkList)
+              self.children.append(modules.LinkList(
+                  _('Support'),
+                  children=[
+                      {
+                          'title': _('Django documentation'),
+                          'url': 'http://docs.djangoproject.com/',
+                          'external': True,
+                      },
+                      {
+                          'title': _('Django "django-users" mailing list'),
+                          'url': 'http://groups.google.com/group/django-users',
+                          'external': True,
+                      },
+                      {
+                          'title': _('Django irc channel'),
+                          'url': 'irc://irc.freenode.net/django',
+                          'external': True,
+                      },
+                  ],
+                  column=0,
+                  order=0
+              ))
+
+
+* Add to your settings.py path to created ``dashboard.py`` (example for ``dashboard.py`` in project root):
+
+.. code:: python
+
+    JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
+
+That's all, now you have dashboard with only one widget - ``LinkList``. Dashboard reset may be needed
+if your had another dashboard already rendered for any user. Visit :doc:`dashboard_modules` to learn
+other widgets you can add to your custom dashboard or create your own.

+ 139 - 0
docs/dashboard_modules.rst

@@ -0,0 +1,139 @@
+=================
+Dashboard modules
+=================
+
+Build-in dashboard modules
+==========================
+
+LinkList
+--------
+
+.. autoclass:: jet.dashboard.modules.LinkList
+   :members:
+
+AppList
+-------
+
+.. autoclass:: jet.dashboard.modules.AppList
+   :members:
+
+ModelList
+---------
+
+.. autoclass:: jet.dashboard.modules.ModelList
+   :members:
+
+RecentActions
+-------------
+
+.. autoclass:: jet.dashboard.modules.RecentActions
+   :members:
+
+Feed
+----
+
+.. autoclass:: jet.dashboard.modules.Feed
+   :members:
+
+Google Analytics widgets
+========================
+
+.. attention::
+   Google Analytics widgets required extra setup
+
+Extra Installation
+------------------
+
+* Install python package:
+
+.. code::
+
+   pip install google-api-python-client
+
+* Specify path to your Google Analytics ``client_secrets.json`` (obtained at Google website):
+
+.. code::
+
+   JET_MODULE_GOOGLE_ANALYTICS_CLIENT_SECRETS_FILE = os.path.join(PROJECT_DIR, 'client_secrets.json')
+
+* Add import to the top of your urls.py:
+
+.. code::
+
+   from jet.dashboard.dashboard_modules import google_analytics_views
+
+
+Usage example
+-------------
+   .. code-block:: python
+
+     from django.utils.translation import ugettext_lazy as _
+     from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
+     from jet.dashboard.dashboard_modules import google_analytics
+
+
+     class CustomIndexDashboard(Dashboard):
+         columns = 3
+
+         def init_with_context(self, context):
+            self.available_children.append(google_analytics.GoogleAnalyticsVisitorsTotals)
+            self.available_children.append(google_analytics.GoogleAnalyticsVisitorsChart)
+            self.available_children.append(google_analytics.GoogleAnalyticsPeriodVisitors)
+
+.. autoclass:: jet.dashboard.dashboard_modules.google_analytics.GoogleAnalyticsVisitorsTotals
+   :members:
+
+.. autoclass:: jet.dashboard.dashboard_modules.google_analytics.GoogleAnalyticsVisitorsChart
+   :members:
+
+.. autoclass:: jet.dashboard.dashboard_modules.google_analytics.GoogleAnalyticsPeriodVisitors
+   :members:
+
+Yandex Metrika widgets
+======================
+
+.. attention::
+   Yandex Metrika widgets required extra setup
+
+Extra Installation
+------------------
+
+* Set your Yandex Metrika CLIENT_ID and CLIENT_SECRET (obtained at Yandex Metrika API website):
+
+.. code::
+
+   JET_MODULE_YANDEX_METRIKA_CLIENT_ID = 'YANDEX_METRIKA_CLIENT_ID'
+   JET_MODULE_YANDEX_METRIKA_CLIENT_SECRET = 'YANDEX_METRIKA_CLIENT_SECRET'
+
+* Add import to the top of your urls.py:
+
+.. code::
+
+   from jet.dashboard.dashboard_modules import yandex_metrika_views
+
+
+Usage example
+-------------
+   .. code-block:: python
+
+     from django.utils.translation import ugettext_lazy as _
+     from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
+     from jet.dashboard.dashboard_modules import yandex_metrika
+
+
+     class CustomIndexDashboard(Dashboard):
+         columns = 3
+
+         def init_with_context(self, context):
+            self.available_children.append(yandex_metrika.YandexMetrikaVisitorsTotals)
+            self.available_children.append(yandex_metrika.YandexMetrikaVisitorsChart)
+            self.available_children.append(yandex_metrika.YandexMetrikaPeriodVisitors)
+
+.. autoclass:: jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaVisitorsTotals
+   :members:
+
+.. autoclass:: jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaVisitorsChart
+   :members:
+
+.. autoclass:: jet.dashboard.dashboard_modules.yandex_metrika.YandexMetrikaPeriodVisitors
+   :members:

+ 4 - 3
docs/install.rst

@@ -2,9 +2,10 @@
 Installation
 Installation
 ============
 ============
 
 
-.. note:: After following this instruction Django JET dashboard won't be active (as it is located into
-          a separate application). If you want to make it work, you will have to enable dashboard application
-          by following :doc:`install_dashboard` steps too.
+.. note::
+    After following this instruction Django JET dashboard won't be active (as it is located into
+    a separate application). If you want to make it work, you will have to enable dashboard application
+    by following :doc:`install_dashboard` steps too.
 
 
 * Download and install latest version of Django JET:
 * Download and install latest version of Django JET:
 
 

+ 4 - 2
docs/install_dashboard.rst

@@ -2,8 +2,9 @@
 Dashboard installation
 Dashboard installation
 ======================
 ======================
 
 
-.. note:: Dashboard is located into a separate application. So after a typical JET installation it won't be active.
-          To enable dashboard application follow these steps:
+.. note::
+    Dashboard is located into a separate application. So after a typical JET installation it won't be active.
+    To enable dashboard application follow these steps:
 
 
 * Add 'jet.dashboard' application to the INSTALLED_APPS setting of your Django project settings.py file (note it should be before 'jet'):
 * Add 'jet.dashboard' application to the INSTALLED_APPS setting of your Django project settings.py file (note it should be before 'jet'):
 
 
@@ -49,3 +50,4 @@ Dashboard installation
 
 
         python manage.py collectstatic
         python manage.py collectstatic
 
 
+Dashboard installed! Learn about making your custom dashboard here :doc:`dashboard`.