]> git.parisson.com Git - django-postman.git/commitdiff
Added a template for the autocomplete of multiple recipients in version 1.2.x of...
authorPatrick Samson <pk.samson@gmail.com>
Mon, 3 Sep 2012 20:26:28 +0000 (22:26 +0200)
committerPatrick Samson <pk.samson@gmail.com>
Mon, 3 Sep 2012 20:26:28 +0000 (22:26 +0200)
docs/conf.py
docs/features.rst
postman/__init__.py
postman/templates/autocomplete_postman_multiple_as1-2.html [new file with mode: 0644]
postman/tests.py

index 49b157888edf6c0a5fe12afc59e773b5619a51e1..4cc6def479fbb7c76a8ce645f4545988865a9676 100644 (file)
@@ -45,9 +45,9 @@ copyright = u'2010, Patrick Samson'
 # built documents.\r
 #\r
 # The short X.Y version.\r
-version = '2.0'\r
+version = '2.1'\r
 # The full version, including alpha/beta/rc tags.\r
-release = '2.0.0'\r
+release = '2.1.0a1'\r
 \r
 # The language for content autogenerated by Sphinx. Refer to documentation\r
 # for a list of supported languages.\r
index 59904c1232c578c394f60ce20d9bde934612b578..4b4452714e9190b805568ee02acd159c0d671f5f 100644 (file)
@@ -233,7 +233,9 @@ In case of version 1.2.x of django-ajax-selects:
 \r
 .. _`jQuery UI demos`: http://jqueryui.com/demos/autocomplete/multiple-remote.html\r
 \r
-       The directory `postman/templates/` doesn't currently provide any examples for this version.\r
+       You can use the following working implementation example:\r
+\r
+       * :file:`postman/templates/autocomplete_postman_multiple_as1-2.html`\r
 \r
 Customization\r
 ~~~~~~~~~~~~~\r
index 13e72d9ce8b23982cde6197069ac40b06a4eccca..5f4cc3b0c115e28f6316f4b2db2aca0f1747e194 100644 (file)
@@ -1,8 +1,8 @@
 """A messaging application for Django"""
 
 # following PEP 386: N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]
-VERSION = (2, 0, 0)
-PREREL = ()
+VERSION = (2, 1, 0)
+PREREL = ('a', 1)
 POST = 0
 DEV = 0
 
diff --git a/postman/templates/autocomplete_postman_multiple_as1-2.html b/postman/templates/autocomplete_postman_multiple_as1-2.html
new file mode 100644 (file)
index 0000000..7557acc
--- /dev/null
@@ -0,0 +1,59 @@
+{% extends "autocomplete.html" %}{% comment %}
+This is a custom template for django-ajax-selects version 1.2+ (not for 1.1.4/5).
+Channel:               postman_multiple_as1-2
+Form Field:            AutoCompleteField
+Usage:                 Entering of multiple values.
+
+There is no such template provided in the django-ajax-selects application.
+
+{% endcomment %}
+{% block script %}
+       addAutoComplete("{{html_id}}", function(html_id) {
+               function split(val) {
+                       return val.split(/,\s*/);
+               }
+               function extractLast(term) {
+                       return split(term).pop();
+               }
+
+               $("#"+html_id)
+               // don't navigate away from the field on tab when selecting an item
+               .bind("keydown", function(event) {
+                       if (event.keyCode === $.ui.keyCode.TAB &&
+                                       $(this).data("autocomplete").menu.active) {
+                               event.preventDefault();
+                       }
+               })
+               .autocomplete({
+                       source: function(request, response) {
+                               $.getJSON("{{lookup_url}}", {
+                                       term: extractLast(request.term)
+                               }, response);
+                       },
+                       search: function() {
+                               // custom minLength
+                               var term = extractLast(this.value);
+                               if (term.length < {{min_length}}) {
+                                       return false;
+                               }
+                       },
+                       focus: function() {
+                               // prevent value inserted on focus
+                               return false;
+                       },
+                       select: function(event, ui) {
+                               var terms = split(this.value);
+                               // remove the current input
+                               terms.pop();
+                               // add the selected item
+                               terms.push(ui.item.value);
+                               // add placeholder to get the comma-and-space at the end
+                               terms.push("");
+                               this.value = terms.join(", ");
+                               $(this).trigger("added");
+                               return false;
+                       }
+               }).autocompletehtml();
+       });
+{% block extra_script %}{% endblock %}
+{% endblock %}
\ No newline at end of file
index 64f4fa3a45b7d9fa9dfb4b31edbcd36b46c338a3..400da375357d67f64b919a92df08704f74c8c0fe 100644 (file)
@@ -76,7 +76,7 @@ class GenericTest(TestCase):
     Usual generic tests.
     """
     def test_version(self):
-        self.assertEqual(sys.modules['postman'].__version__, "2.0.0")
+        self.assertEqual(sys.modules['postman'].__version__, "2.1.0a1")
 
 class BaseTest(TestCase):
     """