Compare commits

...

1 commit

Author SHA1 Message Date
redfast00
563f9b84a2
Add slug to order 2022-04-19 21:29:53 +02:00

View file

@ -2,6 +2,8 @@
import typing import typing
from datetime import datetime from datetime import datetime
from collections import defaultdict from collections import defaultdict
import secrets
import string
from utils import first from utils import first
from hlds.definitions import location_definitions from hlds.definitions import location_definitions
@ -18,9 +20,15 @@ class Order(db.Model):
starttime = db.Column(db.DateTime) starttime = db.Column(db.DateTime)
stoptime = db.Column(db.DateTime) stoptime = db.Column(db.DateTime)
public = db.Column(db.Boolean, default=True) public = db.Column(db.Boolean, default=True)
slug = db.Column(db.String(7))
items = db.relationship("OrderItem", backref="order", lazy="dynamic") items = db.relationship("OrderItem", backref="order", lazy="dynamic")
def __init__(self):
super().__init__()
alphabet = string.ascii_letters + string.digits
self.slug = ''.join(secrets.choice(alphabet) for i in range(7))
def __getattr__(self, name): def __getattr__(self, name):
if name == "location": if name == "location":
return first( return first(