Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms-admin: Merged from trunk up to [5625]. This includes the Uni…

…code

merge, however, not all of admin/ (and none of admindocs/) has been ported and
checked yet.


git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5627 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1e747f98af99a23c5aff7b460d5b845c3a9e2013 1 parent 7ed1a91
@malcolmt malcolmt authored
Showing with 7,793 additions and 4,596 deletions.
  1. +10 −0 AUTHORS
  2. +1 −1  django/bin/make-messages.py
  3. +4 −0 django/conf/global_settings.py
  4. BIN  django/conf/locale/ca/LC_MESSAGES/django.mo
  5. +4 −4 django/conf/locale/ca/LC_MESSAGES/django.po
  6. BIN  django/conf/locale/es/LC_MESSAGES/django.mo
  7. +2,181 −1,503 django/conf/locale/es/LC_MESSAGES/django.po
  8. BIN  django/conf/locale/sl/LC_MESSAGES/django.mo
  9. +2,485 −1,447 django/conf/locale/sl/LC_MESSAGES/django.po
  10. BIN  django/conf/locale/sl/LC_MESSAGES/djangojs.mo
  11. +38 −29 django/conf/locale/sl/LC_MESSAGES/djangojs.po
  12. +8 −6 django/contrib/admin/filterspecs.py
  13. +101 −0 django/contrib/admin/media/js/urlify.js
  14. +5 −4 django/contrib/admin/models.py
  15. +12 −10 django/contrib/admin/options.py
  16. +3 −3 django/contrib/admin/sites.py
  17. +1 −1  django/contrib/admin/templates/admin/filter.html
  18. +18 −15 django/contrib/admin/templatetags/admin_list.py
  19. +4 −3 django/contrib/admin/templatetags/admin_modify.py
  20. +1 −0  django/contrib/admin/views/auth.py
  21. +2 −2 django/contrib/admin/views/decorators.py
  22. +26 −18 django/contrib/admin/views/main.py
  23. +1 −0  django/contrib/admin/widgets.py
  24. +1 −1  django/contrib/auth/forms.py
  25. +2 −2 django/contrib/auth/management.py
  26. +20 −15 django/contrib/auth/models.py
  27. +1 −0  django/contrib/auth/views.py
  28. +2 −2 django/contrib/comments/feeds.py
  29. +1 −1  django/contrib/comments/models.py
  30. +5 −4 django/contrib/comments/views/comments.py
  31. +1 −0  django/contrib/comments/views/karma.py
  32. +2 −2 django/contrib/contenttypes/generic.py
  33. +2 −1  django/contrib/contenttypes/management.py
  34. +7 −6 django/contrib/contenttypes/models.py
  35. +18 −14 django/contrib/databrowse/datastructures.py
  36. +5 −4 django/contrib/databrowse/plugins/calendars.py
  37. +7 −5 django/contrib/databrowse/plugins/fieldchoices.py
  38. +1 −1  django/contrib/databrowse/sites.py
  39. +1 −1  django/contrib/databrowse/templates/databrowse/fieldchoice_list.html
  40. +3 −3 django/contrib/flatpages/models.py
  41. +9 −9 django/contrib/humanize/templatetags/humanize.py
  42. +6 −6 django/contrib/localflavor/au/forms.py
  43. +10 −10 django/contrib/localflavor/br/forms.py
  44. +1 −1  django/contrib/localflavor/ch/ch_states.py
  45. +3 −3 django/contrib/localflavor/ch/forms.py
  46. +8 −7 django/contrib/localflavor/cl/forms.py
  47. +1 −1  django/contrib/localflavor/de/de_states.py
  48. +6 −6 django/contrib/localflavor/de/forms.py
  49. +6 −6 django/contrib/localflavor/fi/forms.py
  50. +4 −4 django/contrib/localflavor/fr/forms.py
  51. +5 −4 django/contrib/localflavor/is_/forms.py
  52. +7 −7 django/contrib/localflavor/it/forms.py
  53. +1 −1  django/contrib/localflavor/it/it_province.py
  54. +15 −11 django/contrib/localflavor/it/util.py
  55. +3 −3 django/contrib/localflavor/jp/forms.py
  56. +48 −48 django/contrib/localflavor/jp/jp_prefectures.py
  57. +6 −6 django/contrib/localflavor/no/forms.py
  58. +5 −5 django/contrib/localflavor/no/no_municipalities.py
  59. +2 −2 django/contrib/localflavor/uk/forms.py
  60. +10 −10 django/contrib/localflavor/us/forms.py
  61. +8 −7 django/contrib/markup/templatetags/markup.py
  62. +3 −2 django/contrib/redirects/models.py
  63. +1 −1  django/contrib/sessions/models.py
  64. +2 −1  django/contrib/sitemaps/views.py
  65. +2 −2 django/contrib/sites/models.py
  66. +8 −5 django/contrib/syndication/feeds.py
  67. +39 −7 django/contrib/webdesign/lorem_ipsum.py
  68. +1 −1  django/contrib/webdesign/templatetags/webdesign.py
  69. +2 −2 django/contrib/webdesign/tests.py
  70. +3 −3 django/core/handlers/modpython.py
  71. +5 −5 django/core/handlers/wsgi.py
  72. +36 −7 django/core/mail.py
  73. +3 −3 django/core/management.py
  74. +8 −8 django/core/serializers/__init__.py
  75. +3 −2 django/core/serializers/base.py
  76. +22 −27 django/core/serializers/python.py
  77. +2 −2 django/core/serializers/pyyaml.py
  78. +42 −40 django/core/serializers/xml_serializer.py
  79. +17 −10 django/core/urlresolvers.py
  80. +61 −58 django/core/validators.py
  81. +1 −1  django/db/backends/mysql/base.py
  82. +16 −2 django/db/backends/mysql_old/base.py
  83. +49 −15 django/db/backends/oracle/base.py
  84. +5 −5 django/db/backends/oracle/creation.py
  85. +35 −15 django/db/backends/postgresql/base.py
  86. +4 −0 django/db/backends/postgresql_psycopg2/base.py
  87. +6 −13 django/db/backends/sqlite3/base.py
  88. +13 −6 django/db/backends/util.py
  89. +6 −3 django/db/models/base.py
  90. +28 −27 django/db/models/fields/__init__.py
  91. +4 −3 django/db/models/fields/related.py
  92. +4 −2 django/db/models/manipulators.py
  93. +19 −3 django/db/models/options.py
  94. +2 −1  django/db/models/query.py
  95. +82 −16 django/http/__init__.py
  96. +36 −36 django/newforms/fields.py
  97. +8 −8 django/newforms/forms.py
  98. +8 −6 django/newforms/models.py
  99. +9 −9 django/newforms/util.py
  100. +20 −20 django/newforms/widgets.py
  101. +91 −81 django/oldforms/__init__.py
  102. +21 −20 django/template/__init__.py
  103. +67 −72 django/template/defaultfilters.py
  104. +4 −3 django/template/defaulttags.py
  105. +1 −1  django/template/loaders/app_directories.py
  106. +1 −1  django/template/loaders/eggs.py
  107. +1 −1  django/template/loaders/filesystem.py
  108. +4 −4 django/templatetags/i18n.py
  109. +18 −15 django/test/client.py
  110. +7 −7 django/test/testcases.py
  111. +2 −2 django/test/utils.py
  112. +2 −1  django/utils/cache.py
  113. +28 −26 django/utils/dateformat.py
  114. +5 −1 django/utils/dates.py
  115. +24 −1 django/utils/decorators.py
  116. +68 −16 django/utils/encoding.py
  117. +29 −21 django/utils/feedgenerator.py
  118. +54 −1 django/utils/functional.py
  119. +25 −16 django/utils/html.py
  120. +35 −0 django/utils/http.py
  121. +1 −1  django/utils/stopwords.py
  122. +34 −20 django/utils/text.py
  123. +10 −10 django/utils/timesince.py
  124. +18 −5 django/utils/translation/__init__.py
  125. +9 −2 django/utils/translation/trans_null.py
  126. +63 −32 django/utils/translation/trans_real.py
  127. +10 −3 django/utils/tzinfo.py
  128. +13 −1 django/views/debug.py
  129. +4 −4 django/views/generic/create_update.py
  130. +23 −22 docs/contributing.txt
  131. +3 −3 docs/db-api.txt
  132. +1 −1  docs/forms.txt
  133. +128 −48 docs/i18n.txt
  134. +40 −10 docs/model-api.txt
  135. +1 −1  docs/newforms.txt
  136. +2 −2 docs/overview.txt
  137. +19 −0 docs/settings.txt
  138. +10 −0 docs/templates.txt
  139. +3 −2 docs/templates_python.txt
  140. +24 −7 docs/tutorial01.txt
  141. +364 −0 docs/unicode.txt
  142. +9 −2 tests/modeltests/basic/models.py
  143. +3 −3 tests/modeltests/choices/models.py
  144. +9 −9 tests/modeltests/custom_columns/models.py
  145. +4 −4 tests/modeltests/custom_managers/models.py
  146. +1 −1  tests/modeltests/custom_methods/models.py
  147. +5 −5 tests/modeltests/custom_pk/models.py
  148. +1 −1  tests/modeltests/field_defaults/models.py
  149. +10 −10 tests/modeltests/fixtures/models.py
  150. +8 −8 tests/modeltests/generic_relations/models.py
  151. +2 −2 tests/modeltests/get_latest/models.py
  152. +2 −2 tests/modeltests/get_object_or_404/models.py
  153. +2 −2 tests/modeltests/get_or_create/models.py
  154. +16 −16 tests/modeltests/lookup/models.py
  155. +2 −2 tests/modeltests/m2m_and_m2o/models.py
  156. +5 −5 tests/modeltests/m2m_intermediary/models.py
  157. +2 −2 tests/modeltests/m2m_multiple/models.py
  158. +1 −1  tests/modeltests/m2m_recursive/models.py
  159. +1 −1  tests/modeltests/m2o_recursive/models.py
  160. +1 −1  tests/modeltests/m2o_recursive2/models.py
  161. +8 −8 tests/modeltests/manipulators/models.py
  162. +2 −2 tests/modeltests/many_to_many/models.py
  163. +10 −5 tests/modeltests/many_to_one/models.py
  164. +2 −2 tests/modeltests/many_to_one_null/models.py
  165. +8 −8 tests/modeltests/model_forms/models.py
  166. +6 −6 tests/modeltests/model_inheritance/models.py
  167. +6 −6 tests/modeltests/one_to_one/models.py
  168. +2 −2 tests/modeltests/or_lookups/models.py
  169. +1 −1  tests/modeltests/ordering/models.py
  170. +1 −1  tests/modeltests/pagination/models.py
  171. +1 −1  tests/modeltests/reserved_names/models.py
  172. +3 −3 tests/modeltests/reverse_lookup/models.py
  173. +2 −2 tests/modeltests/save_delete_hooks/models.py
  174. +8 −8 tests/modeltests/select_related/models.py
  175. +5 −5 tests/modeltests/serializers/models.py
  176. +29 −7 tests/modeltests/str/models.py
  177. +7 −3 tests/modeltests/test_client/models.py
  178. +1 −1  tests/modeltests/test_client/views.py
  179. +3 −3 tests/modeltests/transactions/models.py
  180. +7 −7 tests/modeltests/validation/models.py
  181. +23 −23 tests/regressiontests/dateformat/tests.py
  182. +230 −216 tests/regressiontests/defaultfilters/tests.py
  183. +3 −3 tests/regressiontests/fixtures_regress/models.py
  184. +7 −7 tests/regressiontests/forms/localflavor.py
  185. +44 −5 tests/regressiontests/forms/regressions.py
  186. +1 −1  tests/regressiontests/forms/tests.py
  187. +43 −33 tests/regressiontests/httpwrappers/tests.py
  188. +5 −5 tests/regressiontests/humanize/tests.py
  189. 0  tests/regressiontests/i18n/__init__.py
  190. 0  tests/regressiontests/i18n/models.py
  191. +33 −0 tests/regressiontests/i18n/tests.py
  192. 0  tests/regressiontests/model_regress/__init__.py
  193. +34 −0 tests/regressiontests/model_regress/models.py
  194. +4 −4 tests/regressiontests/null_queries/models.py
  195. +6 −6 tests/regressiontests/one_to_one_regress/models.py
  196. +3 −0  tests/regressiontests/serializers_regress/tests.py
  197. +27 −11 tests/regressiontests/string_lookup/models.py
  198. +14 −7 tests/regressiontests/templates/tests.py
  199. +33 −0 tests/regressiontests/templates/unicode.py
  200. +2 −0  tests/regressiontests/templates/urls.py
  201. +14 −4 tests/regressiontests/test_client_regress/models.py
  202. +1 −1  tests/regressiontests/test_client_regress/urls.py
  203. +13 −1 tests/regressiontests/test_client_regress/views.py
  204. +26 −5 tests/regressiontests/text/tests.py
  205. +1 −0  tests/runtests.py
