Ticket #503: required.diff

File required.diff, 6.6 KB (added by craig@…, 10 years ago)

makes CharField's maxlength and FloatField's max_digits and decimal_places positional non-defaulted arguments for the constructors

  • django/models/core.py

     
    11from django.core import meta, validators
    22
    33class Site(meta.Model):
    4     domain = meta.CharField('domain name', maxlength=100)
    5     name = meta.CharField('display name', maxlength=50)
     4    domain = meta.CharField(100, 'domain name')
     5    name = meta.CharField(50, 'display name')
    66    class META:
    77        db_table = 'sites'
    88        ordering = ('domain',)
     
    1616        return get_object(pk=SITE_ID)
    1717
    1818class Package(meta.Model):
    19     label = meta.CharField(maxlength=20, primary_key=True)
    20     name = meta.CharField(maxlength=30, unique=True)
     19    label = meta.CharField(20, primary_key=True)
     20    name = meta.CharField(30, unique=True)
    2121    class META:
    2222        db_table = 'packages'
    2323        ordering = ('name',)
     
    2626        return self.name
    2727
    2828class ContentType(meta.Model):
    29     name = meta.CharField(maxlength=100)
     29    name = meta.CharField(100)
    3030    package = meta.ForeignKey(Package, db_column='package')
    31     python_module_name = meta.CharField(maxlength=50)
     31    python_module_name = meta.CharField(50)
    3232    class META:
    3333        db_table = 'content_types'
    3434        ordering = ('package', 'name')
     
    5252
    5353class Redirect(meta.Model):
    5454    site = meta.ForeignKey(Site, radio_admin=meta.VERTICAL)
    55     old_path = meta.CharField('redirect from', maxlength=200, db_index=True,
     55    old_path = meta.CharField(200, 'redirect from', db_index=True,
    5656        help_text="This should be an absolute path, excluding the domain name. Example: '/events/search/'.")
    57     new_path = meta.CharField('redirect to', maxlength=200, blank=True,
     57    new_path = meta.CharField(200, 'redirect to', blank=True,
    5858        help_text="This can be either an absolute path (as above) or a full URL starting with 'http://'.")
    5959    class META:
    6060        db_table = 'redirects'
     
    6969        return "%s ---> %s" % (self.old_path, self.new_path)
    7070
    7171class FlatFile(meta.Model):
    72     url = meta.CharField('URL', maxlength=100, validator_list=[validators.isAlphaNumericURL],
     72    url = meta.CharField(100, 'URL', validator_list=[validators.isAlphaNumericURL],
    7373        help_text="Example: '/about/contact/'. Make sure to have leading and trailing slashes.")
    74     title = meta.CharField(maxlength=200)
     74    title = meta.CharField(200)
    7575    content = meta.TextField()
    7676    enable_comments = meta.BooleanField()
    77     template_name = meta.CharField(maxlength=70, blank=True,
     77    template_name = meta.CharField(70, blank=True,
    7878        help_text="Example: 'flatfiles/contact_page'. If this isn't provided, the system will use 'flatfiles/default'.")
    7979    registration_required = meta.BooleanField(help_text="If this is checked, only logged-in users will be able to view the page.")
    8080    sites = meta.ManyToManyField(Site)
     
    101101import cPickle as pickle
    102102
    103103class Session(meta.Model):
    104     session_key = meta.CharField(maxlength=40, primary_key=True)
     104    session_key = meta.CharField(40, primary_key=True)
    105105    session_data = meta.TextField()
    106106    expire_date = meta.DateTimeField()
    107107    class META:
  • django/models/auth.py

     
    22from django.models import core
    33
    44class Permission(meta.Model):
    5     name = meta.CharField(maxlength=50)
     5    name = meta.CharField(50)
    66    package = meta.ForeignKey(core.Package, db_column='package')
    7     codename = meta.CharField(maxlength=100)
     7    codename = meta.CharField(100)
    88    class META:
    99        unique_together = (('package', 'codename'),)
    1010        ordering = ('package', 'codename')
     
    1313        return "%s | %s" % (self.package, self.name)
    1414
    1515class Group(meta.Model):
    16     name = meta.CharField(maxlength=80, unique=True)
     16    name = meta.CharField(80, unique=True)
    1717    permissions = meta.ManyToManyField(Permission, blank=True, filter_interface=meta.HORIZONTAL)
    1818    class META:
    1919        ordering = ('name',)
     
    2525        return self.name
    2626
    2727class User(meta.Model):
    28     username = meta.CharField(maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric])
    29     first_name = meta.CharField(maxlength=30, blank=True)
    30     last_name = meta.CharField(maxlength=30, blank=True)
     28    username = meta.CharField(30, unique=True, validator_list=[validators.isAlphaNumeric])
     29    first_name = meta.CharField(30, blank=True)
     30    last_name = meta.CharField(30, blank=True)
    3131    email = meta.EmailField('e-mail address', blank=True)
    32     password_md5 = meta.CharField('password', maxlength=32, help_text="Use an MD5 hash -- not the raw password.")
     32    password_md5 = meta.CharField(32, 'password', help_text="Use an MD5 hash -- not the raw password.")
    3333    is_staff = meta.BooleanField('staff status', help_text="Designates whether the user can log into this admin site.")
    3434    is_active = meta.BooleanField('active', default=True)
    3535    is_superuser = meta.BooleanField('superuser status')
     
    182182    user = meta.ForeignKey(User)
    183183    content_type = meta.ForeignKey(core.ContentType, blank=True, null=True) # TODO: content_type_id name?
    184184    object_id = meta.TextField(blank=True, null=True)
    185     object_repr = meta.CharField(maxlength=200)
     185    object_repr = meta.CharField(200)
    186186    action_flag = meta.PositiveSmallIntegerField()
    187187    change_message = meta.TextField(blank=True)
    188188    class META:
  • django/core/meta/fields.py

     
    287287        return [formfields.CheckboxField]
    288288
    289289class CharField(Field):
     290    def __init__(self, maxlength, *args, **kwargs):
     291        kwargs['maxlength'] = maxlength
     292        Field.__init__(self, *args, **kwargs)
     293       
    290294    def get_manipulator_field_objs(self):
    291295        return [formfields.TextField]
    292296
     
    422426
    423427class FloatField(Field):
    424428    empty_strings_allowed = False
    425     def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs):
    426         self.max_digits, self.decimal_places = max_digits, decimal_places
    427         Field.__init__(self, verbose_name, name, **kwargs)
     429    def __init__(self, max_digits, decimal_places, *args, **kwargs):
     430        self.max_digits = max_digits
     431        self.decimal_places = decimal_places
     432        Field.__init__(self, *args, **kwargs)
    428433
    429434    def get_manipulator_field_objs(self):
    430435        return [curry(formfields.FloatField, max_digits=self.max_digits, decimal_places=self.decimal_places)]
Back to Top