Browse files

new-admin: Merged to trunk 1424

git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1425 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 8f5f915 commit 5edaf7838e64ea679f11a0f2b8855faa9333850e @adrianholovaty adrianholovaty committed Nov 25, 2005
View
24 django/contrib/admin/templatetags/adminmedia.py
@@ -1,17 +1,9 @@
-from django.core import template
+from django.core.template.decorators import simple_tag
-class AdminMediaPrefixNode(template.Node):
- def render(self, context):
- try:
- from django.conf.settings import ADMIN_MEDIA_PREFIX
- except ImportError:
- return ''
- return ADMIN_MEDIA_PREFIX
-
-def admin_media_prefix(parser, token):
- """
- {% admin_media_prefix %}
- """
- return AdminMediaPrefixNode()
-
-template.register_tag('admin_media_prefix', admin_media_prefix)
+def admin_media_prefix():
+ try:
+ from django.conf.settings import ADMIN_MEDIA_PREFIX
+ except ImportError:
+ return ''
+ return ADMIN_MEDIA_PREFIX
+admin_media_prefix = simple_tag(admin_media_prefix)
View
2 django/core/formfields.py
@@ -333,7 +333,7 @@ def __init__(self, field_name, length=30, maxlength=None, is_required=False, val
def isValidLength(self, data, form):
if data and self.maxlength and len(data.decode(DEFAULT_CHARSET)) > self.maxlength:
- raise validators.ValidationError, ngettext("Ensure your text is less than %s character",
+ raise validators.ValidationError, ngettext("Ensure your text is less than %s character.",
"Ensure your text is less than %s characters.", self.maxlength) % self.maxlength
def hasNoNewlines(self, data, form):
View
2 django/core/meta/fields.py
@@ -775,7 +775,7 @@ def isValidIDList(self, field_data, all_data):
if len(objects) != len(pks):
badkeys = [k for k in pks if k not in objects]
raise validators.ValidationError, ngettext("Please enter valid %(self)s IDs. The value %(value)r is invalid.",
- "Please enter valid %(self)s IDs. The values %(value)r are invalid", len(badkeys)) % {
+ "Please enter valid %(self)s IDs. The values %(value)r are invalid.", len(badkeys)) % {
'self': self.verbose_name,
'value': len(badkeys) == 1 and badkeys[0] or tuple(badkeys),
}
View
29 django/templatetags/i18n.py
@@ -1,15 +1,10 @@
-"Default tags used by the template system, available to all templates."
-
from django.core.template import Node, NodeList, Template, Context, resolve_variable, resolve_variable_with_filters, registered_filters
from django.core.template import TemplateSyntaxError, register_tag, TokenParser
from django.core.template import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR
from django.utils import translation
-
-import sys
-import re
+import re, sys
class GetAvailableLanguagesNode(Node):
-
def __init__(self, variable):
self.variable = variable
@@ -19,7 +14,6 @@ def render(self, context):
return ''
class GetCurrentLanguageNode(Node):
-
def __init__(self, variable):
self.variable = variable
@@ -28,7 +22,6 @@ def render(self, context):
return ''
class TranslateNode(Node):
-
def __init__(self, value, noop):
self.value = value
self.noop = noop
@@ -41,7 +34,6 @@ def render(self, context):
return translation.gettext(value)
class BlockTranslateNode(Node):
-
def __init__(self, extra_context, singular, plural=None, countervar=None, counter=None):
self.extra_context = extra_context
self.singular = singular
@@ -78,7 +70,7 @@ def do_get_available_languages(parser, token):
This will store a list of available languages
in the context.
- Usage is as follows::
+ Usage::
{% get_available_languages as languages %}
{% for language in languages %}
@@ -89,26 +81,23 @@ def do_get_available_languages(parser, token):
your setting file (or the default settings) and
put it into the named variable.
"""
-
args = token.contents.split()
if len(args) != 3 or args[1] != 'as':
raise TemplateSyntaxError, "'get_available_languages' requires 'as variable' (got %r)" % args
return GetAvailableLanguagesNode(args[2])
def do_get_current_language(parser, token):
"""
- This will store the current language in
- the context.
+ This will store the current language in the context.
- Usage is as follows::
+ Usage::
{% get_current_language as language %}
This will fetch the currently active language and
put it's value into the ``language`` context
variable.
"""
-
args = token.contents.split()
if len(args) != 3 or args[1] != 'as':
raise TemplateSyntaxError, "'get_available_languages' requires 'as variable' (got %r)" % args
@@ -119,7 +108,7 @@ def do_translate(parser, token):
This will mark a string for translation and will
translate the string for the current language.
- Usage is like this::
+ Usage::
{% trans "this is a test" %}
@@ -144,9 +133,7 @@ def do_translate(parser, token):
the variable ``variable``. Make sure that the string
in there is something that is in the .po file.
"""
-
class TranslateParser(TokenParser):
-
def top(self):
value = self.value()
if self.more():
@@ -157,21 +144,20 @@ def top(self):
else:
noop = False
return (value, noop)
-
(value, noop) = TranslateParser(token.contents).top()
return TranslateNode(value, noop)
def do_block_translate(parser, token):
"""
This will translate a block of text with parameters.
- Format is like this::
+ Usage::
{% blocktrans with foo|filter as bar and baz|filter as boo %}
This is {{ bar }} and {{ boo }}.
{% endblocktrans %}
- Additionally this supports pluralization::
+ Additionally, this supports pluralization::
{% blocktrans count var|length as count %}
There is {{ count }} object.
@@ -231,4 +217,3 @@ def top(self):
register_tag('get_current_language', do_get_current_language)
register_tag('trans', do_translate)
register_tag('blocktrans', do_block_translate)
-
View
2 django/views/registration/passwords.py
@@ -1,6 +1,6 @@
from django.core import formfields, validators
from django.core.extensions import DjangoContext, render_to_response
-from django.core.template import loader
+from django.core.template import Context, loader
from django.models.auth import users
from django.views.decorators.auth import login_required
from django.utils.httpwrappers import HttpResponseRedirect

0 comments on commit 5edaf78

Please sign in to comment.