Commit 01f049b0 authored by Birin Sanchez's avatar Birin Sanchez
Browse files

Allow to create more than 4 invitations if some of the invitations are


not consumed and expired.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent f15702d6
Pipeline #12275 passed with stage
in 39 seconds
......@@ -34,7 +34,11 @@ def userlimit(request):
# Prepare context variables for Group service
invitations = {'list': []}
inv_all = request.user.invitation_set.all()
invitations['full'] = len(inv_all) >= 4
used_inv = 0
for inv in inv_all:
if inv.consumed or (not inv.consumed and not inv.expired()):
used_inv += 1
invitations['full'] = used_inv >= 4
invitations['no_members'] = True
invitations['links_not_used'] = False
for inv in inv_all:
......@@ -100,8 +104,14 @@ def toggle_tunnel(request):
@login_required
def new_invitation(request):
if request.user.account_type == AccountType.GROUP:
invs_count = len(request.user.invitation_set.all())
if invs_count < 4:
all_invs = request.user.invitation_set.all()
# Counter for invitations consumed and not consumed but
# not expired
used = 0
for inv in all_invs:
if inv.consumed or (not inv.consumed and not inv.expired()):
used += 1
if used < 4:
new_inv = Invitation.create(request.user)
new_inv.save()
return HttpResponseRedirect(reverse('profile'))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment