commit
10327941d2
1 changed files with 4 additions and 3 deletions
|
@ -11,11 +11,12 @@ from utils import first
|
||||||
from .database import db
|
from .database import db
|
||||||
from .user import User
|
from .user import User
|
||||||
|
|
||||||
|
BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||||
|
|
||||||
def generate_slug():
|
def generate_slug():
|
||||||
alphabet = string.ascii_letters + string.digits
|
secret = ''.join(secrets.choice(BASE58_ALPHABET) for i in range(7))
|
||||||
secret = ''.join(secrets.choice(alphabet) for i in range(7))
|
|
||||||
while Order.query.filter(Order.slug == secret).first() is not None:
|
while Order.query.filter(Order.slug == secret).first() is not None:
|
||||||
secret = ''.join(secrets.choice(alphabet) for i in range(7))
|
secret = ''.join(secrets.choice(BASE58_ALPHABET) for i in range(7))
|
||||||
return secret
|
return secret
|
||||||
|
|
||||||
class Order(db.Model):
|
class Order(db.Model):
|
||||||
|
|
Loading…
Reference in a new issue