Permalink
Browse files

Merge branch 'master' of https://github.com/django/django

  • Loading branch information...
2 parents fbb7389 + 840ffd8 commit eee791e9b216333ad0b4c6c441a88828bf9aee62 @bohyn bohyn committed Jun 5, 2012
Showing with 3,275 additions and 2,324 deletions.
  1. +3 −2 AUTHORS
  2. +11 −11 django/contrib/admin/static/admin/js/actions.js
  3. +6 −7 django/contrib/admin/static/admin/js/actions.min.js
  4. +13 −13 django/contrib/admin/static/admin/js/inlines.js
  5. +5 −5 django/contrib/admin/static/admin/js/inlines.min.js
  6. +6 −2 django/contrib/admin/templates/admin/index.html
  7. +1 −0 django/contrib/admin/views/main.py
  8. +7 −7 django/contrib/auth/management/commands/createsuperuser.py
  9. +4 −9 django/contrib/auth/tests/management.py
  10. +11 −0 django/contrib/flatpages/fixtures/example_site.json
  11. +2 −1 django/contrib/flatpages/tests/csrf.py
  12. +4 −1 django/contrib/flatpages/tests/forms.py
  13. +7 −5 django/contrib/flatpages/tests/middleware.py
  14. +1 −0 django/contrib/flatpages/tests/templatetags.py
  15. +5 −3 django/contrib/flatpages/tests/views.py
  16. +27 −30 django/contrib/formtools/tests/__init__.py
  17. +8 −6 django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
  18. +6 −6 django/contrib/formtools/tests/wizard/wizardtests/tests.py
  19. +2 −4 django/contrib/formtools/utils.py
  20. +8 −0 django/contrib/gis/admin/options.py
  21. +2 −2 django/contrib/gis/gdal/base.py
  22. +3 −1 django/contrib/gis/gdal/tests/__init__.py
  23. +3 −1 django/contrib/gis/geoip/__init__.py
  24. +2 −2 django/contrib/gis/geos/base.py
  25. +20 −9 django/contrib/gis/geos/mutable_list.py
  26. +3 −1 django/contrib/gis/geos/tests/__init__.py
  27. +65 −60 django/contrib/gis/geos/tests/test_geos.py
  28. +9 −3 django/contrib/gis/maps/google/overlays.py
  29. +20 −4 django/contrib/gis/measure.py
  30. +1 −1 django/contrib/gis/templates/gis/admin/openlayers.js
  31. +19 −0 django/contrib/gis/tests/geoadmin/tests.py
  32. +1 −0 django/contrib/gis/tests/layermap/models.py
  33. +34 −31 django/contrib/gis/tests/layermap/tests.py
  34. +1 −1 django/contrib/gis/utils/layermapping.py
  35. +1 −1 django/contrib/humanize/tests.py
  36. +1 −1 django/contrib/localflavor/es/es_provinces.py
  37. +2 −1 django/contrib/messages/tests/base.py
  38. +0 −10 django/contrib/sitemaps/tests/base.py
  39. +11 −2 django/contrib/sitemaps/tests/http.py
  40. +2 −5 django/contrib/staticfiles/management/commands/collectstatic.py
  41. +2 −4 django/contrib/staticfiles/management/commands/findstatic.py
  42. +16 −7 django/contrib/staticfiles/storage.py
  43. +1 −1 django/core/context_processors.py
  44. +1 −0 django/core/exceptions.py
  45. +3 −2 django/core/files/base.py
  46. +2 −2 django/core/files/uploadedfile.py
  47. +5 −5 django/core/handlers/wsgi.py
  48. +46 −32 django/core/management/base.py
  49. +1 −1 django/core/management/commands/compilemessages.py
  50. +7 −8 django/core/management/commands/createcachetable.py
  51. +16 −12 django/core/management/commands/dumpdata.py
  52. +5 −0 django/core/management/commands/inspectdb.py
  53. +18 −18 django/core/management/commands/loaddata.py
  54. +2 −2 django/core/management/commands/runserver.py
  55. +2 −4 django/core/management/templates.py
  56. +3 −0 django/core/serializers/base.py
  57. +27 −2 django/core/serializers/json.py
  58. +8 −5 django/core/serializers/python.py
  59. +12 −14 django/core/servers/basehttp.py
  60. +2 −4 django/core/urlresolvers.py
  61. +10 −5 django/db/backends/__init__.py
  62. +11 −2 django/db/backends/mysql/base.py
  63. +1 −0 django/db/backends/oracle/base.py
  64. +9 −9 django/db/backends/sqlite3/base.py
  65. +3 −9 django/db/models/base.py
  66. +10 −15 django/db/models/fields/__init__.py
  67. +21 −0 django/db/models/fields/files.py
  68. +40 −23 django/db/models/fields/related.py
  69. +13 −8 django/db/models/query.py
  70. +32 −17 django/db/models/query_utils.py
  71. +12 −2 django/db/models/sql/compiler.py
  72. +2 −1 django/db/models/sql/where.py
  73. +5 −5 django/dispatch/saferef.py
  74. +5 −1 django/forms/fields.py
  75. +2 −2 django/forms/models.py
  76. +3 −3 django/http/__init__.py
  77. +19 −19 django/http/multipartparser.py
  78. +1 −1 django/template/loaders/app_directories.py
  79. +1 −1 django/template/loaders/filesystem.py
  80. +1 −1 django/templatetags/i18n.py
  81. +32 −38 django/test/client.py
  82. +2 −2 django/utils/cache.py
  83. +5 −4 django/utils/crypto.py
  84. +4 −5 django/utils/encoding.py
  85. +15 −8 django/utils/functional.py
  86. +1 −1 django/utils/html.py
  87. +15 −4 django/views/debug.py
  88. +6 −6 django/views/decorators/debug.py
  89. +10 −2 django/views/generic/base.py
  90. +168 −77 django/views/generic/dates.py
  91. +2 −3 django/views/generic/detail.py
  92. +16 −7 django/views/generic/list.py
  93. +8 −4 docs/howto/custom-management-commands.txt
  94. BIN docs/intro/_images/admin10.png
  95. BIN docs/intro/_images/admin11.png
  96. BIN docs/intro/_images/admin11t.png
  97. BIN docs/intro/_images/admin12.png
  98. +28 −17 docs/intro/tutorial01.txt
  99. +6 −6 docs/intro/tutorial02.txt
  100. +2 −2 docs/intro/tutorial03.txt
  101. +2 −2 docs/intro/tutorial04.txt
  102. +17 −1 docs/ref/class-based-views.txt
  103. +1 −0 docs/ref/contrib/formtools/form-wizard.txt
  104. +1 −1 docs/ref/contrib/gis/geoquerysets.txt
  105. +9 −0 docs/ref/contrib/staticfiles.txt
  106. +1 −1 docs/ref/files/file.txt
  107. +3 −2 docs/ref/settings.txt
  108. +4 −3 docs/ref/templates/api.txt
  109. +2 −2 docs/ref/unicode.txt
  110. +60 −1 docs/releases/1.5.txt
  111. +0 −3 docs/topics/class-based-views.txt
  112. +2 −0 docs/topics/forms/formsets.txt
  113. +1 −1 docs/topics/forms/index.txt
  114. +1 −1 docs/topics/i18n/timezones.txt
  115. +86 −52 docs/topics/install.txt
  116. +10 −13 docs/topics/security.txt
  117. +11 −2 docs/topics/settings.txt
  118. +34 −23 docs/topics/testing.txt
  119. +36 −0 setup.py
  120. +15 −0 tests/modeltests/defer/tests.py
  121. +4 −0 tests/modeltests/field_subclassing/tests.py
  122. +12 −1 tests/modeltests/files/tests.py
  123. +15 −15 tests/modeltests/fixtures/tests.py
  124. 0 tests/modeltests/known_related_objects/__init__.py
  125. +65 −0 tests/modeltests/known_related_objects/fixtures/tournament.json
  126. +19 −0 tests/modeltests/known_related_objects/models.py
  127. +88 −0 tests/modeltests/known_related_objects/tests.py
  128. +7 −7 tests/modeltests/model_forms/tests.py
  129. +18 −0 tests/modeltests/model_inheritance/tests.py
  130. +9 −9 tests/modeltests/serializers/tests.py
  131. +4 −4 tests/modeltests/str/tests.py
  132. +1 −4 tests/modeltests/update_only_fields/tests.py
  133. +5 −3 tests/modeltests/user_commands/management/commands/dance.py
  134. +19 −2 tests/modeltests/user_commands/tests.py
  135. +52 −104 tests/modeltests/validation/test_error_messages.py
  136. +7 −4 tests/regressiontests/admin_scripts/tests.py
  137. +1 −1 tests/regressiontests/admin_util/tests.py
  138. +1 −1 tests/regressiontests/admin_widgets/tests.py
  139. +12 −0 tests/regressiontests/backends/tests.py
  140. +8 −4 tests/regressiontests/cache/tests.py
  141. +2 −2 tests/regressiontests/conditional_processing/models.py
  142. +1 −1 tests/regressiontests/csrf_tests/tests.py
  143. +27 −27 tests/regressiontests/file_storage/tests.py
  144. +16 −16 tests/regressiontests/file_uploads/tests.py
  145. +0 −19 tests/regressiontests/fixtures_regress/tests.py
  146. +29 −30 tests/regressiontests/forms/tests/fields.py
  147. 0 tests/regressiontests/forms/tests/filepath_test_files/.dot-file
  148. 0 tests/regressiontests/forms/tests/filepath_test_files/directory/.keep
  149. 0 tests/regressiontests/forms/tests/filepath_test_files/fake-image.jpg
  150. 0 tests/regressiontests/forms/tests/filepath_test_files/real-text-file.txt
  151. +3 −3 tests/regressiontests/forms/tests/forms.py
  152. +3 −3 tests/regressiontests/forms/tests/models.py
  153. +3 −2 tests/regressiontests/forms/tests/regressions.py
  154. +1 −1 tests/regressiontests/forms/tests/widgets.py
  155. +52 −0 tests/regressiontests/generic_views/base.py
  156. +28 −3 tests/regressiontests/generic_views/dates.py
  157. +10 −0 tests/regressiontests/generic_views/list.py
  158. +1 −1 tests/regressiontests/generic_views/templates/generic_views/book_archive.html
  159. +1 −1 tests/regressiontests/generic_views/templates/generic_views/book_archive_year.html
  160. +9 −0 tests/regressiontests/generic_views/urls.py
  161. +1 −1 tests/regressiontests/handlers/tests.py
  162. +5 −5 tests/regressiontests/httpwrappers/tests.py
  163. +6 −17 tests/regressiontests/i18n/commands/compilation.py
  164. BIN tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.mo
  165. +6 −0 tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.po
  166. +16 −2 tests/regressiontests/i18n/tests.py
  167. +24 −2 tests/regressiontests/inspectdb/tests.py
  168. +1 −1 tests/regressiontests/localflavor/es/tests.py
  169. +1 −1 tests/regressiontests/localflavor/mk/tests.py
  170. +25 −25 tests/regressiontests/mail/tests.py
  171. +13 −1 tests/regressiontests/model_fields/tests.py
  172. +3 −3 tests/regressiontests/model_forms_regress/tests.py
  173. +1 −1 tests/regressiontests/queries/models.py
  174. +57 −2 tests/regressiontests/queries/tests.py
  175. +44 −44 tests/regressiontests/requests/tests.py
  176. +3 −3 tests/regressiontests/servers/tests.py
  177. +3 −3 tests/regressiontests/signing/tests.py
  178. +7 −0 tests/regressiontests/staticfiles_tests/storage.py
  179. +76 −46 tests/regressiontests/staticfiles_tests/tests.py
  180. +1 −1 tests/regressiontests/string_lookup/tests.py
  181. +7 −7 tests/regressiontests/templates/tests.py
  182. +6 −6 tests/regressiontests/templates/unicode.py
  183. +0 −1,034 tests/regressiontests/test_client_regress/models.py
  184. +1,006 −0 tests/regressiontests/test_client_regress/tests.py
  185. +2 −3 tests/regressiontests/test_client_regress/views.py
  186. +3 −8 tests/regressiontests/test_runner/tests.py
  187. +3 −3 tests/regressiontests/views/__init__.py
  188. +63 −41 tests/regressiontests/views/tests/debug.py
  189. +5 −5 tests/regressiontests/views/tests/static.py
  190. +21 −2 tests/regressiontests/views/views.py
