equal
deleted
inserted
replaced
178 |
178 |
179 class StringField(Field): |
179 class StringField(Field): |
180 def __init__(self, max_length=None, **kwargs): |
180 def __init__(self, max_length=None, **kwargs): |
181 super(StringField, self).__init__(**kwargs) |
181 super(StringField, self).__init__(**kwargs) |
182 self.max_length = max_length |
182 self.max_length = max_length |
183 |
183 if max_length < 513 and isinstance(self.widget, TextArea): |
184 |
184 self.widget.attrs['cols'], self.widget.attrs['rows'] = 60, 5 |
185 class TextField(Field): |
185 |
|
186 |
|
187 class TextField(StringField): |
|
188 """XXX string field not enough?""" |
186 widget = TextArea |
189 widget = TextArea |
187 def __init__(self, rows=10, cols=80, **kwargs): |
|
188 super(TextField, self).__init__(**kwargs) |
|
189 self.rows = rows |
|
190 self.cols = cols |
|
191 |
190 |
192 |
191 |
193 class RichTextField(TextField): |
192 class RichTextField(TextField): |
194 widget = None |
193 widget = None |
195 def __init__(self, format_field=None, **kwargs): |
194 def __init__(self, format_field=None, **kwargs): |
422 kwargs['widget'].attrs.setdefault('size', 1) |
421 kwargs['widget'].attrs.setdefault('size', 1) |
423 return StringField(choices=cstr.vocabulary, **kwargs) |
422 return StringField(choices=cstr.vocabulary, **kwargs) |
424 if isinstance(cstr, SizeConstraint) and cstr.max is not None: |
423 if isinstance(cstr, SizeConstraint) and cstr.max is not None: |
425 if cstr.max > 257: |
424 if cstr.max > 257: |
426 rows_cols_from_constraint(cstr, kwargs) |
425 rows_cols_from_constraint(cstr, kwargs) |
427 field = TextField(**kwargs) |
426 field = TextField(max_length=cstr.max, **kwargs) |
428 else: |
427 else: |
429 field = StringField(max_length=cstr.max, **kwargs) |
428 field = StringField(max_length=cstr.max, **kwargs) |
430 return field or TextField(**kwargs) |
429 return field or TextField(**kwargs) |
431 |
430 |
432 |
431 |