Example #1
0
def accept_reject_invitation(request, invite_pk, action):
    """Accept or reject group invitation."""

    redeemer = request.user.userprofile
    invite = get_object_or_404(Invite, pk=invite_pk, redeemer=redeemer)
    if action == 'accept':
        if invite.group.terms:
            invite.group.add_member(redeemer, GroupMembership.PENDING_TERMS)
        else:
            invite.group.add_member(redeemer, GroupMembership.MEMBER)
        invite.accepted = True
        invite.save()
        notify_curators_invitation_accepted.delay(invite.pk)
    else:
        notify_curators_invitation_rejected.delay(redeemer.pk, invite.inviter.pk, invite.group.pk)
        invite.delete()

    return redirect(reverse('groups:show_group', args=[invite.group.url]))
Example #2
0
def accept_reject_invitation(request, invite_pk, action):
    """Accept or reject group invitation."""

    redeemer = request.user.userprofile
    invite = get_object_or_404(Invite, pk=invite_pk, redeemer=redeemer)
    if action == 'accept':
        if invite.group.terms:
            invite.group.add_member(redeemer, GroupMembership.PENDING_TERMS)
        else:
            invite.group.add_member(redeemer, GroupMembership.MEMBER)
        invite.accepted = True
        invite.save()
        notify_curators_invitation_accepted.delay(invite.pk)
    else:
        notify_curators_invitation_rejected.delay(redeemer.pk, invite.inviter.pk, invite.group.pk)
        invite.delete()

    return redirect(reverse('groups:show_group', args=[invite.group.url]))