Fix flake8 error

This commit is contained in:
Bas Peschier 2013-10-29 12:15:11 +01:00
parent 2379458f6d
commit d7ef747db4

View file

@ -34,6 +34,7 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
elif self.fields:
return [(None, {'fields': self.replace_orig_field(self.fields)})]
return None
declared_fieldsets = property(_declared_fieldsets)
def formfield_for_dbfield(self, db_field, **kwargs):
@ -69,7 +70,7 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
# widget.
css_classes.append('mt-default')
if (orig_formfield.required or self._orig_was_required.get(
'%s.%s' % (orig_field.model._meta, orig_field.name))):
'%s.%s' % (orig_field.model._meta, orig_field.name))):
# In case the original form field was required, make the
# default translation field required instead.
orig_formfield.required = False
@ -121,7 +122,7 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
index = option_new.index(opt)
option_new[index:index + 1] = get_translation_fields(opt)
elif isinstance(opt, (tuple, list)) and (
[o for o in opt if o in self.trans_opts.fields]):
[o for o in opt if o in self.trans_opts.fields]):
index = option_new.index(opt)
option_new[index:index + 1] = self.replace_orig_field(opt)
option = option_new
@ -139,10 +140,12 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
def _patch_prepopulated_fields(self):
def localize(sources, lang):
"Append lang suffix (if applicable) to field list"
def append_lang(source):
if source in self.trans_opts.fields:
return build_localized_fieldname(source, lang)
return source
return tuple(map(append_lang, sources))
prepopulated_fields = {}
@ -169,7 +172,7 @@ class TranslationBaseModelAdmin(BaseModelAdmin):
# Take the custom ModelForm's Meta.exclude into account only if the
# ModelAdmin doesn't define its own.
exclude.extend(self.form._meta.exclude)
# If exclude is an empty list we pass None to be consistant with the
# If exclude is an empty list we pass None to be consistant with the
# default on modelform_factory
exclude = self.replace_orig_field(exclude) or None
exclude = self._exclude_original_fields(exclude)
@ -295,7 +298,8 @@ class TranslationAdmin(TranslationBaseModelAdmin, admin.ModelAdmin):
if self.declared_fieldsets:
return self._do_get_fieldsets_pre_form_or_formset()
return self._group_fieldsets(
self._do_get_fieldsets_post_form_or_formset(request, self.get_form(request, obj, fields=None), obj))
self._do_get_fieldsets_post_form_or_formset(
request, self.get_form(request, obj, fields=None), obj))
class TranslationInlineModelAdmin(TranslationBaseModelAdmin, InlineModelAdmin):
@ -339,6 +343,8 @@ class TabbedDjangoJqueryTranslationAdmin(TranslationAdmin):
css = {
'all': ('modeltranslation/css/tabbed_translation_fields.css',),
}
TabbedTranslationAdmin = TabbedDjangoJqueryTranslationAdmin