Ticket #1679: multiline_fields.patch

File multiline_fields.patch, 2.1 KB (added by lalo.martins@…, 19 years ago)
  • django/db/models/fields/__init__.py

     
    6767        maxlength=None, unique=False, blank=False, null=False, db_index=False,
    6868        core=False, rel=None, default=NOT_PROVIDED, editable=True,
    6969        prepopulate_from=None, unique_for_date=None, unique_for_month=None,
    70         unique_for_year=None, validator_list=None, choices=None, radio_admin=None,
     70        unique_for_year=None, validator_list=None, choices=None,
     71        radio_admin=None, multiline_admin=None,
    7172        help_text='', db_column=None):
    7273        self.name = name
    7374        self.verbose_name = verbose_name
     
    8283        self.unique_for_year = unique_for_year
    8384        self.choices = choices or []
    8485        self.radio_admin = radio_admin
     86        self.multiline_admin = multiline_admin
    8587        self.help_text = help_text
    8688        self.db_column = db_column
    8789
     
    377379        return [forms.CheckboxField]
    378380
    379381class CharField(Field):
     382    def __init__(self, *args, **kwargs):
     383        if 'multiline_admin' not in kwargs:
     384            kwargs['multiline_admin'] = False
     385        Field.__init__(self, *args, **kwargs)
     386
    380387    def get_manipulator_field_objs(self):
    381         return [forms.TextField]
     388        if self.multiline_admin:
     389            return [forms.LargeTextField]
     390        else:
     391            return [forms.TextField]
    382392
    383393    def to_python(self, value):
    384394        if isinstance(value, basestring):
     
    710720        return [forms.SmallIntegerField]
    711721
    712722class TextField(Field):
     723    def __init__(self, *args, **kwargs):
     724        if 'multiline_admin' not in kwargs:
     725            kwargs['multiline_admin'] = True
     726        Field.__init__(self, *args, **kwargs)
     727
    713728    def get_manipulator_field_objs(self):
    714         return [forms.LargeTextField]
     729        if self.multiline_admin:
     730            return [forms.LargeTextField]
     731        else:
     732            return [forms.TextField]
    715733
    716734class TimeField(Field):
    717735    empty_strings_allowed = False
Back to Top