def create_account(self, payload):
     return Account.objects.create(
         account_type=payload['account_type'],
         start_date=payload['start_date'],
         end_date=payload['end_date'],
         code=codes.generate()
     )
Example #2
0
 def create_account(self, payload):
     return Account.objects.create(
         account_type=payload['account_type'],
         start_date=payload['start_date'],
         end_date=payload['end_date'],
         code=codes.generate()
     )
def create_giftcard(order_number, user, amount):
    source = core.paid_source_account()
    code = codes.generate()
    destination = Account.objects.create(
        code=code
    )
    facade.transfer(source, destination, amount, user,
                    "Create new account")
Example #4
0
 def save(self, *args, **kwargs):
     kwargs['commit'] = False
     account = super(NewAccountForm, self).save(*args, **kwargs)
     account.code = codes.generate()
     if hasattr(self, '_account_type'):
         account.account_type = self._account_type
     account.save()
     return account
Example #5
0
 def save(self, *args, **kwargs):
     kwargs['commit'] = False
     account = super(NewAccountForm, self).save(*args, **kwargs)
     account.code = codes.generate()
     if hasattr(self, '_account_type'):
         account.account_type = self._account_type
     account.save()
     return account
 def test_create_codes_of_correct_length(self):
     for size in [4, 6, 8]:
         code = codes.generate(size=size)
         self.assertTrue(size, len(code))
 def test_can_create_codes_using_custom_character_set(self):
     chars = string.ascii_uppercase
     code = codes.generate(chars=chars)
     for char in code:
         self.assertTrue(char in chars)
 def test_create_codes_using_correct_default_character_set(self):
     code = codes.generate()
     chars = string.ascii_uppercase + string.digits
     for char in code:
         self.assertTrue(char in chars)
 def test_create_codes_of_correct_length(self):
     for size in [4, 6, 8]:
         code = codes.generate(size=size)
         self.assertTrue(size, len(code))
 def test_can_create_codes_using_custom_character_set(self):
     chars = string.ascii_uppercase
     code = codes.generate(chars=chars)
     for char in code:
         self.assertTrue(char in chars)
 def test_create_codes_using_correct_default_character_set(self):
     code = codes.generate()
     chars = string.ascii_uppercase + string.digits
     for char in code:
         self.assertTrue(char in chars)
def create_giftcard(order_number, user, amount):
    source = core.paid_source_account()
    code = codes.generate()
    destination = Account.objects.create(code=code)
    facade.transfer(source, destination, amount, user, "Create new account")