mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-04-28 17:04:43 +00:00
Refactored TranslationField. Removed method overrides which are obsoleted by the the field_factory.
This commit is contained in:
parent
0842323e27
commit
825cbe38da
1 changed files with 0 additions and 33 deletions
|
|
@ -78,12 +78,7 @@ class TranslationField(object):
|
|||
# Update the dict of this field with the content of the original one
|
||||
# This might be a bit radical?! Seems to work though...
|
||||
self.__dict__.update(translated_field.__dict__)
|
||||
self._post_init(translated_field, language)
|
||||
|
||||
def _post_init(self, translated_field, language):
|
||||
"""
|
||||
Common init for subclasses of TranslationField.
|
||||
"""
|
||||
# Store the originally wrapped field for later
|
||||
self.translated_field = translated_field
|
||||
self.language = language
|
||||
|
|
@ -103,25 +98,6 @@ class TranslationField(object):
|
|||
self.verbose_name = build_localized_verbose_name(
|
||||
translated_field.verbose_name, language)
|
||||
|
||||
def pre_save(self, model_instance, add):
|
||||
val = self.translated_field.__class__.pre_save(
|
||||
self, model_instance, add)
|
||||
return val
|
||||
|
||||
def get_prep_value(self, value):
|
||||
if value == '':
|
||||
value = None
|
||||
return self.translated_field.get_prep_value(value)
|
||||
|
||||
def get_prep_lookup(self, lookup_type, value):
|
||||
return self.translated_field.get_prep_lookup(lookup_type, value)
|
||||
|
||||
def to_python(self, value):
|
||||
return self.translated_field.to_python(value)
|
||||
|
||||
def get_internal_type(self):
|
||||
return self.translated_field.get_internal_type()
|
||||
|
||||
def south_field_triple(self):
|
||||
"""
|
||||
Returns a suitable description of this field for South.
|
||||
|
|
@ -134,15 +110,6 @@ class TranslationField(object):
|
|||
# That's our definition!
|
||||
return (field_class, args, kwargs)
|
||||
|
||||
def formfield(self, *args, **kwargs):
|
||||
"""
|
||||
Preserves the widget of the translated field.
|
||||
"""
|
||||
trans_formfield = self.translated_field.formfield(*args, **kwargs)
|
||||
defaults = {'widget': type(trans_formfield.widget)}
|
||||
defaults.update(kwargs)
|
||||
return super(TranslationField, self).formfield(*args, **defaults)
|
||||
|
||||
|
||||
class TranslationFieldDescriptor(object):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue