Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
f1nality committed Apr 29, 2017
2 parents 45e9471 + 1e1ea92 commit 05b5433
Show file tree
Hide file tree
Showing 34 changed files with 249 additions and 100 deletions.
47 changes: 32 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ python:
- 3.2
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
env:
- DJANGO=1.6.11
- DJANGO=1.7.7
- DJANGO=1.8.3
- DJANGO=1.9.8
- DJANGO=1.10.0
- DJANGO="<1.7"
- DJANGO="<1.8"
- DJANGO="<1.9"
- DJANGO="<1.10"
- DJANGO="<1.11"
- DJANGO="<1.12"
before_install:
- export DJANGO_SETTINGS_MODULE=jet.tests.settings
install:
- pip install -q Django==$DJANGO --use-mirrors
- pip install . --use-mirrors
- pip install -q "Django${DJANGO}"
- pip install .
- pip install coverage==3.7.1
- pip install coveralls==0.5
script:
Expand All @@ -27,18 +30,32 @@ after_success:
matrix:
exclude:
- python: 2.6
env: DJANGO=1.7.7
env: DJANGO="<1.8"
- python: 2.6
env: DJANGO=1.8.3
env: DJANGO="<1.9"
- python: 2.6
env: DJANGO=1.9.8
env: DJANGO="<1.10"
- python: 3.2
env: DJANGO=1.9.8
env: DJANGO="<1.10"
- python: 3.3
env: DJANGO=1.9.8
env: DJANGO="<1.10"
- python: 2.6
env: DJANGO=1.10.0
env: DJANGO="<1.11"
- python: 3.2
env: DJANGO=1.10.0
env: DJANGO="<1.11"
- python: 3.3
env: DJANGO=1.10.0
env: DJANGO="<1.11"
- python: 2.6
env: DJANGO="<1.12"
- python: 3.2
env: DJANGO="<1.12"
- python: 3.3
env: DJANGO="<1.12"
- python: 3.5
env: DJANGO="<1.7"
- python: 3.5
env: DJANGO="<1.8"
- python: 3.6
env: DJANGO="<1.7"
- python: 3.6
env: DJANGO="<1.8"
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Changelog
=========

1.0.6
-----
* PR-191: Added sidebar pinning functionality (thanks to grigory51 for PR)
* Issue-199: Fixed Django 1.11 context issue (thanks to gileadslostson for report)
* Issue-202: Fixed inline-group-row:added event (thanks to a1Gupta for report)
* Issue-188: Make testing use latest major Django versions and Python 3.5, 3.6 (thanks to liminspace for report)
* Added new flexible menu customizing setting JET_SIDE_MENU_ITEMS
* Added labels to sibling buttons
* Fixed django.jQuery select change events
* Fixed sidebar "Search..." label localization
* Added select disabled style
* Fixed initial value for select2 ajax fields when POST request


1.0.5
-----
* PR-167: Added fallback to window.opener to support old Django popups (thanks to michaelkuty for PR)
Expand Down
107 changes: 79 additions & 28 deletions docs/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,61 +95,112 @@ CUSTOM MENU
-----------

By default JET displays all applications and it models in the side menu in the alphabetical order.
To display applications and models you want or to change their order you can use ``JET_SIDE_MENU_CUSTOM_APPS`` setting.
To display applications and models you want or to change their order you can use ``JET_SIDE_MENU_ITEMS`` setting.

