Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
f1nality committed Oct 22, 2015
2 parents 77b76b7 + 42c3c8e commit 893b951
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Changelog
* [Fix] Fixed select2_lookups for posted data
* [Feature] Issue-14: Added ajax related field filters
* [Fix] Made booleanfield icons cross browser compatible
* [Fix] Issue-13: Added zh-hans i18n
* [Feature] Separate static browser cache for each jet version


0.1.1
Expand Down
19 changes: 16 additions & 3 deletions docs/autocomplete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Autocomplete
By default Django JET renders all possible choices for select inputs. This behavior may be unwanted if number of
available options is rather big. In this case Django JET allows you to load these options dynamically through AJAX.

In order to achieve this functionality all you have to do is specify which model fields should be
searchable by AJAX queries. Add this static method to your model and that's it!
In order to achieve this functionality all you have to do is :

* Specify which model fields should be searchable by AJAX queries. Add this static method to all models which you want to be searchable with AJAX:

.. code:: python
Expand Down Expand Up @@ -35,7 +36,19 @@ Example from Django JET demo site:
def autocomplete_search_fields():
return 'name', 'city__name'
Now all your admin select boxes will perform AJAX queries to load available options while you type.
* Use custom AJAX filter class ``jet.filters.RelatedFieldAjaxListFilter`` if you have any foreign key list filters:

.. code:: python
from jet.filters import RelatedFieldAjaxListFilter
class PersonAdmin(admin.ModelAdmin):
list_filter = (
...
('address', RelatedFieldAjaxListFilter),
)
* 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.
2 changes: 1 addition & 1 deletion jet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.1.1'
VERSION = '0.1.2'
37 changes: 37 additions & 0 deletions jet/static/jet/vendor/jquery-ui/i18n/datepicker-zh-HANS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Chinese initialisation for the jQuery UI date picker plugin. */
/* Written by Cloudream ([email protected]). */
(function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define([ "../datepicker" ], factory );
} else {

// Browser globals
factory( jQuery.datepicker );
}
}(function( datepicker ) {

datepicker.regional['zh-CN'] = {
closeText: '关闭',
prevText: '<上月',
nextText: '下月>',
currentText: '今天',
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
weekHeader: '周',
dateFormat: 'yy-mm-dd',
firstDay: 1,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: '年'};
datepicker.setDefaults(datepicker.regional['zh-CN']);

return datepicker.regional['zh-CN'];

}));
3 changes: 3 additions & 0 deletions jet/static/jet/vendor/select2/js/i18n/zh-HANS.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions jet/templates/admin/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n admin_static jet_tags %}
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}{% format_current_language LANGUAGE_CODE as LANGUAGE_CODE %}{% get_current_theme as THEME %}
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}{% format_current_language LANGUAGE_CODE as LANGUAGE_CODE %}{% get_current_theme as THEME %}{% get_current_jet_version as JET_VERSION %}
{% block html %}<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
Expand All @@ -11,10 +11,10 @@
<link href="{% static "jet/vendor/jquery-ui/jquery-ui.min.css" %}" rel="stylesheet" />
<link href="{% static "jet/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css" %}" rel="stylesheet" />
<link href="{% static "jet/vendor/perfect-scrollbar/css/perfect-scrollbar.css" %}" rel="stylesheet" />
<link href="{% static "jet/css/icons/style.css" %}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/base.css" %}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/select2.theme.css" %}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/jquery-ui.theme.css" %}" rel="stylesheet" />
<link href="{% static "jet/css/icons/style.css" %}?v={{ JET_VERSION }}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/base.css" %}?v={{ JET_VERSION }}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/select2.theme.css" %}?v={{ JET_VERSION }}" rel="stylesheet" />
<link href="{% static "jet/css/themes/"|add:THEME|add:"/jquery-ui.theme.css" %}?v={{ JET_VERSION }}" rel="stylesheet" />
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{% static "admin/css/ie.css" %}{% endblock %}" /><![endif]-->
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
{% block extrastyle %}{% endblock %}
Expand Down Expand Up @@ -48,8 +48,8 @@
var jet = jet || {};
jet.jQuery = jQuery.noConflict(true);
</script>
<script src="{% static "jet/js/main.min.js" %}"></script>
<script src="{% static "jet/js/select2.jet.min.js" %}"></script>
<script src="{% static "jet/js/main.min.js" %}?v={{ JET_VERSION }}"></script>
<script src="{% static "jet/js/select2.jet.min.js" %}?v={{ JET_VERSION }}"></script>
{% block extrahead %}{% endblock %}
</head>
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}">
Expand Down
7 changes: 6 additions & 1 deletion jet/templatetags/jet_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.admin.widgets import RelatedFieldWidgetWrapper
from django.utils.formats import get_format
from django.template import loader, Context
from jet import settings
from jet import settings, VERSION
from jet.models import Bookmark, PinnedApplication
import re
from jet.utils import get_app_list, get_model_instance_label
Expand Down Expand Up @@ -245,3 +245,8 @@ def format_current_language(language):
@register.assignment_tag(takes_context=True)
def get_current_theme(context):
return settings.JET_THEME


@register.assignment_tag
def get_current_jet_version():
return VERSION

0 comments on commit 893b951

Please sign in to comment.