Skip to content

Commit

Permalink
Overly optimistic content type queries (#633)
Browse files Browse the repository at this point in the history
* Overly optimistic content type queries

* Why not
  • Loading branch information
qeternity authored and ad-m committed Sep 4, 2019
1 parent c6901c1 commit fbbdf4e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ Authors ordered by first contribution
- George Karakostas <gckarakostas@gmail.com>
- Adam Dobrawy <guardian@jawnosc.tk>
- Jeff Hackshaw <intrepidevio@gmail.com>
- Chase Bennett <ch@se.gd>
3 changes: 1 addition & 2 deletions guardian/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def clean_orphan_obj_perms():
def get_obj_perms_model(obj, base_cls, generic_cls):
if isinstance(obj, Model):
obj = obj.__class__
ctype = get_content_type(obj)

fields = (f for f in obj._meta.get_fields()
if (f.one_to_many or f.one_to_one) and f.auto_created)
Expand All @@ -176,7 +175,7 @@ def get_obj_perms_model(obj, base_cls, generic_cls):
# make sure that content_object's content_type is same as
# the one of given obj
fk = model._meta.get_field('content_object')
if ctype == get_content_type(fk.remote_field.model):
if get_content_type(obj) == get_content_type(fk.remote_field.model):
return model
return generic_cls

Expand Down

0 comments on commit fbbdf4e

Please sign in to comment.