Example #1
0
    def test_invitation_accepted(self):
        """Verify inviter whose invitee accepts invitation is notified"""
        inviter = self.make_user("inviter")
        InvitationStat.add_invites(2)

        invitee_email = "*****@*****.**"
        with self.login(inviter):
            post_data = {"email_address": invitee_email}
            self.post("pinax_invitations:invite", data=post_data)
            self.response_200()

        invitation = JoinInvitation.objects.first()
        self.assertEqual(len(mail.outbox), 1)
        self.assertIn(invitee_email, mail.outbox[0].to)
        mail.outbox.clear()

        # Accept the invitation
        invitee_username = "******"
        post_data = dict(
            username=invitee_username,
            password="******",
            password_confirm="notasecret",
            email=invitee_email,
        )

        url = reverse("account_signup")
        self.post(url + f"?code={invitation.signup_code.code}", data=post_data)

        self.assertEqual(len(mail.outbox), 1)
        self.assertIn(inviter.email, mail.outbox[0].to)
        self.assertIn(
            f"User \"{invitee_username}\" ({invitee_email}) joined this site at your invitation",
            mail.outbox[0].body)
Example #2
0
 def form_valid(self, formset):
     for form in formset:
         deactivate = form.cleaned_data["deactivate"]
         if deactivate is True:
             user = User.objects.get(email=form.cleaned_data["email"])
             AccountDeletion.mark(user)
     #Allocate an Enlingo Package Member quota to Customer
     InvitationStat.add_invites_to_user(self.request.user, +1)
     return super(MemberAccountDeactivate,self).form_valid(formset)
Example #3
0
 def form_valid(self, formset):
     for form in formset:
         deactivate = form.cleaned_data["deactivate"]
         if deactivate is True:
             user = User.objects.get(email=form.cleaned_data["email"])
             AccountDeletion.mark(user)
     #Allocate an Enlingo Package Member quota to Customer
     InvitationStat.add_invites_to_user(self.request.user, +1)
     return super(MemberAccountDeactivate, self).form_valid(formset)
    def handle(self, *args, **kwargs):
        if len(args) == 0:
            sys.exit("You must supply the number of invites as an argument.")

        try:
            num_of_invites = int(args[0])
        except ValueError:
            sys.exit("The argument for number of invites must be an integer.")

        InvitationStat.topoff(num_of_invites)
Example #5
0
 def test_invite_view(self):
     """verify no errors when posting good form data"""
     user = self.make_user("amy")
     InvitationStat.add_invites(2)
     post_data = {
         "email_address": "*****@*****.**"
     }
     with self.login(user):
         self.post("pinax_invitations:invite", data=post_data)
         self.response_200()
Example #6
0
 def update_enlingo_package_customer(self, form, profile, package_object):
             #Create Enlingo Premium Member Package Account
     enlingomember, created = EnlingoPackageCustomer.objects.get_or_create(packadmin_id=profile.pk,
                                                                        defaults={'package_id': package_object.pk,
                                                                                  'autorecharge': form.cleaned_data["autorecharge"],
                                                                                  'schemeregister': form.cleaned_data["schemeregister"],
                                                                                  'customername': form.cleaned_data["companyname"],
                                                                                  'rechargeindicator': '10',
                                                                                  'creditbalance': package_object.credits,
                                                                                  'credits': package_object.credits,
                                                                                  'debits': '0'}) #, created is to allow get_or_create to unpack immediately, from stackoverflow
     invitations = package_object.useraccountlimit-1
     InvitationStat.add_invites_to_user(profile.user, invitations)
     return enlingomember
Example #7
0
    def test_already_invited(self):
        """Ensure form is not valid if invite has already been sent"""
        from_user = User.objects.create(username="******")
        to_user = User.objects.create(username="******", email="*****@*****.**")
        InvitationStat.add_invites(2)
        istat = from_user.invitationstat
        istat.refresh_from_db()

        # Create an existing invitation
        JoinInvitation.invite(from_user, to_user.email, send=False)

        # Attempt to invite same user again
        form_data = {
            "email_address": to_user.email
        }
        form = InviteForm(user=from_user, data=form_data)
        self.assertFalse(form.is_valid())
Example #8
0
 def update_enlingo_package_customer(self, form, profile, package_object):
     #Create Enlingo Premium Member Package Account
     enlingomember, created = EnlingoPackageCustomer.objects.get_or_create(
         packadmin_id=profile.pk,
         defaults={
             'package_id': package_object.pk,
             'autorecharge': form.cleaned_data["autorecharge"],
             'schemeregister': form.cleaned_data["schemeregister"],
             'customername': form.cleaned_data["companyname"],
             'rechargeindicator': '10',
             'creditbalance': package_object.credits,
             'credits': package_object.credits,
             'debits': '0'
         }
     )  #, created is to allow get_or_create to unpack immediately, from stackoverflow
     invitations = package_object.useraccountlimit - 1
     InvitationStat.add_invites_to_user(profile.user, invitations)
     return enlingomember
 def handle(self, *args, **options):
     InvitationStat.topoff(options['num_invites'])
Example #10
0
 def handle(self, *args, **options):
     InvitationStat.add_invites(options['num_invites'])
Example #11
0
 def handle(self, *args, **options):
     InvitationStat.add_invites(options["num_invites"])
Example #12
0
 def handle(self, *args, **options):
     InvitationStat.topoff(options["num_invites"])