View
10 AUTHORS
@@ -44,6 +44,7 @@ answer newbie questions, and generally made Django that much better:
alang@bright-green.com
Marty Alchin <gulopine@gamemusic.org>
Daniel Alves Barbosa de Oliveira Vaz <danielvaz@gmail.com>
+ AgarFu <heaven@croasanaso.sytes.net>
Andreas
andy@jadedplanet.net
Fabrice Aneche <akh@nobugware.com>
@@ -60,9 +61,11 @@ answer newbie questions, and generally made Django that much better:
Ben <afternoon@uk2.net>
Paul Bissex <http://e-scribe.com/>
Simon Blanchard
+ boobsd@gmail.com
Andrew Brehaut <http://brehaut.net/blog>
brut.alll@gmail.com
Jonathan Buchanan <jonathan.buchanan@gmail.com>
+ Ricardo Javier Cárdenes Medina <ricardo.cardenes@gmail.com>
Antonio Cavedoni <http://cavedoni.com/>
C8E
Chris Chamberlin <dja@cdc.msbx.net>
@@ -106,13 +109,16 @@ answer newbie questions, and generally made Django that much better:
Eric Floehr <eric@intellovations.com>
Jorge Gajon <gajon@gajon.org>
gandalf@owca.info
+ Marc Garcia <marc.garcia@accopensys.com>
Baishampayan Ghose
glin@seznam.cz
martin.glueck@gmail.com
GomoX <gomo@datafull.com>
+ Mario Gonzalez <gonzalemario @t gmail.com>
Simon Greenhill <dev@simon.net.nz>
Owen Griffiths
Espen Grindhaug <http://grindhaug.org/>
+ Thomas Güttler <hv@tbz-pariv.de>
Brian Harring <ferringb@gmail.com>
Brant Harris
Hawkeye
@@ -141,12 +147,15 @@ answer newbie questions, and generally made Django that much better:
Sune Kirkeby <http://ibofobi.dk/>
Bastian Kleineidam <calvin@debian.org>
Cameron Knight (ckknight)
+ Nena Kojadin <nena@kiberpipa.org>
+ Igor Kolar <ike@email.si>
Gasper Koren
Martin Kosír <martin@martinkosir.net>
Meir Kriheli <http://mksoft.co.il/>
Bruce Kroeze <http://coderseye.com/>
Joseph Kocherhans
konrad@gwu.edu
+ kurtiss@meetro.com
lakin.wecker@gmail.com
Nick Lane <nick.lane.au@gmail.com>
Stuart Langridge <http://www.kryogenix.org/>
@@ -214,6 +223,7 @@ answer newbie questions, and generally made Django that much better:
scott@staplefish.com
serbaut@gmail.com
Pete Shinners <pete@shinners.org>
+ Jozko Skrablin <jozko.skrablin@gmail.com>
SmileyChris <smileychris@gmail.com>
smurf@smurf.noris.de
sopel
View
2  django/bin/make-messages.py
@@ -103,7 +103,7 @@ def make_messages():
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
thefile = '%s.py' % file
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
- cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
+ cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
msgs = stdout.read()
View
4 django/conf/global_settings.py
@@ -97,6 +97,9 @@
DEFAULT_CONTENT_TYPE = 'text/html'
DEFAULT_CHARSET = 'utf-8'
+# Encoding of files read from disk (template and initial SQL files).
+FILE_CHARSET = 'utf-8'
+
# E-mail address that error messages come from.
SERVER_EMAIL = 'root@localhost'
@@ -280,6 +283,7 @@
# possible values.
CACHE_BACKEND = 'simple://'
CACHE_MIDDLEWARE_KEY_PREFIX = ''
+CACHE_MIDDLEWARE_SECONDS = 600
####################
# COMMENTS #
View
BIN  django/conf/locale/ca/LC_MESSAGES/django.mo
Binary file not shown
View
8 django/conf/locale/ca/LC_MESSAGES/django.po
@@ -237,7 +237,7 @@ msgstr "Coreà"
#: conf/global_settings.py:61
msgid "Kannada"
-msgstr ""
+msgstr "Canès"
#: conf/global_settings.py:62
msgid "Latvian"
@@ -1230,7 +1230,7 @@ msgstr "Pot editar-lo de nou abaix."
#: contrib/admin/views/auth.py:30
msgid "Add user"
-msgstr "Agregar usuari"
+msgstr "Afegir usuari"
#: contrib/admin/views/auth.py:57
msgid "Password changed successfully."
@@ -1248,12 +1248,12 @@ msgstr "Lloc administratiu"
#: contrib/admin/views/main.py:276 contrib/admin/views/main.py:361
#, python-format
msgid "You may add another %s below."
-msgstr "Pot agregar un altre %s abaix."
+msgstr "Pot afegir un altre %s a baix."
#: contrib/admin/views/main.py:294
#, python-format
msgid "Add %s"
-msgstr "Agregar %s"
+msgstr "Afegir %s"
#: contrib/admin/views/main.py:340
#, python-format
View
BIN  django/conf/locale/es/LC_MESSAGES/django.mo
Binary file not shown
View
3,684 django/conf/locale/es/LC_MESSAGES/django.po
2,181 additions, 1,503 deletions not shown
View
BIN  django/conf/locale/sl/LC_MESSAGES/django.mo
Binary file not shown
View
3,932 django/conf/locale/sl/LC_MESSAGES/django.po
2,485 additions, 1,447 deletions not shown
View
BIN  django/conf/locale/sl/LC_MESSAGES/djangojs.mo
Binary file not shown
View
67 django/conf/locale/sl/LC_MESSAGES/djangojs.po
@@ -5,8 +5,8 @@ msgid ""
msgstr ""
"Project-Id-Version: DJANGO-JS\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-12-09 11:51+0100\n"
-"PO-Revision-Date: 2007-03-31 21:29+0100\n"
+"POT-Creation-Date: 2007-07-02 13:55+0200\n"
+"PO-Revision-Date: 2007-07-02 13:56+0100\n"
"Last-Translator: Gasper Koren <skrat@owca.info>\n"
"Language-Team: SLOVENIAN <lugos-slo@lugos.si>\n"
"MIME-Version: 1.0\n"
@@ -15,6 +15,19 @@ msgstr ""
"X-Poedit-Language: Slovenian\n"
"X-Poedit-Country: SLOVENIA\n"
+#: contrib/admin/media/js/calendar.js:24
+#: contrib/admin/media/js/dateparse.js:32
+msgid "January February March April May June July August September October November December"
+msgstr "Januar Februar Marec April Maj Junij Julij Avgust September Oktober November December"
+
+#: contrib/admin/media/js/calendar.js:25
+msgid "S M T W T F S"
+msgstr "N P T S Č P S"
+
+#: contrib/admin/media/js/dateparse.js:33
+msgid "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
+msgstr "Nedelja Ponedeljek Torek Sreda Četrtek Petek Sobota"
+
#: contrib/admin/media/js/SelectFilter2.js:33
#, perl-format
msgid "Available %s"
@@ -45,63 +58,59 @@ msgstr "Izberite in kliknite"
msgid "Clear all"
msgstr "Izbriši vse"
-#: contrib/admin/media/js/dateparse.js:26
-#: contrib/admin/media/js/calendar.js:24
-msgid "January February March April May June July August September October November December"
-msgstr "Januar Februar Marec April Maj Junij Julij Avgust September Oktober November December"
-
-#: contrib/admin/media/js/dateparse.js:27
-msgid "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
-msgstr "Nedelja Ponedeljek Torek Sreda Četrtek Petek Sobota"
-
-#: contrib/admin/media/js/calendar.js:25
-msgid "S M T W T F S"
-msgstr "N P T S Č P S"
-
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:45
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:80
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:47
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:81
msgid "Now"
msgstr "Sedaj"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:48
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:51
msgid "Clock"
msgstr "URA"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:77
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:78
msgid "Choose a time"
msgstr "Izberite čas"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:81
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:82
msgid "Midnight"
msgstr "Polnoč"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:82
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:83
msgid "6 a.m."
msgstr "Ob 6h"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:83
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:84
msgid "Noon"
msgstr "Opoldne"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:87
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:168
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:88
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:183
msgid "Cancel"
msgstr "Prekliči"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:111
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:162
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:128
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:177
msgid "Today"
msgstr "Danes"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:114
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:132
msgid "Calendar"
msgstr "Koledar"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:160
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:175
msgid "Yesterday"
msgstr "Včeraj"
-#: contrib/admin/media/js/admin/DateTimeShortcuts.js:164
+#: contrib/admin/media/js/admin/DateTimeShortcuts.js:179
msgid "Tomorrow"
msgstr "Jutri"
+#: contrib/admin/media/js/admin/CollapsedFieldsets.js:34
+#: contrib/admin/media/js/admin/CollapsedFieldsets.js:72
+msgid "Show"
+msgstr "Prikaži"
+
+#: contrib/admin/media/js/admin/CollapsedFieldsets.js:63
+msgid "Hide"
+msgstr "Skrij"
+
View
14 django/contrib/admin/filterspecs.py
@@ -7,6 +7,8 @@
"""
from django.db import models
+from django.utils.encoding import smart_unicode, iri_to_uri
+from django.utils.translation import ugettext as _
import datetime
class FilterSpec(object):
@@ -37,12 +39,12 @@ def title(self):
def output(self, cl):
t = []
if self.has_output():
- t.append(_('<h3>By %s:</h3>\n<ul>\n') % self.title())
+ t.append(_(u'<h3>By %s:</h3>\n<ul>\n') % self.title())
for choice in self.choices(cl):
- t.append('<li%s><a href="%s">%s</a></li>\n' % \
+ t.append(u'<li%s><a href="%s">%s</a></li>\n' % \
((choice['selected'] and ' class="selected"' or ''),
- choice['query_string'] ,
+ iri_to_uri(choice['query_string']),
choice['display']))
t.append('</ul>\n\n')
return "".join(t)
@@ -70,7 +72,7 @@ def choices(self, cl):
'display': _('All')}
for val in self.lookup_choices:
pk_val = getattr(val, self.field.rel.to._meta.pk.attname)
- yield {'selected': self.lookup_val == str(pk_val),
+ yield {'selected': self.lookup_val == smart_unicode(pk_val),
'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}),
'display': val}
@@ -87,7 +89,7 @@ def choices(self, cl):
'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
'display': _('All')}
for k, v in self.field.choices:
- yield {'selected': str(k) == self.lookup_val,
+ yield {'selected': smart_unicode(k) == self.lookup_val,
'query_string': cl.get_query_string({self.lookup_kwarg: k}),
'display': v}
@@ -168,7 +170,7 @@ def choices(self, cl):
'query_string': cl.get_query_string({}, [self.field.name]),
'display': _('All')}
for val in self.lookup_choices:
- val = str(val[self.field.name])
+ val = smart_unicode(val[self.field.name])
yield {'selected': self.lookup_val == val,
'query_string': cl.get_query_string({self.field.name: val}),
'display': val}
View
101 django/contrib/admin/media/js/urlify.js
@@ -1,15 +1,116 @@
+var LATIN_MAP = {
+ 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'Ç':
+ 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I',
+ 'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö':
+ 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ý': 'Y', 'Þ': 'TH',
+ 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ':
+ 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i',
+ 'î': 'i', 'ï': 'i', 'ð': 'o', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ':
+ 'o', 'ö': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', 'ý': 'y',
+ 'þ': 'th', 'ÿ': 'y'
+}
+var LATIN_SYMBOLS_MAP = {
+ '©':'(c)'
+}
+var GREEK_MAP = {
+ 'α':'a', 'β':'b', 'γ':'g', 'δ':'d', 'ε':'e', 'ζ':'z', 'η':'h', 'θ':'8',
+ 'ι':'i', 'κ':'k', 'λ':'l', 'μ':'m', 'ν':'n', 'ξ':'3', 'ο':'o', 'π':'p',
+ 'ρ':'r', 'σ':'s', 'τ':'t', 'υ':'y', 'φ':'f', 'χ':'x', 'ψ':'ps', 'ω':'w',
+ 'ά':'a', 'έ':'e', 'ί':'i', 'ό':'o', 'ύ':'y', 'ή':'h', 'ώ':'w', 'ς':'s',
+ 'ϊ':'i', 'ΰ':'y', 'ϋ':'y', 'ΐ':'i',
+ 'Α':'A', 'Β':'B', 'Γ':'G', 'Δ':'D', 'Ε':'E', 'Ζ':'Z', 'Η':'H', 'Θ':'8',
+ 'Ι':'I', 'Κ':'K', 'Λ':'L', 'Μ':'M', 'Ν':'N', 'Ξ':'3', 'Ο':'O', 'Π':'P',
+ 'Ρ':'R', 'Σ':'S', 'Τ':'T', 'Υ':'Y', 'Φ':'F', 'Χ':'X', 'Ψ':'PS', 'Ω':'W',
+ 'Ά':'A', 'Έ':'E', 'Ί':'I', 'Ό':'O', 'Ύ':'Y', 'Ή':'H', 'Ώ':'W', 'Ϊ':'I',
+ 'Ϋ':'Y'
+}
+var TURKISH_MAP = {
+ 'ş':'s', 'Ş':'S', 'ı':'i', 'İ':'I', 'ç':'c', 'Ç':'C', 'ü':'u', 'Ü':'U',
+ 'ö':'o', 'Ö':'O', 'ğ':'g', 'Ğ':'G'
+}
+var RUSSIAN_MAP = {
+ 'а':'a', 'б':'b', 'в':'v', 'г':'g', 'д':'d', 'е':'e', 'ё':'yo', 'ж':'zh',
+ 'з':'z', 'и':'i', 'й':'j', 'к':'k', 'л':'l', 'м':'m', 'н':'n', 'о':'o',
+ 'п':'p', 'р':'r', 'с':'s', 'т':'t', 'у':'u', 'ф':'f', 'х':'h', 'ц':'c',
+ 'ч':'ch', 'ш':'sh', 'щ':'sh', 'ъ':'', 'ы':'y', 'ь':'', 'э':'e', 'ю':'yu',
+ 'я':'ya',
+ 'А':'A', 'Б':'B', 'В':'V', 'Г':'G', 'Д':'D', 'Е':'E', 'Ё':'Yo', 'Ж':'Zh',
+ 'З':'Z', 'И':'I', 'Й':'J', 'К':'K', 'Л':'L', 'М':'M', 'Н':'N', 'О':'O',
+ 'П':'P', 'Р':'R', 'С':'S', 'Т':'T', 'У':'U', 'Ф':'F', 'Х':'H', 'Ц':'C',
+ 'Ч':'Ch', 'Ш':'Sh', 'Щ':'Sh', 'Ъ':'', 'Ы':'Y', 'Ь':'', 'Э':'E', 'Ю':'Yu',
+ 'Я':'Ya'
+}
+
+var ALL_DOWNCODE_MAPS=new Array()
+ALL_DOWNCODE_MAPS[0]=LATIN_MAP
+ALL_DOWNCODE_MAPS[1]=LATIN_SYMBOLS_MAP
+ALL_DOWNCODE_MAPS[2]=GREEK_MAP
+ALL_DOWNCODE_MAPS[3]=TURKISH_MAP
+ALL_DOWNCODE_MAPS[4]=RUSSIAN_MAP
+
+var Downcoder = new Object();
+Downcoder.Initialize = function()
+{
+ if (Downcoder.map) // already made
+ return ;
+ Downcoder.map ={}
+ Downcoder.chars = '' ;
+ for(var i in ALL_DOWNCODE_MAPS)
+ {
+ var lookup = ALL_DOWNCODE_MAPS[i]
+ for (var c in lookup)
+ {
+ Downcoder.map[c] = lookup[c] ;
+ Downcoder.chars += c ;
+ }
+ }
+ Downcoder.regex = new RegExp('[' + Downcoder.chars + ']|[^' + Downcoder.chars + ']+','g') ;
+}
+
+downcode= function( slug )
+{
+ Downcoder.Initialize() ;
+ var downcoded =""
+ var pieces = slug.match(Downcoder.regex);
+ if(pieces)
+ {
+ for (var i = 0 ; i < pieces.length ; i++)
+ {
+ if (pieces[i].length == 1)
+ {
+ var mapped = Downcoder.map[pieces[i]] ;
+ if (mapped != null)
+ {
+ downcoded+=mapped;
+ continue ;
+ }
+ }
+ downcoded+=pieces[i];
+ }
+ }
+ else
+ {
+ downcoded = slug;
+ }
+ return downcoded;
+}
+
+
function URLify(s, num_chars) {
// changes, e.g., "Petty theft" to "petty_theft"
// remove all these words from the string before urlifying
+ s = downcode(s);
removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",
"is", "in", "into", "like", "of", "off", "on", "onto", "per",
"since", "than", "the", "this", "that", "to", "up", "via",
"with"];
r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi');
s = s.replace(r, '');
+ // if downcode doesn't hit, the char will be stripped here
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars);// trim to first num_chars chars
}
+
View
9 django/contrib/admin/models.py
@@ -1,7 +1,8 @@
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ugettext_lazy as _
+from django.utils.encoding import smart_unicode
ADDITION = 1
CHANGE = 2
@@ -9,7 +10,7 @@
class LogEntryManager(models.Manager):
def log_action(self, user_id, content_type_id, object_id, object_repr, action_flag, change_message=''):
- e = self.model(None, None, user_id, content_type_id, str(object_id), object_repr[:200], action_flag, change_message)
+ e = self.model(None, None, user_id, content_type_id, smart_unicode(object_id), object_repr[:200], action_flag, change_message)
e.save()
class LogEntry(models.Model):
@@ -28,7 +29,7 @@ class Meta:
ordering = ('-action_time',)
def __repr__(self):
- return str(self.action_time)
+ return smart_unicode(self.action_time)
def is_addition(self):
return self.action_flag == ADDITION
@@ -48,4 +49,4 @@ def get_admin_url(self):
Returns the admin URL to edit the object represented by this log entry.
This is relative to the Django admin index page.
"""
- return "%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id)
+ return u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, self.object_id)
View
22 django/contrib/admin/options.py
@@ -9,6 +9,8 @@
from django.shortcuts import get_object_or_404, render_to_response
from django.utils.html import escape
from django.utils.text import capfirst, get_text_list
+from django.utils.translation import ugettext as _
+from django.utils.encoding import force_unicode
import sets
class IncorrectLookupParameters(Exception):
@@ -50,7 +52,7 @@ def first_field(self):
class Fieldset(object):
def __init__(self, name=None, fields=(), classes=(), description=None):
self.name, self.fields = name, fields
- self.classes = ' '.join(classes)
+ self.classes = u' '.join(classes)
self.description = description
class BoundFieldset(object):
@@ -85,15 +87,15 @@ def __init__(self, form, field, is_first):
def label_tag(self):
classes = []
if self.is_checkbox:
- classes.append('vCheckboxLabel')
+ classes.append(u'vCheckboxLabel')
contents = escape(self.field.label)
else:
- contents = escape(self.field.label) + ':'
+ contents = escape(self.field.label) + u':'
if self.field.field.required:
- classes.append('required')
+ classes.append(u'required')
if not self.is_first:
- classes.append('inline')
- attrs = classes and {'class': ' '.join(classes)} or {}
+ classes.append(u'inline')
+ attrs = classes and {'class': u' '.join(classes)} or {}
return self.field.label_tag(contents=contents, attrs=attrs)
class BaseModelAdmin(object):
@@ -561,7 +563,7 @@ def delete_view(self, request, object_id):
# Populate deleted_objects, a data structure of all related objects that
# will also be deleted.
- deleted_objects = ['%s: <a href="../../%s/">%s</a>' % (capfirst(opts.verbose_name), object_id, escape(str(obj))), []]
+ deleted_objects = [u'%s: <a href="../../%s/">%s</a>' % (force_unicode(capfirst(opts.verbose_name)), object_id, escape(str(obj))), []]
perms_needed = sets.Set()
_get_deleted_objects(deleted_objects, perms_needed, request.user, obj, opts, 1)
@@ -571,7 +573,7 @@ def delete_view(self, request, object_id):
obj_display = str(obj)
obj.delete()
LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, object_id, obj_display, DELETION)
- request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': opts.verbose_name, 'obj': obj_display})
+ request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
return HttpResponseRedirect("../../")
extra_context = {
"title": _("Are you sure?"),
@@ -596,7 +598,7 @@ def history_view(self, request, object_id):
# If no history was found, see whether this object even exists.
obj = get_object_or_404(model, pk=object_id)
extra_context = {
- 'title': _('Change history: %s') % obj,
+ 'title': _('Change history: %s') % force_unicode(obj),
'action_list': action_list,
'module_name': capfirst(opts.verbose_name_plural),
'object': obj,
@@ -618,7 +620,7 @@ def get_inline_formsets(self):
class InlineModelAdmin(BaseModelAdmin):
"""
Options for inline editing of ``model`` instances.
-
+
Provide ``name`` to specify the attribute name of the ``ForeignKey`` from
``model`` to its parent. This is required if ``model`` has more than one
``ForeignKey`` to its parent.
View
6 django/contrib/admin/sites.py
@@ -4,13 +4,13 @@
from django.db.models import Model
from django.shortcuts import render_to_response
from django.utils.text import capfirst
-from django.utils.translation import gettext_lazy
+from django.utils.translation import ugettext_lazy, ugettext as _
import base64
import cPickle as pickle
import datetime
import md5
-ERROR_MESSAGE = gettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
+ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
class AlreadyRegistered(Exception):
@@ -199,7 +199,7 @@ def login(self, request):
user = authenticate(username=username, password=password)
if user is None:
message = ERROR_MESSAGE
- if '@' in username:
+ if u'@' in username:
# Mistakenly entered e-mail address instead of username? Look it up.
try:
user = User.objects.get(email=username)
View
2  django/contrib/admin/templates/admin/filter.html
@@ -3,6 +3,6 @@
<ul>
{% for choice in choices %}
<li{% if choice.selected %} class="selected"{% endif %}>
- <a href="{{ choice.query_string }}">{{ choice.display|escape }}</a></li>
+ <a href="{{ choice.query_string|iriencode }}">{{ choice.display|escape }}</a></li>
{% endfor %}
</ul>
View
33 django/contrib/admin/templatetags/admin_list.py
@@ -6,7 +6,8 @@
from django.utils import dateformat
from django.utils.html import escape
from django.utils.text import capfirst
-from django.utils.translation import get_date_formats, get_partial_date_formats
+from django.utils.translation import get_date_formats, get_partial_date_formats, ugettext as _
+from django.utils.encoding import smart_unicode, smart_str, force_unicode
from django.template import Library
import datetime
@@ -16,11 +17,11 @@
def paginator_number(cl,i):
if i == DOT:
- return '... '
+ return u'... '
elif i == cl.page_num:
- return '<span class="this-page">%d</span> ' % (i+1)
+ return u'<span class="this-page">%d</span> ' % (i+1)
else:
- return '<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
+ return u'<a href="%s"%s>%d</a> ' % (cl.get_query_string({PAGE_VAR: i}), (i == cl.paginator.pages-1 and ' class="end"' or ''), i+1)
paginator_number = register.simple_tag(paginator_number)
def pagination(cl):
@@ -75,10 +76,12 @@ def result_headers(cl):
admin_order_field = None
except models.FieldDoesNotExist:
# For non-field list_display values, check for the function
- # attribute "short_description". If that doesn't exist, fall
- # back to the method name. And __str__ is a special-case.
- if field_name == '__str__':
- header = lookup_opts.verbose_name
+ # attribute "short_description". If that doesn't exist, fall back
+ # to the method name. And __str__ and __unicode__ are special-cases.
+ if field_name == '__unicode__':
+ header = force_unicode(lookup_opts.verbose_name)
+ elif field_name == '__str__':
+ header = smart_str(lookup_opts.verbose_name)
else:
attr = getattr(cl.model, field_name) # Let AttributeErrors propagate.
try:
@@ -114,7 +117,7 @@ def result_headers(cl):
def _boolean_icon(field_val):
BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'}
- return '<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val)
+ return u'<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val)
def items_for_result(cl, result):
first = True
@@ -136,7 +139,7 @@ def items_for_result(cl, result):
allow_tags = True
result_repr = _boolean_icon(attr)
else:
- result_repr = str(attr)
+ result_repr = smart_unicode(attr)
except (AttributeError, ObjectDoesNotExist):
result_repr = EMPTY_CHANGELIST_VALUE
else:
@@ -179,19 +182,19 @@ def items_for_result(cl, result):
elif f.choices:
result_repr = dict(f.choices).get(field_val, EMPTY_CHANGELIST_VALUE)
else:
- result_repr = escape(str(field_val))
- if result_repr == '':
+ result_repr = escape(field_val)
+ if force_unicode(result_repr) == '':
result_repr = '&nbsp;'
# If list_display_links not defined, add the link tag to the first field
if (first and not cl.list_display_links) or field_name in cl.list_display_links:
table_tag = {True:'th', False:'td'}[first]
first = False
url = cl.url_for_result(result)
- result_id = str(getattr(result, pk)) # str() is needed in case of 23L (long ints)
- yield ('<%s%s><a href="%s"%s>%s</a></%s>' % \
+ result_id = smart_unicode(getattr(result, pk)) # conversion to string is needed in case of 23L (long ints)
+ yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \
(table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr, table_tag))
else:
- yield ('<td%s>%s</td>' % (row_class, result_repr))
+ yield (u'<td%s>%s</td>' % (row_class, result_repr))
def results(cl):
for res in cl.result_list:
View
7 django/contrib/admin/templatetags/admin_modify.py
@@ -2,6 +2,7 @@
from django.contrib.admin.views.main import AdminBoundField
from django.template import loader
from django.utils.text import capfirst
+from django.utils.encoding import force_unicode
from django.db import models
from django.db.models.fields import Field
from django.db.models.related import BoundRelatedObject
@@ -13,7 +14,7 @@
word_re = re.compile('[A-Z][a-z]+')
def class_name_to_underscored(name):
- return '_'.join([s.lower() for s in word_re.findall(name)[:-1]])
+ return u'_'.join([s.lower() for s in word_re.findall(name)[:-1]])
def submit_row(context):
opts = context['opts']
@@ -45,7 +46,7 @@ def get_nodelist(cls, klass):
if klass not in cls.nodelists:
try:
field_class_name = klass.__name__
- template_name = "widget/%s.html" % class_name_to_underscored(field_class_name)
+ template_name = u"widget/%s.html" % class_name_to_underscored(field_class_name)
nodelist = loader.get_template(template_name).nodelist
except template.TemplateDoesNotExist:
super_klass = bool(klass.__bases__) and klass.__bases__[0] or None
@@ -95,7 +96,7 @@ def __init__(self, field_mapping, fields, index):
self.index = index
def output_all(form_fields):
- return ''.join([str(f) for f in form_fields])
+ return u''.join([force_unicode(f) for f in form_fields])
output_all = register.simple_tag(output_all)
def field_widget(parser, token):
View
1  django/contrib/admin/views/auth.py
@@ -6,6 +6,7 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.html import escape
+from django.utils.translation import ugettext as _
def user_add_stage(request):
if not request.user.has_perm('auth.change_user'):
View
4 django/contrib/admin/views/decorators.py
@@ -3,11 +3,11 @@
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login
from django.shortcuts import render_to_response
-from django.utils.translation import gettext_lazy
+from django.utils.translation import ugettext_lazy, ugettext as _
import base64, datetime, md5
import cPickle as pickle
-ERROR_MESSAGE = gettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
+ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
LOGIN_FORM_KEY = 'this_is_the_login_form'
def _display_login_form(request, error_message=''):
View
44 django/contrib/admin/views/main.py
@@ -12,6 +12,8 @@
from django.http import Http404
from django.utils.html import escape
from django.utils.text import capfirst
+from django.utils.encoding import force_unicode, smart_str
+from django.utils.translation import ugettext as _
import operator
try:
@@ -77,11 +79,11 @@ def __init__(self, field, field_mapping, original):
classes = []
if self.raw_id_admin:
- classes.append('nowrap')
+ classes.append(u'nowrap')
if max([bool(f.errors()) for f in self.form_fields]):
- classes.append('error')
+ classes.append(u'error')
if classes:
- self.cell_class_attribute = ' class="%s" ' % ' '.join(classes)
+ self.cell_class_attribute = u' class="%s" ' % ' '.join(classes)
self._repr_filled = False
def original_value(self):
@@ -93,9 +95,9 @@ def existing_display(self):
return self._display
except AttributeError:
if isinstance(self.field.rel, models.ManyToOneRel):
- self._display = getattr(self.original, self.field.name)
+ self._display = force_unicode(getattr(self.original, self.field.name), strings_only=True)
elif isinstance(self.field.rel, models.ManyToManyRel):
- self._display = ", ".join([str(obj) for obj in getattr(self.original, self.field.name).all()])
+ self._display = u", ".join([force_unicode(obj) for obj in getattr(self.original, self.field.name).all()])
return self._display
def __repr__(self):
@@ -173,11 +175,11 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
if related.field.rel.edit_inline or not related.opts.admin:
# Don't display link to edit, because it either has no
# admin or is edited inline.
- nh(deleted_objects, current_depth, ['%s: %s' % (capfirst(related.opts.verbose_name), sub_obj), []])
+ nh(deleted_objects, current_depth, [u'%s: %s' % (force_unicode(capfirst(related.opts.verbose_name)), sub_obj), []])
else:
# Display a link to the admin page.
- nh(deleted_objects, current_depth, ['%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
- (capfirst(related.opts.verbose_name), related.opts.app_label, related.opts.object_name.lower(),
+ nh(deleted_objects, current_depth, [u'%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
+ (force_unicode(capfirst(related.opts.verbose_name)), related.opts.app_label, related.opts.object_name.lower(),
sub_obj._get_pk_val(), sub_obj), []])
_get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2)
else:
@@ -187,11 +189,11 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
if related.field.rel.edit_inline or not related.opts.admin:
# Don't display link to edit, because it either has no
# admin or is edited inline.
- nh(deleted_objects, current_depth, ['%s: %s' % (capfirst(related.opts.verbose_name), escape(str(sub_obj))), []])
+ nh(deleted_objects, current_depth, [u'%s: %s' % (force_unicode(capfirst(related.opts.verbose_name)), escape(sub_obj)), []])
else:
# Display a link to the admin page.
- nh(deleted_objects, current_depth, ['%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
- (capfirst(related.opts.verbose_name), related.opts.app_label, related.opts.object_name.lower(), sub_obj._get_pk_val(), escape(str(sub_obj))), []])
+ nh(deleted_objects, current_depth, [u'%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
+ (force_unicode(capfirst(related.opts.verbose_name)), related.opts.app_label, related.opts.object_name.lower(), sub_obj._get_pk_val(), escape(sub_obj)), []])
_get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2)
# If there were related objects, and the user doesn't have
# permission to delete them, add the missing perm to perms_needed.
@@ -218,17 +220,17 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
# Don't display link to edit, because it either has no
# admin or is edited inline.
nh(deleted_objects, current_depth, [_('One or more %(fieldname)s in %(name)s: %(obj)s') % \
- {'fieldname': related.field.verbose_name, 'name': related.opts.verbose_name, 'obj': escape(str(sub_obj))}, []])
+ {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name), 'obj': escape(sub_obj)}, []])
else:
# Display a link to the admin page.
nh(deleted_objects, current_depth, [
- (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': related.field.verbose_name, 'name':related.opts.verbose_name}) + \
- (' <a href="../../../../%s/%s/%s/">%s</a>' % \
- (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(str(sub_obj)))), []])
+ (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \
+ (u' <a href="../../../../%s/%s/%s/">%s</a>' % \
+ (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(sub_obj))), []])
# If there were related objects, and the user doesn't have
# permission to change them, add the missing perm to perms_needed.
if related.opts.admin and has_related_objs:
- p = '%s.%s' % (related.opts.app_label, related.opts.get_change_permission())
+ p = u'%s.%s' % (related.opts.app_label, related.opts.get_change_permission())
if not user.has_perm(p):
perms_needed.add(related.opts.verbose_name)
@@ -264,7 +266,7 @@ def __init__(self, request, model, list_display, list_display_links, list_filter
self.query = request.GET.get(SEARCH_VAR, '')
self.query_set = self.get_query_set()
self.get_results(request)
- self.title = (self.is_popup and _('Select %s') % self.opts.verbose_name or _('Select %s to change') % self.opts.verbose_name)
+ self.title = (self.is_popup and _('Select %s') % force_unicode(self.opts.verbose_name) or _('Select %s to change') % force_unicode(self.opts.verbose_name))
self.filter_specs, self.has_filters = self.get_filters(request)
self.pk_attname = self.lookup_opts.pk.attname
@@ -291,7 +293,7 @@ def get_query_string(self, new_params=None, remove=None):
del p[k]
elif v is not None:
p[k] = v
- return '?' + '&amp;'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
+ return '?' + '&amp;'.join([u'%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
def get_results(self, request):
paginator = ObjectPaginator(self.query_set, self.list_per_page)
@@ -377,6 +379,12 @@ def get_query_set(self):
for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):
if i in lookup_params:
del lookup_params[i]
+ for key, value in lookup_params.items():
+ if not isinstance(key, str):
+ # 'key' will be used as a keyword argument later, so Python
+ # requires it to be a string.
+ del lookup_params[key]
+ lookup_params[smart_str(key)] = value
# Apply lookup parameters from the query string.
qs = qs.filter(**lookup_params)
View
1  django/contrib/admin/widgets.py
@@ -4,6 +4,7 @@
from django import newforms as forms
from django.utils.text import capfirst
+from django.utils.translation import ugettext as _
class FilteredSelectMultiple(forms.SelectMultiple):
"""
View
2  django/contrib/auth/forms.py
@@ -4,7 +4,7 @@
from django.template import Context, loader
from django.core import validators
from django import oldforms
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
class UserCreationForm(oldforms.Manipulator):
"A form that creates a user, with no privileges, from the given username and password."
View
4 django/contrib/auth/management.py
@@ -7,13 +7,13 @@
from django.contrib.auth import models as auth_app
def _get_permission_codename(action, opts):
- return '%s_%s' % (action, opts.object_name.lower())
+ return u'%s_%s' % (action, opts.object_name.lower())
def _get_all_permissions(opts):
"Returns (codename, name) for all permissions in the given opts."
perms = []
for action in ('add', 'change', 'delete'):
- perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name)))
+ perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))
return perms + list(opts.permissions)
def create_permissions(app, created_models, verbosity):
View
35 django/contrib/auth/models.py
@@ -2,8 +2,10 @@
from django.core.exceptions import ImproperlyConfigured
from django.db import backend, connection, models
from django.contrib.contenttypes.models import ContentType
-from django.utils.translation import gettext_lazy as _
+from django.utils.encoding import smart_str
+from django.utils.translation import ugettext_lazy as _
import datetime
+import urllib
try:
set
@@ -18,16 +20,16 @@ def check_password(raw_password, enc_password):
algo, salt, hsh = enc_password.split('$')
if algo == 'md5':
import md5
- return hsh == md5.new(salt+raw_password).hexdigest()
+ return hsh == md5.new(smart_str(salt + raw_password)).hexdigest()
elif algo == 'sha1':
import sha
- return hsh == sha.new(salt+raw_password).hexdigest()
+ return hsh == sha.new(smart_str(salt + raw_password)).hexdigest()
elif algo == 'crypt':
try:
import crypt
except ImportError:
raise ValueError, "Crypt password algorithm not supported in this environment."
- return hsh == crypt.crypt(raw_password, salt)
+ return hsh == crypt.crypt(smart_str(raw_password), smart_str(salt))
raise ValueError, "Got unknown password algorithm type in password."
class SiteProfileNotAvailable(Exception):
@@ -56,8 +58,8 @@ class Meta:
unique_together = (('content_type', 'codename'),)
ordering = ('content_type', 'codename')
- def __str__(self):
- return "%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
+ def __unicode__(self):
+ return u"%s | %s | %s" % (self.content_type.app_label, self.content_type, self.name)
class Group(models.Model):
"""Groups are a generic way of categorizing users to apply permissions, or some other label, to those users. A user can belong to any number of groups.
@@ -74,7 +76,7 @@ class Meta:
verbose_name_plural = _('groups')
ordering = ('name',)
- def __str__(self):
+ def __unicode__(self):
return self.name
class UserManager(models.Manager):
@@ -118,11 +120,11 @@ class Meta:
verbose_name_plural = _('users')
ordering = ('username',)
- def __str__(self):
+ def __unicode__(self):
return self.username
def get_absolute_url(self):
- return "/users/%s/" % self.username
+ return "/users/%s/" % urllib.quote(smart_str(self.username))
def is_anonymous(self):
"Always returns False. This is a way of comparing User objects to anonymous users."
@@ -135,14 +137,14 @@ def is_authenticated(self):
def get_full_name(self):
"Returns the first_name plus the last_name, with a space in between."
- full_name = '%s %s' % (self.first_name, self.last_name)
+ full_name = u'%s %s' % (self.first_name, self.last_name)
return full_name.strip()
def set_password(self, raw_password):
import sha, random
algo = 'sha1'
salt = sha.new(str(random.random())).hexdigest()[:5]
- hsh = sha.new(salt+raw_password).hexdigest()
+ hsh = sha.new(salt + smart_str(raw_password)).hexdigest()
self.password = '%s$%s$%s' % (algo, salt, hsh)
def check_password(self, raw_password):
@@ -154,7 +156,7 @@ def check_password(self, raw_password):
# algorithm or salt.
if '$' not in self.password:
import md5
- is_correct = (self.password == md5.new(raw_password).hexdigest())
+ is_correct = (self.password == md5.new(smart_str(raw_password)).hexdigest())
if is_correct:
# Convert the password to the new, more secure format.
self.set_password(raw_password)
@@ -194,7 +196,7 @@ def get_group_permissions(self):
def get_all_permissions(self):
if not hasattr(self, '_perm_cache'):
- self._perm_cache = set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
+ self._perm_cache = set([u"%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
self._perm_cache.update(self.get_group_permissions())
return self._perm_cache
@@ -256,7 +258,7 @@ class Message(models.Model):
user = models.ForeignKey(User)
message = models.TextField(_('message'))
- def __str__(self):
+ def __unicode__(self):
return self.message
class AnonymousUser(object):
@@ -266,9 +268,12 @@ class AnonymousUser(object):
def __init__(self):
pass
- def __str__(self):
+ def __unicode__(self):
return 'AnonymousUser'
+ def __str__(self):
+ return unicode(self).encode('utf-8')
+
def __eq__(self, other):
return isinstance(other, self.__class__)
View
1  django/contrib/auth/views.py
@@ -7,6 +7,7 @@
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import REDIRECT_FIELD_NAME
+from django.utils.translation import ugettext as _
def login(request, template_name='registration/login.html'):
"Displays the login form and handles the login action."
View
4 django/contrib/comments/feeds.py
@@ -11,7 +11,7 @@ class LatestFreeCommentsFeed(Feed):
def title(self):
if not hasattr(self, '_site'):
self._site = Site.objects.get_current()
- return "%s comments" % self._site.name
+ return u"%s comments" % self._site.name
def link(self):
if not hasattr(self, '_site'):
@@ -21,7 +21,7 @@ def link(self):
def description(self):
if not hasattr(self, '_site'):
self._site = Site.objects.get_current()
- return "Latest comments on %s" % self._site.name
+ return u"Latest comments on %s" % self._site.name
def get_query_set(self):
return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)
View
2  django/contrib/comments/models.py
@@ -2,7 +2,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.contrib.auth.models import User
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ugettext_lazy as _
from django.conf import settings
import datetime
View
9 django/contrib/comments/views/comments.py
@@ -11,7 +11,8 @@
from django.http import HttpResponseRedirect
from django.utils.text import normalize_newlines
from django.conf import settings
-from django.utils.translation import ngettext
+from django.utils.translation import ungettext, ugettext as _
+from django.utils.encoding import smart_unicode
import base64, datetime
COMMENTS_PER_PAGE = 20
@@ -108,7 +109,7 @@ def save(self, new_data):
# If the commentor has posted fewer than COMMENTS_FIRST_FEW comments,
# send the comment to the managers.
if self.user_cache.comment_set.count() <= settings.COMMENTS_FIRST_FEW:
- message = ngettext('This comment was posted by a user who has posted fewer than %(count)s comment:\n\n%(text)s',
+ message = ungettext('This comment was posted by a user who has posted fewer than %(count)s comment:\n\n%(text)s',
'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s', settings.COMMENTS_FIRST_FEW) % \
{'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
mail_managers("Comment posted by rookie user", message)
@@ -248,7 +249,7 @@ def ratings(self):
# If the IP is banned, mail the admins, do NOT save the comment, and
# serve up the "Thanks for posting" page as if the comment WAS posted.
if request.META['REMOTE_ADDR'] in settings.BANNED_IPS:
- mail_admins("Banned IP attempted to post comment", str(request.POST) + "\n\n" + str(request.META))
+ mail_admins("Banned IP attempted to post comment", smart_unicode(request.POST) + "\n\n" + str(request.META))
else:
manipulator.do_html2python(new_data)
comment = manipulator.save(new_data)
@@ -312,7 +313,7 @@ def post_free_comment(request):
# serve up the "Thanks for posting" page as if the comment WAS posted.
if request.META['REMOTE_ADDR'] in settings.BANNED_IPS:
from django.core.mail import mail_admins
- mail_admins("Practical joker", str(request.POST) + "\n\n" + str(request.META))
+ mail_admins("Practical joker", smart_unicode(request.POST) + "\n\n" + str(request.META))
else:
manipulator.do_html2python(new_data)
comment = manipulator.save(new_data)
View
1  django/contrib/comments/views/karma.py
@@ -2,6 +2,7 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.comments.models import Comment, KarmaScore
+from django.utils.translation import ugettext as _
def vote(request, comment_id, vote):
"""
View
4 django/contrib/contenttypes/generic.py
@@ -49,7 +49,7 @@ def get_content_type(self, obj):
def __get__(self, instance, instance_type=None):
if instance is None:
- raise AttributeError, "%s must be accessed via instance" % self.name
+ raise AttributeError, u"%s must be accessed via instance" % self.name
try:
return getattr(instance, self.cache_attr)
@@ -66,7 +66,7 @@ def __get__(self, instance, instance_type=None):
def __set__(self, instance, value):
if instance is None:
- raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name
+ raise AttributeError, u"%s must be accessed via instance" % self.related.opts.object_name
ct = None
fk = None
View
3  django/contrib/contenttypes/management.py
@@ -4,6 +4,7 @@
from django.dispatch import dispatcher
from django.db.models import get_apps, get_models, signals
+from django.utils.encoding import smart_unicode
def create_contenttypes(app, created_models, verbosity=2):
from django.contrib.contenttypes.models import ContentType
@@ -17,7 +18,7 @@ def create_contenttypes(app, created_models, verbosity=2):
ContentType.objects.get(app_label=opts.app_label,
model=opts.object_name.lower())
except ContentType.DoesNotExist:
- ct = ContentType(name=str(opts.verbose_name),
+ ct = ContentType(name=smart_unicode(opts.verbose_name_raw),
app_label=opts.app_label, model=opts.object_name.lower())
ct.save()
if verbosity >= 2:
View
13 django/contrib/contenttypes/models.py
@@ -1,5 +1,6 @@
from django.db import models
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ugettext_lazy as _
+from django.utils.encoding import smart_unicode
CONTENT_TYPE_CACHE = {}
class ContentTypeManager(models.Manager):
@@ -13,13 +14,13 @@ def get_for_model(self, model):
try:
ct = CONTENT_TYPE_CACHE[key]
except KeyError:
- # The str() is needed around opts.verbose_name because it's a
- # django.utils.functional.__proxy__ object.
+ # The smart_unicode() is needed around opts.verbose_name_raw because it might
+ # be a django.utils.functional.__proxy__ object.
ct, created = self.model._default_manager.get_or_create(app_label=key[0],
- model=key[1], defaults={'name': str(opts.verbose_name)})
+ model=key[1], defaults={'name': smart_unicode(opts.verbose_name_raw)})
CONTENT_TYPE_CACHE[key] = ct
return ct
-
+
def clear_cache(self):
"""
Clear out the content-type cache. This needs to happen during database
@@ -42,7 +43,7 @@ class Meta:
ordering = ('name',)
unique_together = (('app_label', 'model'),)
- def __str__(self):
+ def __unicode__(self):
return self.name
def model_class(self):
View
32 django/contrib/databrowse/datastructures.py
@@ -7,6 +7,7 @@
from django.utils import dateformat
from django.utils.text import capfirst
from django.utils.translation import get_date_formats
+from django.utils.encoding import smart_unicode, smart_str, iri_to_uri
EMPTY_VALUE = '(None)'
@@ -19,7 +20,7 @@ def __init__(self, site, model):
self.verbose_name_plural = model._meta.verbose_name_plural
def __repr__(self):
- return '<EasyModel for %s>' % self.model._meta.object_name
+ return '<EasyModel for %s>' % smart_str(self.model._meta.object_name)
def model_databrowse(self):
"Returns the ModelDatabrowse class for this model."
@@ -54,7 +55,7 @@ def __init__(self, easy_model, field):
self.model, self.field = easy_model, field
def __repr__(self):
- return '<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)
+ return smart_str(u'<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def choices(self):
for value, label in self.field.choices:
@@ -72,29 +73,32 @@ def __init__(self, easy_model, field, value, label):
self.value, self.label = value, label
def __repr__(self):
- return '<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name)
+ return smart_str(u'<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def url(self):
- return '%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, self.value)
+ return '%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value))
class EasyInstance(object):
def __init__(self, easy_model, instance):
self.model, self.instance = easy_model, instance
def __repr__(self):
- return '<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val())
+ return smart_str(u'<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))
- def __str__(self):
- val = str(self.instance)
+ def __unicode__(self):
+ val = smart_unicode(self.instance)
if len(val) > 30:
- return val[:30] + '...'
+ return val[:30] + u'...'
return val
+ def __str__(self):
+ return self.__unicode__().encode('utf-8')
+
def pk(self):
return self.instance._get_pk_val()
def url(self):
- return '%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.pk())
+ return '%s%s/%s/objects/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, iri_to_uri(self.pk()))
def fields(self):
"""
@@ -126,7 +130,7 @@ def __init__(self, easy_model, instance, field):
self.raw_value = getattr(instance.instance, field.name)
def __repr__(self):
- return '<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name)
+ return smart_str(u'<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def values(self):
"""
@@ -175,18 +179,18 @@ def urls(self):
if self.field.rel.to in self.model.model_list:
lst = []
for value in self.values():
- url = '%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, value._get_pk_val())
- lst.append((str(value), url))
+ url = '%s%s/%s/objects/%s/' % (self.model.site.root_url, m.model._meta.app_label, m.model._meta.module_name, iri_to_uri(value._get_pk_val()))
+ lst.append((smart_unicode(value), url))
else:
lst = [(value, None) for value in self.values()]
elif self.field.choices:
lst = []
for value in self.values():
- url = '%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, self.raw_value)
+ url = '%s%s/%s/fields/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.name, iri_to_uri(self.raw_value))
lst.append((value, url))
elif isinstance(self.field, models.URLField):
val = self.values()[0]
- lst = [(val, val)]
+ lst = [(val, iri_to_uri(val))]
else:
lst = [(self.values()[0], None)]
return lst
View
9 django/contrib/databrowse/plugins/calendars.py
@@ -6,6 +6,7 @@
from django.utils.text import capfirst
from django.utils.translation import get_date_formats
from django.views.generic import date_based
+from django.utils.encoding import force_unicode
import datetime
import time
@@ -27,13 +28,13 @@ def field_dict(self, model):
def model_index_html(self, request, model, site):
fields = self.field_dict(model)
if not fields:
- return ''
- return '<p class="filter"><strong>View calendar by:</strong> %s</p>' % \
- ', '.join(['<a href="calendars/%s/">%s</a>' % (f.name, capfirst(f.verbose_name)) for f in fields.values()])
+ return u''
+ return u'<p class="filter"><strong>View calendar by:</strong> %s</p>' % \
+ u', '.join(['<a href="calendars/%s/">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()])
def urls(self, plugin_name, easy_instance_field):
if isinstance(easy_instance_field.field, models.DateField):
- return ['%s%s/%s/%s/%s/%s/' % (easy_instance_field.model.url(),
+ return [u'%s%s/%s/%s/%s/%s/' % (easy_instance_field.model.url(),
plugin_name, easy_instance_field.field.name,
easy_instance_field.raw_value.year,
easy_instance_field.raw_value.strftime('%b').lower(),
View
12 django/contrib/databrowse/plugins/fieldchoices.py
@@ -4,9 +4,11 @@
from django.contrib.databrowse.sites import DatabrowsePlugin
from django.shortcuts import render_to_response
from django.utils.text import capfirst
+from django.utils.encoding import smart_str, force_unicode
from django.views.generic import date_based
import datetime
import time
+import urllib
class FieldChoicePlugin(DatabrowsePlugin):
def __init__(self, field_filter=None):
@@ -29,15 +31,15 @@ def field_dict(self, model):
def model_index_html(self, request, model, site):
fields = self.field_dict(model)
if not fields:
- return ''
- return '<p class="filter"><strong>View by:</strong> %s</p>' % \
- ', '.join(['<a href="fields/%s/">%s</a>' % (f.name, capfirst(f.verbose_name)) for f in fields.values()])
+ return u''
+ return u'<p class="filter"><strong>View by:</strong> %s</p>' % \
+ u', '.join(['<a href="fields/%s/">%s</a>' % (f.name, force_unicode(capfirst(f.verbose_name))) for f in fields.values()])
def urls(self, plugin_name, easy_instance_field):
if easy_instance_field.field in self.field_dict(easy_instance_field.model.model).values():
- return ['%s%s/%s/%s/' % (easy_instance_field.model.url(),
+ return [u'%s%s/%s/%s/' % (easy_instance_field.model.url(),
plugin_name, easy_instance_field.field.name,
- easy_instance_field.raw_value)]
+ urllib.quote(smart_str(easy_instance_field.raw_value)))]
def model_view(self, request, model_databrowse, url):
self.model, self.site = model_databrowse.model, model_databrowse.site
View
2  django/contrib/databrowse/sites.py
@@ -60,7 +60,7 @@ def root(self, request, url):
def main_view(self, request):
easy_model = EasyModel(self.site, self.model)
- html_snippets = '\n'.join([p.model_index_html(request, self.model, self.site) for p in self.plugins.values()])
+ html_snippets = u'\n'.join([p.model_index_html(request, self.model, self.site) for p in self.plugins.values()])
return render_to_response('databrowse/model_detail.html', {
'model': easy_model,
'root_url': self.site.root_url,
View
2  django/contrib/databrowse/templates/databrowse/fieldchoice_list.html
@@ -10,7 +10,7 @@
<ul class="objectlist">
{% for object in object_list %}
-<li class="{% cycle odd,even %}"><a href="{{ object }}/">{{ object|escape }}</a></li>
+<li class="{% cycle odd,even %}"><a href="{{ object|iriencode }}/">{{ object|escape }}</a></li>
{% endfor %}
</ul>
View
6 django/contrib/flatpages/models.py
@@ -1,7 +1,7 @@
from django.core import validators
from django.db import models
from django.contrib.sites.models import Site
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ugettext_lazy as _
class FlatPage(models.Model):
url = models.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], db_index=True,
@@ -20,8 +20,8 @@ class Meta:
verbose_name_plural = _('flat pages')
ordering = ('url',)
- def __str__(self):
- return "%s -- %s" % (self.url, self.title)
+ def __unicode__(self):
+ return u"%s -- %s" % (self.url, self.title)
def get_absolute_url(self):
return self.url
View
18 django/contrib/humanize/templatetags/humanize.py
@@ -1,5 +1,5 @@
-from django.utils.translation import ngettext
-from django.utils.translation import gettext_lazy as _
+from django.utils.translation import ungettext, ugettext as _
+from django.utils.encoding import force_unicode
from django import template
import re
@@ -16,8 +16,8 @@ def ordinal(value):
return value
t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
if value % 100 in (11, 12, 13): # special case
- return "%d%s" % (value, t[0])
- return '%d%s' % (value, t[value % 10])
+ return u"%d%s" % (value, t[0])
+ return u'%d%s' % (value, t[value % 10])
register.filter(ordinal)
def intcomma(value):
@@ -25,8 +25,8 @@ def intcomma(value):
Converts an integer to a string containing commas every three digits.
For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
"""
- orig = str(value)
- new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', str(value))
+ orig = force_unicode(value)
+ new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', orig)
if orig == new:
return new
else:
@@ -44,13 +44,13 @@ def intword(value):
return value
if value < 1000000000:
new_value = value / 1000000.0
- return ngettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}
+ return ungettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}
if value < 1000000000000:
new_value = value / 1000000000.0
- return ngettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}
+ return ungettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}
if value < 1000000000000000:
new_value = value / 1000000000000.0
- return ngettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}
+ return ungettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}
return value
register.filter(intword)
View
12 django/contrib/localflavor/au/forms.py
@@ -5,7 +5,7 @@
from django.newforms import ValidationError
from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES
from django.newforms.util import smart_unicode
-from django.utils.translation import gettext
+from django.utils.translation import ugettext
import re
PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')
@@ -15,14 +15,14 @@ class AUPostCodeField(RegexField):
def __init__(self, *args, **kwargs):
super(AUPostCodeField, self).__init__(r'^\d{4}$',
max_length=None, min_length=None,
- error_message=gettext(u'Enter a 4 digit post code.'),
- *args, **kwargs)
+ error_message=ugettext('Enter a 4 digit post code.'),
+ *args, **kwargs)
class AUPhoneNumberField(Field):
"""Australian phone number field."""