View
@@ -93,7 +93,7 @@ answer newbie questions, and generally made Django that much better:
Simon Blanchard
David Blewett <david@dawninglight.net>
Matt Boersma <matt@sprout.org>
- boobsd@gmail.com
+ Artem Gnilov <boobsd@gmail.com>
Matías Bordese
Nate Bragg <jonathan.bragg@alum.rpi.edu>
Sean Brant
@@ -211,7 +211,6 @@ answer newbie questions, and generally made Django that much better:
Dimitris Glezos <dimitris@glezos.com>
glin@seznam.cz
martin.glueck@gmail.com
- Artyom Gnilov <boobsd@gmail.com>
Ben Godfrey <http://aftnn.org>
GomoX <gomo@datafull.com>
Guilherme Mesquita Gondim <semente@taurinus.org>
@@ -347,6 +346,7 @@ answer newbie questions, and generally made Django that much better:
Frantisek Malina <vizualbod@vizualbod.com>
Mike Malone <mjmalone@gmail.com>
Martin Maney <http://www.chipy.org/Martin_Maney>
+ Michael Manfre <mmanfre@gmail.com>
masonsimon+django@gmail.com
Manuzhai
Petr Marhoun <petr.marhoun@gmail.com>
@@ -401,6 +401,7 @@ answer newbie questions, and generally made Django that much better:
Christian Oudard <christian.oudard@gmail.com>
oggie rob <oz.robharvey@gmail.com>
oggy <ognjen.maric@gmail.com>
+ Jens Page
Jay Parlar <parlar@gmail.com>
Carlos Eduardo de Paula <carlosedp@gmail.com>
John Paulett <john@paulett.org>
@@ -3,15 +3,15 @@
var options = $.extend({}, $.fn.actions.defaults, opts);
var actionCheckboxes = $(this);
var list_editable_changed = false;
- checker = function(checked) {
+ var checker = function(checked) {
if (checked) {
showQuestion();
} else {
reset();
}
$(actionCheckboxes).attr("checked", checked)
.parent().parent().toggleClass(options.selectedClass, checked);
- }
+ },
updateCounter = function() {
var sel = $(actionCheckboxes).filter(":checked").length;
$(options.counterContainer).html(interpolate(
@@ -29,30 +29,30 @@
}
return value;
});
- }
+ },
showQuestion = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).show();
$(options.allContainer).hide();
- }
+ },
showClear = function() {
$(options.acrossClears).show();
$(options.acrossQuestions).hide();
$(options.actionContainer).toggleClass(options.selectedClass);
$(options.allContainer).show();
$(options.counterContainer).hide();
- }
+ },
reset = function() {
$(options.acrossClears).hide();
$(options.acrossQuestions).hide();
$(options.allContainer).hide();
$(options.counterContainer).show();
- }
+ },
clearAcross = function() {
reset();
$(options.acrossInput).val(0);
$(options.actionContainer).removeClass(options.selectedClass);
- }
+ };
// Show counter by default
$(options.counterContainer).show();
// Check state of checkboxes and reinit state if needed
@@ -81,9 +81,9 @@
});
lastChecked = null;
$(actionCheckboxes).click(function(event) {
- if (!event) { var event = window.event; }
+ if (!event) { event = window.event; }
var target = event.target ? event.target : event.srcElement;
- if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey == true) {
+ if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey === true) {
var inrange = false;
$(lastChecked).attr("checked", target.checked)
.parent().parent().toggleClass(options.selectedClass, target.checked);
@@ -124,7 +124,7 @@
}
}
});
- }
+ };
/* Setup plugin defaults */
$.fn.actions.defaults = {
actionContainer: "div.actions",
@@ -135,5 +135,5 @@
acrossClears: "div.actions span.clear",
allToggle: "#action-toggle",
selectedClass: "selected"
- }
+ };
})(django.jQuery);
@@ -1,7 +1,6 @@
-(function(a){a.fn.actions=function(g){var b=a.extend({},a.fn.actions.defaults,g),f=a(this),e=!1;checker=function(c){c?showQuestion():reset();a(f).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)};updateCounter=function(){var c=a(f).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},!0));a(b.allToggle).attr("checked",function(){c==f.length?(value=!0,showQuestion()):(value=
-!1,clearAcross());return value})};showQuestion=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()};showClear=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()};reset=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()};clearAcross=function(){reset();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};
-a(b.counterContainer).show();a(this).filter(":checked").each(function(){a(this).parent().parent().toggleClass(b.selectedClass);updateCounter();1==a(b.acrossInput).val()&&showClear()});a(b.allToggle).show().click(function(){checker(a(this).attr("checked"));updateCounter()});a("div.actions span.question a").click(function(c){c.preventDefault();a(b.acrossInput).val(1);showClear()});a("div.actions span.clear a").click(function(c){c.preventDefault();a(b.allToggle).attr("checked",!1);clearAcross();checker(0);
-updateCounter()});lastChecked=null;a(f).click(function(c){if(!c)c=window.event;var d=c.target?c.target:c.srcElement;if(lastChecked&&a.data(lastChecked)!=a.data(d)&&!0==c.shiftKey){var e=!1;a(lastChecked).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(f).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))e=e?!1:!0;e&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,
-d.checked);lastChecked=d;updateCounter()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){e=!0});a('form#changelist-form button[name="index"]').click(function(){if(e)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').click(function(){var b=!1;a("div.actions select option:selected").each(function(){a(this).val()&&(b=!0)});
-if(b)return e?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",
-acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery);
+(function(a){a.fn.actions=function(m){var b=a.extend({},a.fn.actions.defaults,m),f=a(this),e=!1,j=function(c){c?h():i();a(f).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)},g=function(){var c=a(f).filter(":checked").length;a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},!0));a(b.allToggle).attr("checked",function(){c==f.length?(value=!0,h()):(value=!1,k());return value})},h=function(){a(b.acrossClears).hide();
+a(b.acrossQuestions).show();a(b.allContainer).hide()},l=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},i=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},k=function(){i();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};a(b.counterContainer).show();a(this).filter(":checked").each(function(){a(this).parent().parent().toggleClass(b.selectedClass);
+g();1==a(b.acrossInput).val()&&l()});a(b.allToggle).show().click(function(){j(a(this).attr("checked"));g()});a("div.actions span.question a").click(function(c){c.preventDefault();a(b.acrossInput).val(1);l()});a("div.actions span.clear a").click(function(c){c.preventDefault();a(b.allToggle).attr("checked",!1);k();j(0);g()});lastChecked=null;a(f).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(lastChecked&&a.data(lastChecked)!=a.data(d)&&!0===c.shiftKey){var e=!1;a(lastChecked).attr("checked",
+d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(f).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))e=e?false:true;e&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);lastChecked=d;g()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){e=!0});a('form#changelist-form button[name="index"]').click(function(){if(e)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});
+a('form#changelist-form input[name="_save"]').click(function(){var b=!1;a("div.actions select option:selected").each(function(){a(this).val()&&(b=!0)});if(b)return e?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};
+a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(django.jQuery);
@@ -31,11 +31,11 @@
}
};
var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").attr("autocomplete", "off");
- var nextIndex = parseInt(totalForms.val());
+ var nextIndex = parseInt(totalForms.val(), 10);
var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").attr("autocomplete", "off");
// only show the add button if we are allowed to add more items,
// note that max_num = None translates to a blank string.
- var showAddButton = maxForms.val() == '' || (maxForms.val()-totalForms.val()) > 0;
+ var showAddButton = maxForms.val() === '' || (maxForms.val()-totalForms.val()) > 0;
$(this).each(function(i) {
$(this).not("." + options.emptyCssClass).addClass(options.formCssClass);
});
@@ -52,13 +52,14 @@
$(this).filter(":last").after('<div class="' + options.addCssClass + '"><a href="javascript:void(0)">' + options.addText + "</a></div>");
addButton = $(this).filter(":last").next().find("a");
}
- addButton.click(function() {
+ addButton.click(function(e) {
+ e.preventDefault();
var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS");
var template = $("#" + options.prefix + "-empty");
var row = template.clone(true);
row.removeClass(options.emptyCssClass)
- .addClass(options.formCssClass)
- .attr("id", options.prefix + "-" + nextIndex);
+ .addClass(options.formCssClass)
+ .attr("id", options.prefix + "-" + nextIndex);
if (row.is("tr")) {
// If the forms are laid out in table rows, insert
// the remove button into the last table cell:
@@ -78,14 +79,15 @@
// Insert the new form when it has been fully edited
row.insertBefore($(template));
// Update number of total forms
- $(totalForms).val(parseInt(totalForms.val()) + 1);
+ $(totalForms).val(parseInt(totalForms.val(), 10) + 1);
nextIndex += 1;
// Hide add button in case we've hit the max, except we want to add infinitely
- if ((maxForms.val() != '') && (maxForms.val()-totalForms.val()) <= 0) {
+ if ((maxForms.val() !== '') && (maxForms.val()-totalForms.val()) <= 0) {
addButton.parent().hide();
}
// The delete button of each row triggers a bunch of other things
- row.find("a." + options.deleteCssClass).click(function() {
+ row.find("a." + options.deleteCssClass).click(function(e) {
+ e.preventDefault();
// Remove the parent form containing this button:
var row = $(this).parents("." + options.formCssClass);
row.remove();
@@ -98,7 +100,7 @@
var forms = $("." + options.formCssClass);
$("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length);
// Show add button again once we drop below max
- if ((maxForms.val() == '') || (maxForms.val()-forms.length) > 0) {
+ if ((maxForms.val() === '') || (maxForms.val()-forms.length) > 0) {
addButton.parent().show();
}
// Also, update names and ids for all remaining form controls
@@ -110,17 +112,15 @@
updateElementIndex(this, options.prefix, i);
});
}
- return false;
});
// If a post-add callback was supplied, call it with the added form:
if (options.added) {
options.added(row);
}
- return false;
});
}
return this;
- }
+ };
/* Setup plugin defaults */
$.fn.formset.defaults = {
prefix: "form", // The form prefix for your django formset
@@ -132,5 +132,5 @@
formCssClass: "dynamic-form", // CSS class applied to each form in a formset
added: null, // Function called each time a new form is added
removed: null // Function called each time a form is deleted
- }
+ };
})(django.jQuery);
@@ -1,5 +1,5 @@
-(function(b){b.fn.formset=function(c){var a=b.extend({},b.fn.formset.defaults,c),j=function(a,e,d){var i=RegExp("("+e+"-(\\d+|__prefix__))"),e=e+"-"+d;b(a).attr("for")&&b(a).attr("for",b(a).attr("for").replace(i,e));if(a.id)a.id=a.id.replace(i,e);if(a.name)a.name=a.name.replace(i,e)},c=b("#id_"+a.prefix+"-TOTAL_FORMS").attr("autocomplete","off"),g=parseInt(c.val()),f=b("#id_"+a.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off"),c=""==f.val()||0<f.val()-c.val();b(this).each(function(){b(this).not("."+
-a.emptyCssClass).addClass(a.formCssClass)});if(b(this).length&&c){var h;"TR"==b(this).attr("tagName")?(c=this.eq(0).children().length,b(this).parent().append('<tr class="'+a.addCssClass+'"><td colspan="'+c+'"><a href="javascript:void(0)">'+a.addText+"</a></tr>"),h=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('<div class="'+a.addCssClass+'"><a href="javascript:void(0)">'+a.addText+"</a></div>"),h=b(this).filter(":last").next().find("a"));h.click(function(){var c=b("#id_"+a.prefix+
-"-TOTAL_FORMS"),e=b("#"+a.prefix+"-empty"),d=e.clone(!0);d.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+g);d.is("tr")?d.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></div>"):d.is("ul")||d.is("ol")?d.append('<li><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></li>"):d.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+
-"</a></span>");d.find("*").each(function(){j(this,a.prefix,c.val())});d.insertBefore(b(e));b(c).val(parseInt(c.val())+1);g+=1;""!=f.val()&&0>=f.val()-c.val()&&h.parent().hide();d.find("a."+a.deleteCssClass).click(function(){var c=b(this).parents("."+a.formCssClass);c.remove();g-=1;a.removed&&a.removed(c);c=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(c.length);(""==f.val()||0<f.val()-c.length)&&h.parent().show();for(var d=0,e=c.length;d<e;d++)j(b(c).get(d),a.prefix,d),b(c.get(d)).find("*").each(function(){j(this,
-a.prefix,d)});return!1});a.added&&a.added(d);return!1})}return this};b.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);
+(function(b){b.fn.formset=function(c){var a=b.extend({},b.fn.formset.defaults,c),j=function(a,f,d){var e=RegExp("("+f+"-(\\d+|__prefix__))"),f=f+"-"+d;b(a).attr("for")&&b(a).attr("for",b(a).attr("for").replace(e,f));a.id&&(a.id=a.id.replace(e,f));a.name&&(a.name=a.name.replace(e,f))},c=b("#id_"+a.prefix+"-TOTAL_FORMS").attr("autocomplete","off"),h=parseInt(c.val(),10),g=b("#id_"+a.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off"),c=""===g.val()||0<g.val()-c.val();b(this).each(function(){b(this).not("."+
+a.emptyCssClass).addClass(a.formCssClass)});if(b(this).length&&c){var i;"TR"==b(this).attr("tagName")?(c=this.eq(0).children().length,b(this).parent().append('<tr class="'+a.addCssClass+'"><td colspan="'+c+'"><a href="javascript:void(0)">'+a.addText+"</a></tr>"),i=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('<div class="'+a.addCssClass+'"><a href="javascript:void(0)">'+a.addText+"</a></div>"),i=b(this).filter(":last").next().find("a"));i.click(function(c){c.preventDefault();
+var f=b("#id_"+a.prefix+"-TOTAL_FORMS"),c=b("#"+a.prefix+"-empty"),d=c.clone(true);d.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+h);d.is("tr")?d.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></div>"):d.is("ul")||d.is("ol")?d.append('<li><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></li>"):d.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+
+a.deleteText+"</a></span>");d.find("*").each(function(){j(this,a.prefix,f.val())});d.insertBefore(b(c));b(f).val(parseInt(f.val(),10)+1);h=h+1;g.val()!==""&&g.val()-f.val()<=0&&i.parent().hide();d.find("a."+a.deleteCssClass).click(function(e){e.preventDefault();e=b(this).parents("."+a.formCssClass);e.remove();h=h-1;a.removed&&a.removed(e);e=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(e.length);(g.val()===""||g.val()-e.length>0)&&i.parent().show();for(var c=0,d=e.length;c<d;c++){j(b(e).get(c),
+a.prefix,c);b(e.get(c)).find("*").each(function(){j(this,a.prefix,c)})}});a.added&&a.added(d)})}return this};b.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);
@@ -15,8 +15,12 @@
{% if app_list %}
{% for app in app_list %}
<div class="module">
- <table summary="{% blocktrans with name=app.name %}Models available in the {{ name }} application.{% endblocktrans %}">
- <caption><a href="{{ app.app_url }}" class="section">{% blocktrans with name=app.name %}{{ name }}{% endblocktrans %}</a></caption>
+ <table>
+ <caption>
+ <a href="{{ app.app_url }}" class="section" title="{% blocktrans with name=app.name %}Models in the {{ name }} application{% endblocktrans %}">
+ {% blocktrans with name=app.name %}{{ name }}{% endblocktrans %}
+ </a>
+ </caption>
{% for model in app.models %}
<tr>
{% if model.admin_url %}
@@ -1,4 +1,5 @@
import operator
+from functools import reduce
from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
from django.core.paginator import InvalidPage
Oops, something went wrong. Retry.

0 comments on commit eee791e

Please sign in to comment.