Skip to content

Commit

Permalink
Temp solution for creating membership from invitation because of all …
Browse files Browse the repository at this point in the history
…members group doesnt exists.
  • Loading branch information
yaniv14 committed Jun 7, 2016
1 parent f7a3cb9 commit 2cbdd09
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,20 @@ def post(self, request, *args, **kwargs):
def create_membership(user):
# Create selected membership type
for group in i.groups.all():
try:
m = Membership.objects.get(user=user, community=i.community, group_name=group)
except Membership.DoesNotExist:
m = Membership.objects.create(user=user, community=i.community,
group_name=group,
invited_by=i.created_by)
obj, created = Membership.objects.get_or_create(user=user, community=i.community, group_name=group)
if created:
obj.invited_by = i.created_by
obj.save()
# Create all member group
member_group = CommunityGroup.objects.get(community=i.community, title=gettext('member'))
# TODO: Fix this process. !!!!!
try:
m = Membership.objects.get(user=user, community=i.community, group_name=member_group)
except Membership.DoesNotExist:
m = Membership.objects.create(user=user, community=i.community, group_name=member_group,
invited_by=i.created_by)
member_group = CommunityGroup.objects.get(community=i.community, title=gettext('member'))
obj, created = Membership.objects.get_or_create(user=user, community=i.community, group_name=member_group)
if created:
obj.invited_by = i.created_by
obj.save()
except:
pass
i.delete()
return m

Expand Down

0 comments on commit 2cbdd09

Please sign in to comment.