Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tof/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ def add_translation_to_class(self, trans_mng=None):
trans_mng.contribute_to_class(cls, 'objects')
origin.contribute_to_class(cls, 'objects_origin')

cls._meta._field_tof = {
'by_id': {self.id: self},
'by_name': {self.name: self}
}
cls._meta._field_tof['by_id'].update({self.id: self})
Copy link
Author

@baobab-ai baobab-ai Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mom1 The original pull request had an issue, now this should do the work, originally there was setattr with nested setdefault. It was quite hard to read and understand. Also, I hope that a good idea to add more tests for core functionality.

cls._meta._field_tof['by_name'].update({self.name: self})

field = getattr(cls, self.name).field
field_class = TranslatableCharField if isinstance(field, models.CharField) else TranslatableTextField
Expand Down