Skip to content

Commit

Permalink
Fix in create_many for checking for duplicate shares.
Browse files Browse the repository at this point in the history
  • Loading branch information
troygrosfield committed Oct 28, 2014
1 parent 3577ae1 commit 3a57332
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django_shares/db/models/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class ShareManager(CommonManager, TokenManager):

"""Manager for the object share. This manager is used for the share
object (model) that either extends Share or implements AbstractShare.
"""
Expand Down Expand Up @@ -40,7 +41,8 @@ def create_for_user(self, created_user, for_user, shared_object=None,
'status': status})

if not content_type:
content_type = ContentType.objects.get_for_model(model=shared_object)
content_type = ContentType.objects.get_for_model(
model=shared_object)

return self.get_or_create(for_user=for_user,
content_type=content_type,
Expand Down Expand Up @@ -113,7 +115,7 @@ def create_many(self, objs, for_user, created_user, status=Status.PENDING,
for_user=for_user,
object_id__in=obj_ids,
content_type=content_type
).values_list('id', flat=True)
).values_list('object_id', flat=True)

shares = [self.model(for_user=for_user,
shared_object=obj,
Expand Down Expand Up @@ -213,6 +215,7 @@ def get_by_shared_object(self, obj, **kwargs):


class SharedObjectManager(BaseManager):

"""Manager for the object being shared. This likely means you have some
type of relation to shared objects. The models will likely have something
like:
Expand Down

0 comments on commit 3a57332

Please sign in to comment.