Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

boulder-oracle-sprint: Merged to [5127]

  • Loading branch information...
commit 5a7802586d117a75f91df04c032fd249808a877d 1 parent 3b479bf
authored April 30, 2007
BIN  django/conf/locale/de/LC_MESSAGES/django.mo
Binary file not shown
2,125  django/conf/locale/de/LC_MESSAGES/django.po
1355 additions, 770 deletions not shown
4  django/conf/urls/defaults.py
@@ -22,5 +22,7 @@ def url(regex, view, kwargs=None, name=None, prefix=''):
22 22
         # For include(...) processing.
23 23
         return RegexURLResolver(regex, view[0], kwargs)
24 24
     else:
25  
-        return RegexURLPattern(regex, prefix and (prefix + '.' + view) or view, kwargs, name)
  25
+        if prefix and isinstance(view, basestring):
  26
+            view = prefix + '.' + view
  27
+        return RegexURLPattern(regex, view, kwargs, name)
26 28
 
46  django/db/models/fields/__init__.py
@@ -346,11 +346,13 @@ def _get_choices(self):
346 346
             return self._choices
347 347
     choices = property(_get_choices)
348 348
 
349  
-    def formfield(self, **kwargs):
  349
+    def formfield(self, form_class=forms.CharField, **kwargs):
350 350
         "Returns a django.newforms.Field instance for this database Field."
351 351
         defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  352
+        if self.choices:
  353
+            defaults['widget'] = forms.Select(choices=self.get_choices())
352 354
         defaults.update(kwargs)
353  
-        return forms.CharField(**defaults)
  355
+        return form_class(**defaults)
354 356
 
355 357
     def value_from_object(self, obj):
356 358
         "Returns the value of this field in the given model instance."
@@ -410,9 +412,9 @@ def get_manipulator_field_objs(self):
410 412
         return [oldforms.CheckboxField]
411 413
 
412 414
     def formfield(self, **kwargs):
413  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  415
+        defaults = {'form_class': forms.BooleanField}
414 416
         defaults.update(kwargs)
415  
-        return forms.BooleanField(**defaults)
  417
+        return super(BooleanField, self).formfield(**defaults)
416 418
 
417 419
 class CharField(Field):
418 420
     def get_manipulator_field_objs(self):
@@ -429,9 +431,9 @@ def to_python(self, value):
429 431
         return str(value)
430 432
 
431 433
     def formfield(self, **kwargs):
432  
-        defaults = {'max_length': self.maxlength, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  434
+        defaults = {'max_length': self.maxlength}
433 435
         defaults.update(kwargs)
434  
-        return forms.CharField(**defaults)
  436
+        return super(CharField, self).formfield(**defaults)
435 437
 
436 438
 # TODO: Maybe move this into contrib, because it's specialized.
437 439
 class CommaSeparatedIntegerField(CharField):
@@ -507,9 +509,9 @@ def flatten_data(self, follow, obj=None):
507 509
         return {self.attname: (val is not None and val.strftime("%Y-%m-%d") or '')}
508 510
 
509 511
     def formfield(self, **kwargs):
510  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  512
+        defaults = {'form_class': forms.DateField}
511 513
         defaults.update(kwargs)
512  
-        return forms.DateField(**defaults)
  514
+        return super(DateField, self).formfield(**defaults)
513 515
 
514 516
 class DateTimeField(DateField):
515 517
     def to_python(self, value):
@@ -576,9 +578,9 @@ def flatten_data(self,follow, obj = None):
576 578
                 time_field: (val is not None and val.strftime("%H:%M:%S") or '')}
577 579
 
578 580
     def formfield(self, **kwargs):
579  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  581
+        defaults = {'form_class': forms.DateTimeField}
580 582
         defaults.update(kwargs)
581  
-        return forms.DateTimeField(**defaults)
  583
+        return super(DateTimeField, self).formfield(**defaults)
582 584
 
583 585
 class EmailField(CharField):
584 586
     def __init__(self, *args, **kwargs):
@@ -595,9 +597,9 @@ def validate(self, field_data, all_data):
595 597
         validators.isValidEmail(field_data, all_data)
596 598
 
597 599
     def formfield(self, **kwargs):
598  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  600
+        defaults = {'form_class': forms.EmailField}
599 601
         defaults.update(kwargs)
600  
-        return forms.EmailField(**defaults)
  602
+        return super(EmailField, self).formfield(**defaults)
601 603
 
602 604
 class FileField(Field):