.. code:: python
JET_SIDE_MENU_CUSTOM_APPS = [
('core', [ # Each list element is a tuple with application name (app_label) and list of models
'User',
'MenuItem',
'Block',
]),
('shops', [
'Shop',
'City',
'MetroStation',
]),
('feedback', [
'Feedback',
]),
JET_SIDE_MENU_ITEMS = [ # A list of application or custom item dicts
{'label': _('General'), 'app_label': 'core', 'items': [
{'name': 'help.question'},
{'name': 'pages.page', 'label': _('Static page')},
{'name': 'city'},
{'name': 'validationcode'},
{'label': _('Analytics'), 'url': 'http://example.com', 'url_blank': True},
]},
{'label': _('Users'), 'items': [
{'name': 'core.user'},
{'name': 'auth.group'},
{'name': 'core.userprofile', 'permissions': ['core.user']},
]},
{'app_label': 'banners', 'items': [
{'name': 'banner'},
{'name': 'bannertype'},
]},
]
If want to show all application's models use ``__all__`` keyword.
JET_SIDE_MENU_ITEMS is a list of application or custom item dicts. Each item can have the following keys:

.. code:: python
* `app_label` - application name
* `label` - application text label
* `items` - list of children items
* `url` - custom url (format is described below)
* `url_blank` - open url in new table (boolean)
* `permissions` - list of required permissions to display item

JET_SIDE_MENU_CUSTOM_APPS = [
('core', ['__all__']),
...
]
Setting `items` and either `app_label` or `label` is required. Other keys are optional to override default behavior.
Order of items is respected. Each menu item is also a dict with the following keys:

* `name` - model name (can be either `MODEL_NAME` or `APP_LABEL.MODEL_NAME`)
* `label` - item text label
* `url` - custom url (format is described below)
* `url_blank` - open url in new table (boolean)
* `permissions` - list of required permissions to display item

Setting either `name` or `label` is required. Other keys are optional to override default behavior.
Order of items is respected.

URLs can be either `string` or `dict`. Examples of possible values:

* http://example.com/
* {'type': 'app', 'app_label': 'pages'}
* {'type': 'model', 'app_label': 'pages', 'model': 'page'}
* {'type': 'reverse', 'name': 'pages:list', 'args': [1], 'kwargs': {'category': 2}}

.. deprecated:: 1.0.6

Old way of customizing menu items via `JET_SIDE_MENU_CUSTOM_APPS` setting is now deprecated in favor
of new `JET_SIDE_MENU_ITEMS` setting.

.. code:: python
JET_SIDE_MENU_CUSTOM_APPS = [
('core', [ # Each list element is a tuple with application name (app_label) and list of models
'User',
'MenuItem',
'Block',
]),
('shops', [
'Shop',
'City',
'MetroStation',
]),
('feedback', [
'Feedback',
]),
]
If have multiple admin sites and you want to specify different menu applications for each admin site, wrap menu lists
in dictionary with admin site names as keys:

.. code:: python
JET_SIDE_MENU_CUSTOM_APPS = {
JET_SIDE_MENU_ITEMS = {
'admin': [
('core', ['__all__']),
{'label': _('General'), 'app_label': 'core', 'items': [
{'name': 'help.question'},
{'name': 'pages.page'},
{'name': 'city'},
{'name': 'validationcode'},
]},
...
],
'custom_admin': [
('custom_admin_app', [
'CustomAdminAppModel',
]),
{'app_label': 'talks', 'items': [
{'name': 'talk'},
{'name': 'talkmessage'},
]},
...
]
}
.. note::

You can use ``jet_custom_apps_example`` management command to generate example ``JET_SIDE_MENU_CUSTOM_APPS``
You can use ``jet_side_menu_items_example`` management command to generate example ``JET_SIDE_MENU_ITEMS``
setting which includes all your applications and models. You can use it this way:

.. code:: python
python manage.py jet_custom_apps_example
python manage.py jet_side_menu_items_example
JET_CHANGE_FORM_SIBLING_LINKS
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion jet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.0.5'
VERSION = '1.0.6'
17 changes: 9 additions & 8 deletions jet/dashboard/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from django.template import Context
from importlib import import_module
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.template.loader import render_to_string
from jet.dashboard import modules
from jet.dashboard.models import UserDashboardModule
from django.utils.translation import ugettext_lazy as _
from jet.ordered_set import OrderedSet
from jet.utils import get_admin_site_name
from jet.utils import get_admin_site_name, context_to_dict

try:
from django.template.context_processors import csrf
except ImportError:
Expand Down Expand Up @@ -48,9 +52,6 @@ def __init__(self, context, **kwargs):
self.set_context(context)

def set_context(self, context):
if isinstance(context, Context):
context = context.flatten()

self.context = context
self.init_with_context(context)
self.load_modules()
Expand Down Expand Up @@ -150,7 +151,7 @@ def load_modules(self):
self.modules = loaded_modules

def render(self):
context = self.context
context = context_to_dict(self.context)
context.update({
'columns': range(self.columns),
'modules': self.modules,
Expand All @@ -161,7 +162,7 @@ def render(self):
return render_to_string('jet.dashboard/dashboard.html', context)

def render_tools(self):
context = self.context
context = context_to_dict(self.context)
context.update({
'children': self.children,
'app_label': self.app_label,
Expand Down
6 changes: 5 additions & 1 deletion jet/dashboard/dashboard_modules/google_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import datetime
import json
from django import forms
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.forms import Widget
from django.utils import formats
from django.utils.html import format_html
Expand Down
6 changes: 5 additions & 1 deletion jet/dashboard/dashboard_modules/google_analytics_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.conf.urls import url
from django.contrib import messages
from django.shortcuts import redirect
Expand Down
6 changes: 5 additions & 1 deletion jet/dashboard/dashboard_modules/yandex_metrika.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import datetime
import json
from django import forms
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.forms import Widget
from django.utils import formats
from django.utils.html import format_html
Expand Down
6 changes: 5 additions & 1 deletion jet/dashboard/dashboard_modules/yandex_metrika_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.conf.urls import url
from django.contrib import messages
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.http import HttpResponse
from django.shortcuts import redirect
from jet.dashboard.dashboard_modules.yandex_metrika import YandexMetrikaClient
Expand Down
4 changes: 2 additions & 2 deletions jet/dashboard/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models import Q
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from jet.utils import get_app_list, LazyDateTimeEncoder
from jet.utils import get_app_list, LazyDateTimeEncoder, context_to_dict
import datetime


Expand Down Expand Up @@ -148,7 +148,7 @@ def init_with_context(self, context):
pass

def get_context_data(self):
context = self.context
context = context_to_dict(self.context)
context.update({
'module': self
})
Expand Down
6 changes: 5 additions & 1 deletion jet/dashboard/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

from django.forms.formsets import formset_factory
from django.http import HttpResponseRedirect
from django.views.decorators.http import require_POST, require_GET
Expand Down
5 changes: 4 additions & 1 deletion jet/filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.contrib.admin import RelatedFieldListFilter
from django.utils.encoding import smart_text
from django.utils.html import format_html
from django.core.urlresolvers import reverse
try:
from django.core.urlresolvers import reverse
except ImportError: # Django 1.11
from django.urls import reverse

try:
from django.contrib.admin.utils import get_model_from_relation
Expand Down
2 changes: 1 addition & 1 deletion jet/management/commands/jet_side_menu_items_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Request:
self.stdout.write('JET_SIDE_MENU_ITEMS = [')

for app in app_list:
self.stdout.write(' {\'app_label\': \'%s\', \'models\': [' % (
self.stdout.write(' {\'app_label\': \'%s\', \'items\': [' % (
app['app_label']
))

Expand Down
2 changes: 1 addition & 1 deletion jet/static/jet/css/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@
color: $hover-link-color;
}

body.menu-pinned & {
body.login &, body.menu-pinned & {
display: none;
}

Expand Down
2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/default/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/default/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/green/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/green/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-blue/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-blue/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-gray/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-gray/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-green/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-green/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-violet/base.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/themes/light-violet/base.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jet/static/jet/css/vendor.css

Large diffs are not rendered by default.

Loading

0 comments on commit 05b5433

Please sign in to comment.