Kaynağa Gözat

Merge branch 'dev'

Denis K 9 yıl önce
ebeveyn
işleme
893b95150b

+ 2 - 0
CHANGELOG.rst

@@ -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

+ 16 - 3
docs/autocomplete.rst

@@ -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
 
@@ -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.

+ 1 - 1
jet/__init__.py

@@ -1 +1 @@
-VERSION = '0.1.1'
+VERSION = '0.1.2'

+ 37 - 0
jet/static/jet/vendor/jquery-ui/i18n/datepicker-zh-HANS.js

@@ -0,0 +1,37 @@
+/* Chinese initialisation for the jQuery UI date picker plugin. */
+/* Written by Cloudream (cloudream@gmail.com). */
+(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 - 0
jet/static/jet/vendor/select2/js/i18n/zh-HANS.js

@@ -0,0 +1,3 @@
+/*! Select2 4.0.0 | https://github.com/select2/select2/blob/master/LICENSE.md */
+
+(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/zh-CN",[],function(){return{errorLoading:function(){return"无法载入结果。"},inputTooLong:function(e){var t=e.input.length-e.maximum,n="请删除"+t+"个字符";return n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="请再输入至少"+t+"个字符";return n},loadingMore:function(){return"载入更多结果…"},maximumSelected:function(e){var t="最多只能选择"+e.maximum+"个项目";return t},noResults:function(){return"未找到结果"},searching:function(){return"搜索中…"}}}),{define:e.define,require:e.require}})();

+ 7 - 7
jet/templates/admin/base.html

@@ -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>
@@ -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 %}
@@ -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 %}">

+ 6 - 1
jet/templatetags/jet_tags.py

@@ -6,7 +6,7 @@ from django.forms import CheckboxInput, ModelChoiceField, Select, ModelMultipleC
 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
@@ -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