603 605
     def __init__(self, verbose_name=None, name=None, upload_to='', **kwargs):
@@ -732,9 +734,9 @@ def get_manipulator_field_objs(self):
732 734
         return [oldforms.IntegerField]
733 735
 
734 736
     def formfield(self, **kwargs):
735  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  737
+        defaults = {'form_class': forms.IntegerField}
736 738
         defaults.update(kwargs)
737  
-        return forms.IntegerField(**defaults)
  739
+        return super(IntegerField, self).formfield(**defaults)
738 740
 
739 741
 class IPAddressField(Field):
740 742
     def __init__(self, *args, **kwargs):
@@ -771,9 +773,9 @@ def validate(self, field_data, all_data):
771 773
 
772 774
     def formfield(self, **kwargs):
773 775
         from django.contrib.localflavor.us.forms import USPhoneNumberField
774  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  776
+        defaults = {'form_class': USPhoneNumberField}
775 777
         defaults.update(kwargs)
776  
-        return USPhoneNumberField(**defaults)
  778
+        return super(PhoneNumberField, self).formfield(**defaults)
777 779
 
778 780
 class PositiveIntegerField(IntegerField):
779 781
     def get_manipulator_field_objs(self):
@@ -804,9 +806,9 @@ def get_manipulator_field_objs(self):
804 806
         return [oldforms.LargeTextField]
805 807
 
806 808
     def formfield(self, **kwargs):
