Skip to content

Commit

Permalink
Merge pull request #8 from amateja/feature/unification
Browse files Browse the repository at this point in the history
  • Loading branch information
amateja committed Jun 19, 2018
2 parents 8953f9a + 04349eb commit e25fab9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
17 changes: 0 additions & 17 deletions bitoptions/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,5 @@ def to_python(self, value):
value = super(BitOptionsField, self).to_python(value)
return BitOptions(self.options.flags, value)

def get_prep_value(self, value):
"""
Takes current value of the model's attribute, and the method returns
data in a format that has been prepared for use as a parameter in
a query.
"""
if isinstance(value, BitOptions):
return super(BitOptionsField, self).get_prep_value(value.value)
return super(BitOptionsField, self).get_prep_value(value)

def get_prep_lookup(self, lookup_type, value):
"""
Prepares value to the database prior to be used in a lookup.
"""
value = self.get_prep_value(value)
return super(BitOptionsField, self).get_prep_lookup(lookup_type, value)


SimpleBitOptionsField.register_lookup(BitwiseAnd)
3 changes: 3 additions & 0 deletions bitoptions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __iter__(self):
def __len__(self):
return len(self._options)

def __int__(self):
return self.value

def get_selected_values(self, selection=None):
"""
Returns a list of options for the given selection.
Expand Down

0 comments on commit e25fab9

Please sign in to comment.