Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor email confirmed receiver to model method

  • Loading branch information...
commit e63d7a8aebc3ebb6fd7a5a66e82aab935c7a1890 1 parent 5b48a7f
@paltman paltman authored
Showing with 15 additions and 8 deletions.
  1. +12 −1 kaleo/models.py
  2. +3 −7 kaleo/receivers.py
View
13 kaleo/models.py
@@ -6,7 +6,7 @@
from account.models import SignupCode
-from kaleo.signals import invite_sent, invite_accepted
+from kaleo.signals import invite_sent, joined_independently, invite_accepted
DEFAULT_INVITE_EXPIRATION = getattr(settings, "KALEO_DEFAULT_EXPIRATION", 168) # 168 Hours = 7 Days
@@ -45,6 +45,17 @@ def accept(self, user):
self.save()
self.from_user.invitationstat.increment_accepted()
invite_accepted.send(sender=JoinInvitation, invitation=self)
+
+ @classmethod
+ def process_independent_joins(cls, user, email):
+ invites = cls.objects.filter(
+ to_user__isnull=True,
+ signup_code__email=email
+ )
+ for invite in invites:
+ invite.to_user = user
+ invite.status = cls.STATUS_JOINED_INDEPENDENTLY
+ invite.save()
@classmethod
def invite(cls, from_user, to_email, message=None):
if not from_user.invitationstat.can_send():
View
10 kaleo/receivers.py
@@ -22,14 +22,10 @@ def handle_signup_code_used(sender, **kwargs):
@receiver(email_confirmed, sender=EmailConfirmation)
def handle_email_confirmed(sender, **kwargs):
email_address = kwargs.get("email_address")
- invites = JoinInvitation.objects.filter(
- to_user__isnull=True,
- signup_code__email=email_address.email
+ JoinInvitation.process_independent_joins(
+ user=email_address.user,
+ email=email_address.email
)
- for invite in invites:
- invite.to_user = email_address.user
- invite.status = JoinInvitation.STATUS_JOINED_INDEPENDENTLY
- invite.save()
@receiver(post_save, sender=User)
Please sign in to comment.
Something went wrong with that request. Please try again.