Esempio n. 1
0
 def post(self, request):
     """ send out an invite """
     invite_request = get_object_or_404(
         models.InviteRequest, id=request.POST.get("invite-request"))
     # only create a new invite if one doesn't exist already (resending)
     if not invite_request.invite:
         invite_request.invite = models.SiteInvite.objects.create(
             use_limit=1,
             user=request.user,
         )
         invite_request.save()
     emailing.invite_email(invite_request)
     return redirect("settings-invite-requests")
Esempio n. 2
0
    def test_invite_email(self, email_mock):
        """load the invite email"""
        invite_request = models.InviteRequest.objects.create(
            email="*****@*****.**",
            invite=models.SiteInvite.objects.create(user=self.local_user),
        )

        emailing.invite_email(invite_request)

        self.assertEqual(email_mock.call_count, 1)
        args = email_mock.call_args[0]
        self.assertEqual(args[0], "*****@*****.**")
        self.assertEqual(args[1], "You're invited to join BookWyrm!")
        self.assertEqual(len(args), 4)
Esempio n. 3
0
    def post(self, request):
        """ send out an invite """
        invite_request = get_object_or_404(
            models.InviteRequest, id=request.POST.get("invite-request")
        )
        # allows re-sending invites
        invite_request.invite, _ = models.SiteInvite.objects.get_or_create(
            use_limit=1,
            user=request.user,
        )

        invite_request.save()
        emailing.invite_email(invite_request)
        return redirect("settings-invite-requests")
Esempio n. 4
0
 def post(self, request):
     """send out an invite"""
     invite_request = get_object_or_404(
         models.InviteRequest, id=request.POST.get("invite-request"))
     # only create a new invite if one doesn't exist already (resending)
     if not invite_request.invite:
         invite_request.invite = models.SiteInvite.objects.create(
             use_limit=1,
             user=request.user,
         )
         invite_request.save()
     emailing.invite_email(invite_request)
     # pylint: disable=consider-using-f-string
     return redirect("{:s}?{:s}".format(reverse("settings-invite-requests"),
                                        urlencode(request.GET.dict())))