807  
-        defaults = {'required': not self.blank, 'widget': forms.Textarea, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  809
+        defaults = {'widget': forms.Textarea}
808 810
         defaults.update(kwargs)
809  
-        return forms.CharField(**defaults)
  811
+        return super(TextField, self).formfield(**defaults)
810 812
 
811 813
 class TimeField(Field):
812 814
     empty_strings_allowed = False
@@ -864,9 +866,9 @@ def flatten_data(self,follow, obj = None):
864 866
         return {self.attname: (val is not None and val.strftime("%H:%M:%S") or '')}
865 867
 
866 868
     def formfield(self, **kwargs):
867  
-        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  869
+        defaults = {'form_class': forms.TimeField}
868 870
         defaults.update(kwargs)
869  
-        return forms.TimeField(**defaults)
  871
+        return super(TimeField, self).formfield(**defaults)
870 872
 
871 873
 class URLField(CharField):
872 874
     def __init__(self, verbose_name=None, name=None, verify_exists=True, **kwargs):
@@ -883,9 +885,9 @@ def get_internal_type(self):
883 885
         return "CharField"
884 886
 
885 887
     def formfield(self, **kwargs):
886  
-        defaults = {'required': not self.blank, 'verify_exists': self.verify_exists, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
  888
+        defaults = {'form_class': forms.URLField, 'verify_exists': self.verify_exists}
887 889
         defaults.update(kwargs)
888  
-        return forms.URLField(**defaults)
  890
+        return super(URLField, self).formfield(**defaults)
889 891
 
890 892
 class USStateField(Field):
891 893
     def get_manipulator_field_objs(self):
18  django/db/models/fields/related.py
@@ -550,9 +550,9 @@ def contribute_to_related_class(self, cls, related):
@@ -616,9 +616,9 @@ def contribute_to_related_class(self, cls, related):
@@ -735,13 +735,13 @@ def value_from_object(self, obj):
4  django/template/__init__.py
@@ -204,7 +204,7 @@ def tokenize(self):
204 204
     def create_token(self, token_string, in_tag):
205 205
         """
206 206
         Convert the given token string into a new Token object and return it.
207  
-        If tag is True, we are processing something that matched a tag,
  207
+        If in_tag is True, we are processing something that matched a tag,
208 208
         otherwise it should be treated as a literal string.
209 209
         """
210 210
         if in_tag:
@@ -239,7 +239,7 @@ def tokenize(self):
239 239
 
240 240
     def create_token(self, token_string, source, in_tag):
241 241
         token = super(DebugLexer, self).create_token(token_string, in_tag)
242  
-        token.source = source
  242
+        token.source = self.origin, source
243 243
         return token
244 244
 
245 245
 class Parser(object):
8  docs/db-api.txt
@@ -112,7 +112,7 @@ the previous record in the database::
112 112
     b4 = Blog(id=3, name='Not Cheddar', tagline='Anything but cheese.')
113 113
     b4.save()  # Overrides the previous blog with ID=3!
114 114
 
115  
-See _`How Django knows to UPDATE vs. INSERT`, below, for the reason this
  115
+See `How Django knows to UPDATE vs. INSERT`_, below, for the reason this
116 116
 happens.
117 117
 
118 118
 Explicitly specifying auto-primary-key values is mostly useful for bulk-saving
@@ -714,7 +714,7 @@ QuerySet methods that do not return QuerySets
714 714
 The following ``QuerySet`` methods evaluate the ``QuerySet`` and return
715 715
 something *other than* a ``QuerySet``.
716 716
 
717  
-These methods do not use a cache (see _`Caching and QuerySets` below). Rather,
  717
+These methods do not use a cache (see `Caching and QuerySets`_ below). Rather,
718 718
 they query the database each time they're called.
719 719
 
720 720
 ``get(**kwargs)``
@@ -906,8 +906,8 @@ The database API supports the following lookup types:
906 906
 exact
907 907
 ~~~~~
908 908
 
909  
-Exact match. If the value provided for comparison is ``None``, it will 
910  
-be interpreted as an SQL ``NULL`` (See isnull_ for more details).  
  909
+Exact match. If the value provided for comparison is ``None``, it will
  910
+be interpreted as an SQL ``NULL`` (See isnull_ for more details).
911 911
 
912 912
 Examples::
913 913
 
15  docs/email.txt
@@ -21,20 +21,19 @@ In two lines::
21 21
         ['to@example.com'], fail_silently=False)
22 22
 
23 23
 Mail will be sent using the SMTP host and port specified in the `EMAIL_HOST`_
24  
-and `EMAIL_PORT`_ settings.  The `EMAIL_HOST_USER`_ and `EMAIL_HOST_PASSWORD`_
25  
-settings, if set, will be used to authenticate to the
26  
-SMTP server.
  24
+and `EMAIL_PORT`_ settings. The `EMAIL_HOST_USER`_ and `EMAIL_HOST_PASSWORD`_
  25
+settings, if set, will be used to authenticate to the SMTP server.
27 26
 
28 27
 .. note::
29 28
 
30 29
     The character set of email sent with ``django.core.mail`` will be set to
31 30
     the value of your `DEFAULT_CHARSET setting`_.
32 31
 
33  
-.. _DEFAULT_CHARSET setting: ../settings/#DEFAULT_CHARSET
34  
-.. _EMAIL_HOST: ../settings/#EMAIL_HOST
35  
-.. _EMAIL_PORT: ../settings/#EMAIL_PORT
36  
-.. _EMAIL_HOST_USER: ../settings/#EMAIL_HOST_USER
37  
-.. _EMAIL_HOST_PASSWORD: ../settings/#EMAIL_HOST_PASSWORD
  32
+.. _DEFAULT_CHARSET setting: ../settings/#default-charset
  33
+.. _EMAIL_HOST: ../settings/#email-host
  34
+.. _EMAIL_PORT: ../settings/#email-port
  35
+.. _EMAIL_HOST_USER: ../settings/#email-host-user
  36
+.. _EMAIL_HOST_PASSWORD: ../settings/#email-host-password
38 37
 
39 38
 
40 39
 send_mail()
5  docs/settings.txt
@@ -396,8 +396,9 @@ EMAIL_HOST_PASSWORD
396 396
 Default: ``''`` (Empty string)
397 397
 
398 398
 Password to use for the SMTP server defined in ``EMAIL_HOST``. This setting is
399  
-used in conjunction with EMAIL_HOST_USER when authenticating to the SMTP server.
400  
-If either of these settings is empty, Django won't attempt authenticaion.
  399
+used in conjunction with ``EMAIL_HOST_USER`` when authenticating to the SMTP
  400
+server. If either of these settings is empty, Django won't attempt
  401
+authenticaion.
401 402
 
402 403
 See also ``EMAIL_HOST_USER``.
403 404
 
41  tests/modeltests/model_forms/models.py
@@ -24,6 +24,12 @@
24 24
 
25 25
 from django.db import models
26 26
 
  27
+ARTICLE_STATUS = (
  28
+    (1, 'Draft'),
  29
+    (2, 'Pending'),
  30
+    (3, 'Live'),
  31
+)
  32
+
27 33
 class Category(models.Model):
28 34
     name = models.CharField(maxlength=20)
29 35
     url = models.CharField('The URL', maxlength=40)
@@ -44,6 +50,7 @@ class Article(models.Model):
44 50
     writer = models.ForeignKey(Writer)
45 51
     article = models.TextField()
46 52
     categories = models.ManyToManyField(Category, blank=True)
  53
+    status = models.IntegerField(choices=ARTICLE_STATUS, blank=True, null=True)
47 54
 
48 55
     def save(self):
49 56
         import datetime
@@ -147,8 +154,8 @@ def __str__(self):
147 154
 >>> w = Writer(name='Bob Woodward')
148 155
 >>> w.save()
149 156
 
150  
-ManyToManyFields are represented by a MultipleChoiceField, and ForeignKeys are
151  
-represented by a ChoiceField.
  157
+ManyToManyFields are represented by a MultipleChoiceField, ForeignKeys and any
  158
+fields with the 'choices' attribute are represented by a ChoiceField.
152 159
 >>> ArticleForm = form_for_model(Article)
153 160
 >>> f = ArticleForm(auto_id=False)
154 161
 >>> print f
@@ -160,6 +167,12 @@ def __str__(self):
160 167
 <option value="2">Bob Woodward</option>
161 168
 </select></td></tr>
162 169
 <tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr>
  170
+<tr><th>Status:</th><td><select name="status">
  171
+<option value="" selected="selected">---------</option>
  172
+<option value="1">Draft</option>
  173
+<option value="2">Pending</option>
  174
+<option value="3">Live</option>
  175
+</select></td></tr>
163 176
 <tr><th>Categories:</th><td><select multiple="multiple" name="categories">
164 177
 <option value="1">Entertainment</option>
165 178
 <option value="2">It&#39;s a test</option>
@@ -200,6 +213,12 @@ def __str__(self):
200 213
 <option value="2">Bob Woodward</option>
201 214
 </select></li>
202 215
 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li>
  216
+<li>Status: <select name="status">
  217
+<option value="" selected="selected">---------</option>
  218
+<option value="1">Draft</option>
  219
+<option value="2">Pending</option>
  220
+<option value="3">Live</option>
  221
+</select></li>
203 222
 <li>Categories: <select multiple="multiple" name="categories">
204 223
 <option value="1">Entertainment</option>
205 224
 <option value="2">It&#39;s a test</option>
@@ -232,6 +251,12 @@ def __str__(self):
232 251
 <option value="2">Bob Woodward</option>
233 252
 </select></li>
234 253
 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li>
  254
+<li>Status: <select name="status">
  255
+<option value="" selected="selected">---------</option>
  256
+<option value="1">Draft</option>
  257
+<option value="2">Pending</option>
  258
+<option value="3">Live</option>
  259
+</select></li>
235 260
 <li>Categories: <select multiple="multiple" name="categories">
236 261
 <option value="1" selected="selected">Entertainment</option>
237 262
 <option value="2">It&#39;s a test</option>
@@ -310,6 +335,12 @@ def __str__(self):
310 335
 <option value="2">Bob Woodward</option>
311 336
 </select></li>
312 337
 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li>
  338
+<li>Status: <select name="status">
  339
+<option value="" selected="selected">---------</option>
  340
+<option value="1">Draft</option>
  341
+<option value="2">Pending</option>
  342
+<option value="3">Live</option>
  343
+</select></li>
313 344
 <li>Categories: <select multiple="multiple" name="categories">
314 345
 <option value="1">Entertainment</option>
315 346
 <option value="2">It&#39;s a test</option>
@@ -329,6 +360,12 @@ def __str__(self):
329 360
 <option value="3">Carl Bernstein</option>
330 361
 </select></li>
331 362
 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li>
  363
+<li>Status: <select name="status">
  364
+<option value="" selected="selected">---------</option>
  365
+<option value="1">Draft</option>
  366
+<option value="2">Pending</option>
  367
+<option value="3">Live</option>
  368
+</select></li>
332 369
 <li>Categories: <select multiple="multiple" name="categories">
333 370
 <option value="1">Entertainment</option>
334 371
 <option value="2">It&#39;s a test</option>
2  tests/regressiontests/templates/tests.py
@@ -217,7 +217,7 @@ def test_templates(self):
217 217
 
218 218
             # If a variable has a __str__() that returns a Unicode object, the
219 219
             # value will be converted to a bytestring.
220  
-            'basic-syntax18': (r'{{ var }}', {'var': UnicodeInStrClass()}, '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91'),
  220
+            'filter-syntax18': (r'{{ var }}', {'var': UnicodeInStrClass()}, '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91'),
221 221
 
222 222
             ### COMMENT SYNTAX ########################################################
223 223
             'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"),

0 notes on commit 5a78025

Please sign in to comment.
Something went wrong with that request. Please try again.