Skip to content

Commit

Permalink
chore: Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed Feb 9, 2023
1 parent 3c0735c commit f0fb6eb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modeltranslation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def replace_orig_field(self, option):
def _patch_fieldsets(self, fieldsets):
if fieldsets:
fieldsets_new = list(fieldsets)
for (name, dct) in fieldsets:
for name, dct in fieldsets:
if 'fields' in dct:
dct['fields'] = self.replace_orig_field(dct['fields'])
fieldsets = fieldsets_new
Expand Down
3 changes: 0 additions & 3 deletions modeltranslation/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def __init__(self, translated_field, language, empty_value, *args, **kwargs):
if isinstance(self.translated_field, fields.related.ManyToManyField) and hasattr(
self.remote_field, "through"
):

# Since fields cannot share the same remote_field object:
self.remote_field = copy.copy(self.remote_field)

Expand Down Expand Up @@ -207,7 +206,6 @@ def __init__(self, translated_field, language, empty_value, *args, **kwargs):

# ForeignKey support - rewrite related_name
elif not NEW_RELATED_API and self.rel and self.related and not self.rel.is_hidden():

current = self.related.get_accessor_name()
self.rel = copy.copy(self.rel) # Since fields cannot share the same rel object.
# self.related doesn't need to be copied, as it will be recreated in
Expand All @@ -224,7 +222,6 @@ def __init__(self, translated_field, language, empty_value, *args, **kwargs):
if hasattr(self.rel.to._meta, '_related_objects_cache'):
del self.rel.to._meta._related_objects_cache
elif NEW_RELATED_API and self.remote_field and not self.remote_field.is_hidden():

current = self.remote_field.get_accessor_name()
# Since fields cannot share the same rel object:
self.remote_field = copy.copy(self.remote_field)
Expand Down
2 changes: 1 addition & 1 deletion modeltranslation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def autodiscover():

mods = [(app_config.name, app_config.module) for app_config in apps.get_app_configs()]

for (app, mod) in mods:
for app, mod in mods:
# Attempt to import the app's translation module.
module = '%s.translation' % app
before_import_registry = copy.copy(translator._registry)
Expand Down
1 change: 0 additions & 1 deletion modeltranslation/tests/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
9 changes: 6 additions & 3 deletions modeltranslation/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ def test_fallback_language(self):

# However, by default FALLBACK_LANGUAGES is set to DEFAULT_LANGUAGE
with default_fallback():

# No change here...
assert inst2.title == title_de

Expand Down Expand Up @@ -3013,9 +3012,13 @@ def test_values_with_expressions(self):
assert obj2['title'] == 'de'

# Values_list behave similarly
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [('en', str(id1))]
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [
('en', str(id1))
]
with override('de'):
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [('de', str(id1))]
assert list(manager.values_list('title', Cast("pk", output_field=CharField()))) == [
('de', str(id1))
]

def test_custom_manager(self):
"""Test if user-defined manager is still working"""
Expand Down

0 comments on commit f0fb6eb

Please sign in to comment.