Skip to content

Commit

Permalink
Stop overriding built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
macro1 committed Oct 31, 2014
1 parent bd0ed76 commit 9164eff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions simple_history/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def get_queryset(self):
return qs

if isinstance(self.instance._meta.pk, models.OneToOneField):
filter = {self.instance._meta.pk.name + "_id": self.instance.pk}
key_name = self.instance._meta.pk.name + "_id"
else:
filter = {self.instance._meta.pk.name: self.instance.pk}
return self.get_super_queryset().filter(**filter)
key_name = self.instance._meta.pk.name
return self.get_super_queryset().filter(**{key_name: self.instance.pk})

get_query_set = get_queryset

Expand Down
4 changes: 2 additions & 2 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ def post_save(self, instance, created, **kwargs):
def post_delete(self, instance, **kwargs):
self.create_historical_record(instance, '-')

def create_historical_record(self, instance, type):
def create_historical_record(self, instance, history_type):
history_date = getattr(instance, '_history_date', now())
history_user = self.get_history_user(instance)
manager = getattr(instance, self.manager_name)
attrs = {}
for field in instance._meta.fields:
attrs[field.attname] = getattr(instance, field.attname)
manager.create(history_date=history_date, history_type=type,
manager.create(history_date=history_date, history_type=history_type,
history_user=history_user, **attrs)

def get_history_user(self, instance):
Expand Down

0 comments on commit 9164eff

Please sign in to comment.