Django

Code

Changeset 1425

Show
Ignore:
Timestamp:
11/24/05 21:03:17 (3 years ago)
Author:
adrian
Message:

new-admin: Merged to trunk 1424

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/new-admin/django/contrib/admin/templatetags/adminmedia.py

    r966 r1425  
    1 from django.core import template 
     1from django.core.template.decorators import simple_tag 
    22 
    3 class AdminMediaPrefixNode(template.Node): 
    4     def render(self, context): 
    5         try: 
    6             from django.conf.settings import ADMIN_MEDIA_PREFIX 
    7         except ImportError: 
    8             return '' 
    9         return ADMIN_MEDIA_PREFIX 
    10  
    11 def admin_media_prefix(parser, token): 
    12     """ 
    13     {% admin_media_prefix %} 
    14     """ 
    15     return AdminMediaPrefixNode() 
    16  
    17 template.register_tag('admin_media_prefix', admin_media_prefix) 
     3def admin_media_prefix(): 
     4    try: 
     5        from django.conf.settings import ADMIN_MEDIA_PREFIX 
     6    except ImportError: 
     7        return '' 
     8    return ADMIN_MEDIA_PREFIX 
     9admin_media_prefix = simple_tag(admin_media_prefix) 
  • django/branches/new-admin/django/core/formfields.py

    r1421 r1425  
    334334    def isValidLength(self, data, form): 
    335335        if data and self.maxlength and len(data.decode(DEFAULT_CHARSET)) > self.maxlength: 
    336             raise validators.ValidationError, ngettext("Ensure your text is less than %s character", 
     336            raise validators.ValidationError, ngettext("Ensure your text is less than %s character.", 
    337337                "Ensure your text is less than %s characters.", self.maxlength) % self.maxlength 
    338338 
  • django/branches/new-admin/django/core/meta/fields.py

    r1414 r1425  
    776776            badkeys = [k for k in pks if k not in objects] 
    777777            raise validators.ValidationError, ngettext("Please enter valid %(self)s IDs. The value %(value)r is invalid.", 
    778                     "Please enter valid %(self)s IDs. The values %(value)r are invalid", len(badkeys)) % { 
     778                    "Please enter valid %(self)s IDs. The values %(value)r are invalid.", len(badkeys)) % { 
    779779                'self': self.verbose_name, 
    780780                'value': len(badkeys) == 1 and badkeys[0] or tuple(badkeys), 
  • django/branches/new-admin/django/templatetags/i18n.py

    r1255 r1425  
    1 "Default tags used by the template system, available to all templates." 
    2  
    31from django.core.template import Node, NodeList, Template, Context, resolve_variable, resolve_variable_with_filters, registered_filters 
    42from django.core.template import TemplateSyntaxError, register_tag, TokenParser 
    53from django.core.template import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR 
    64from django.utils import translation 
    7  
    8 import sys 
    9 import re 
     5import re, sys 
    106 
    117class GetAvailableLanguagesNode(Node): 
    12  
    138    def __init__(self, variable): 
    149        self.variable = variable 
     
    2015 
    2116class GetCurrentLanguageNode(Node): 
    22  
    2317    def __init__(self, variable): 
    2418        self.variable = variable 
     
    2923 
    3024class TranslateNode(Node): 
    31  
    3225    def __init__(self, value, noop): 
    3326        self.value = value 
     
    4235 
    4336class BlockTranslateNode(Node): 
    44  
    4537    def __init__(self, extra_context, singular, plural=None, countervar=None, counter=None): 
    4638        self.extra_context = extra_context 
     
    7971    in the context. 
    8072 
    81     Usage is as follows:: 
     73    Usage:: 
    8274 
    8375        {% get_available_languages as languages %} 
     
    9082    put it into the named variable. 
    9183    """ 
    92  
    9384    args = token.contents.split() 
    9485    if len(args) != 3 or args[1] != 'as': 
     
    9889def do_get_current_language(parser, token): 
    9990    """ 
    100     This will store the current language in 
    101     the context. 
    102  
    103     Usage is as follows:: 
     91    This will store the current language in the context. 
     92 
     93    Usage:: 
    10494 
    10595        {% get_current_language as language %} 
     
    10999    variable. 
    110100    """ 
    111  
    112101    args = token.contents.split() 
    113102    if len(args) != 3 or args[1] != 'as': 
     
    120109    translate the string for the current language. 
    121110 
    122     Usage is like this:: 
     111    Usage:: 
    123112 
    124113        {% trans "this is a test" %} 
     
    145134    in there is something that is in the .po file. 
    146135    """ 
    147  
    148136    class TranslateParser(TokenParser): 
    149  
    150137        def top(self): 
    151138            value = self.value() 
     
    158145                noop = False 
    159146            return (value, noop) 
    160  
    161147    (value, noop) = TranslateParser(token.contents).top() 
    162148    return TranslateNode(value, noop) 
     
    166152    This will translate a block of text with parameters. 
    167153 
    168     Format is like this:: 
     154    Usage:: 
    169155 
    170156        {% blocktrans with foo|filter as bar and baz|filter as boo %} 
     
    172158        {% endblocktrans %} 
    173159 
    174     Additionally this supports pluralization:: 
     160    Additionally, this supports pluralization:: 
    175161 
    176162        {% blocktrans count var|length as count %} 
     
    232218register_tag('trans', do_translate) 
    233219register_tag('blocktrans', do_block_translate) 
    234  
  • django/branches/new-admin/django/views/registration/passwords.py

    r1408 r1425  
    11from django.core import formfields, validators 
    22from django.core.extensions import DjangoContext, render_to_response 
    3 from django.core.template import loader 
     3from django.core.template import Context, loader 
    44from django.models.auth import users 
    55from django.views.decorators.auth import login_required