Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invite_accepted signal not firing #116

Open
aaronkazah opened this issue Dec 16, 2018 · 7 comments
Open

invite_accepted signal not firing #116

aaronkazah opened this issue Dec 16, 2018 · 7 comments

Comments

@aaronkazah
Copy link
Contributor

aaronkazah commented Dec 16, 2018

The signal "invite_accepted" isn't firing even when using the examples provided in django-invitations signals file as shown below.

@receiver(invite_accepted, sender=auth.models.AnonymousUser)
def invite_accepted(sender, request, email, **kwargs):
    pass

This issue is caused is mainly caused because 'request' isn't being passed as an argument when the signal is called.

This procedure below

def accept_invitation(invitation, request, signal_sender):
    invitation.accepted = True
    invitation.save()
    invite_accepted.send(sender=signal_sender, email=invitation.email)

    get_invitations_adapter().add_message(
        request,
        messages.SUCCESS,
        'invitations/messages/invite_accepted.txt',
        {'email': invitation.email})

should be

def accept_invitation(invitation, request, signal_sender):
    invitation.accepted = True
    invitation.save()
    invite_accepted.send(sender=signal_sender, email=invitation.email, request=request)

    get_invitations_adapter().add_message(
        request,
        messages.SUCCESS,
        'invitations/messages/invite_accepted.txt',
        {'email': invitation.email})
@aaronkazah aaronkazah changed the title invite_accept signal not firing invite_accepted signal not firing Dec 16, 2018
@ShuklaMadhur
Copy link

Hi
Is this issue fixed? I am facing the same issue.
Thanks
Maddy

@aaronkazah
Copy link
Contributor Author

Hey @ShuklaMadhur you can go to my profile and pull my repo that has the fix. https://github.com/AaronKazah/django-invitations

or you can install it to your django project by running this
-e git+git://github.com/AaronKazah/django-invitations.git@master#egg=django-invitations

@ShuklaMadhur
Copy link

Hi @aaronkazah Thanks for your reply. Its still not working for me. (Nothing gets printed in my case )

@receiver(invite_accepted, sender=auth.models.AnonymousUser)
def invite_accepted(sender, request, email, **kwargs):
print('invitation accepted')

@aaronkazah
Copy link
Contributor Author

@ShuklaMadhur You don't need the sender anymore, since we're passing the request along with it.

Instead of:
@receiver(invite_accepted, sender=auth.models.AnonymousUser)
Try:
@receiver(invite_accepted)

@bee-keeper
Copy link
Member

@aaronkazah if you want to PR your changes, ideally with a test am happy to merge. Sorry have been busy with other stuff and not been a very active maintainer..

@ShuklaMadhur
Copy link

Thanks @aaronkazah it works now. :)

@ShuklaMadhur
Copy link

@aaronkazah @bee-keeper can I access the inviter in the invite-accepted ? the request.user is always anonymous. Basically I want to reward the inviter when the person he invited accepts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants