Skip to content

Commit

Permalink
style: nicer indent and shorten 81 col lines (PEP8)
Browse files Browse the repository at this point in the history
  • Loading branch information
asfaltboy committed Feb 22, 2015
1 parent 87208da commit 63231cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion advanced_filters/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def changelist_view(self, request, extra_context=None):
"""Add advanced_filters form to changelist context"""
if extra_context is None:
extra_context = {}
response = self.adv_filters_handle(request, extra_context=extra_context)
response = self.adv_filters_handle(request,
extra_context=extra_context)
if response:
return response
return super(AdminAdvancedFiltersMixin, self
Expand Down
14 changes: 8 additions & 6 deletions advanced_filters/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class AdvancedFilterQueryForm(CleanWhiteSpacesMixin, forms.Form):

field = forms.ChoiceField(required=True, widget=forms.Select(
attrs={'class': 'query-field'}))
operator = forms.ChoiceField(required=True, choices=OPERATORS,
initial="iexact", widget=forms.Select(
attrs={'class': 'query-operator'}))
operator = forms.ChoiceField(
required=True, choices=OPERATORS, initial="iexact",
widget=forms.Select(attrs={'class': 'query-operator'}))
value = VaryingTypeCharField(required=True, widget=forms.TextInput(
attrs={'class': 'query-value'}))
value_from = forms.DateTimeField(widget=forms.HiddenInput(
Expand All @@ -54,7 +54,9 @@ class AdvancedFilterQueryForm(CleanWhiteSpacesMixin, forms.Form):
negate = forms.BooleanField(initial=False, required=False)

def _build_field_choices(self, fields):
"""Iterate over passed model fields tuple and update initial choices."""
"""
Iterate over passed model fields tuple and update initial choices.
"""
return tuple(sorted(
[(fquery, capfirst(fname)) for fquery, fname in fields.items()],
key=lambda f: f[1].lower())
Expand Down Expand Up @@ -137,8 +139,8 @@ def set_range_value(self, data):
def clean(self):
cleaned_data = super(AdvancedFilterQueryForm, self).clean()
if cleaned_data['operator'] == "range":
if ('value_from' in cleaned_data
and 'value_to' in cleaned_data):
if ('value_from' in cleaned_data and
'value_to' in cleaned_data):
self.set_range_value(cleaned_data)
return cleaned_data

Expand Down

0 comments on commit 63231cd

Please sign in to comment.