Example #1
0
 def create(cls, **kwargs):
     email, code = kwargs.get('email'), kwargs.get('code')
     if kwargs.get('check_exists', True) and cls.exists(code=code, email=email):
         raise cls.AlreadyExists()
     expiry = timezone.now() + datetime.timedelta(hours=kwargs.get('expiry', 24))
     if not code:
         code = random_token([email]) if email else random_token()
     params = {
         'code': code,
         'max_uses': kwargs.get('max_uses', 0),
         'expiry': expiry,
         'inviter': kwargs.get('inviter'),
         'notes': kwargs.get('notes', '')
     }
     if email:
         params['email'] = email
     return cls(**params)
Example #2
0
 def create(cls, **kwargs):
     email, code = kwargs.get("email"), kwargs.get("code")
     if kwargs.get("check_exists", True) and cls.exists(code=code, email=email):
         raise cls.AlreadyExists()
     expiry = timezone.now() + datetime.timedelta(hours=kwargs.get("expiry", 24))
     if not code:
         code = random_token([email]) if email else random_token()
     params = {
         "code": code,
         "max_uses": kwargs.get("max_uses", 0),
         "expiry": expiry,
         "inviter": kwargs.get("inviter"),
         "notes": kwargs.get("notes", "")
     }
     if email:
         params["email"] = email
     return cls(**params)
Example #3
0
 def create(cls, **kwargs):
     email, code = kwargs.get("email"), kwargs.get("code")
     if kwargs.get("check_exists", True) and cls.exists(code=code, email=email):
         raise cls.AlreadyExists()
     expiry = timezone.now() + datetime.timedelta(hours=kwargs.get("expiry", 24))
     if not code:
         code = random_token([email]) if email else random_token()
     params = {
         "code": code,
         "max_uses": kwargs.get("max_uses", 0),
         "expiry": expiry,
         "inviter": kwargs.get("inviter"),
         "notes": kwargs.get("notes", "")
     }
     if email:
         params["email"] = email
     return cls(**params)
Example #4
0
 def create(cls, **kwargs):
     email, code = kwargs.get('email'), kwargs.get('code')
     if kwargs.get('check_exists', True) and cls.exists(code=code,
                                                        email=email):
         raise cls.AlreadyExists()
     expiry = timezone.now() + datetime.timedelta(
         hours=kwargs.get('expiry', 24))
     if not code:
         code = random_token([email]) if email else random_token()
     params = {
         'code': code,
         'max_uses': kwargs.get('max_uses', 0),
         'expiry': expiry,
         'inviter': kwargs.get('inviter'),
         'notes': kwargs.get('notes', '')
     }
     if email:
         params['email'] = email
     return cls(**params)
Example #5
0
    def create(cls, email_address):
        email = email_address.user.email
        key = random_token([email])

        cls._default_manager.filter(email_address=email_address).delete()
        obj = cls._default_manager.create(email_address=email_address, confirmation_key=key)

        cls._default_manager.save_presend_email(obj, email)

        return obj
Example #6
0
    def create(cls, email_address):
        email = email_address.user.email
        key = random_token([email])

        cls._default_manager.filter(email_address=email_address).delete()
        obj = cls._default_manager.create(email_address=email_address,
                                          confirmation_key=key)

        cls._default_manager.save_presend_email(obj, email)

        return obj
Example #7
0
    def create(cls, request=None, **kwargs):
        # Check if a similar request already exists before proceeding
        try:
            _object = cls.objects.get(requester=kwargs['requester'],
                                      responder=kwargs['responder'],
                                      team=kwargs['team'])
            # If the request has expired keep going
            #if _object.key_expired():
            #    raise cls.DoesNotExist
            # If not, return None
            joinrequest = None
        except cls.DoesNotExist:
            kwargs['key'] = random_token()
            joinrequest = cls(**kwargs)
            joinrequest.save()

        return joinrequest
Example #8
0
 def create(cls, email_address):
     key = random_token([email_address.email])
     return cls._default_manager.create(email_address=email_address, key=key)
Example #9
0
 def create(cls, email_address):
     key = random_token([email_address.email])
     return cls._default_manager.create(email_address=email_address, key=key)
Example #10
0
 def create(cls, reddit_account):
     key = random_token([reddit_account.reddit_login])
     return cls._default_manager.create(reddit_account=reddit_account, key=key)