Compare commits
1 commit
master
...
feature/sl
Author | SHA1 | Date | |
---|---|---|---|
|
563f9b84a2 |
1 changed files with 8 additions and 0 deletions
|
@ -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(
|
||||||
|
|
Loading…
Reference in a new issue