creation of designer objects improved
This commit is contained in:
+12
-2
@@ -1,13 +1,14 @@
|
||||
from api import db
|
||||
from api.helpers import slugify
|
||||
|
||||
|
||||
class Designer(db.Model):
|
||||
__tablename__ = 'designers'
|
||||
|
||||
id = db.Column('designerid', db.Integer, primary_key=True)
|
||||
commission = db.Column(db.Integer(), nullable=False)
|
||||
commission_resale = db.Column(db.Integer(), nullable=False)
|
||||
currency = db.Column(db.String(3), nullable=False)
|
||||
designerid = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(100), nullable=False)
|
||||
no_follow = db.Column(db.Integer(), nullable=True, default=0)
|
||||
path = db.Column(db.String(100), nullable=False)
|
||||
@@ -19,6 +20,15 @@ class Designer(db.Model):
|
||||
visible_productpage = db.Column(db.Integer(), nullable=False, default=1)
|
||||
visible_search = db.Column(db.Integer(), nullable=False, default=1)
|
||||
|
||||
def __init__(self, name, username, territory, currency):
|
||||
self.name = name
|
||||
self.username = username
|
||||
self.territory = territory
|
||||
self.currency = currency
|
||||
self.commission = 0
|
||||
self.commission_resale = 0
|
||||
self.path = slugify(name)
|
||||
|
||||
@property
|
||||
def send_to_bottom(self):
|
||||
if self.sort_desc:
|
||||
@@ -36,7 +46,7 @@ class Designer(db.Model):
|
||||
'commission': self.commission,
|
||||
'commission_resale': self.commission_resale,
|
||||
'currency': self.currency,
|
||||
'designerid': self.designerid,
|
||||
'designerid': self.id,
|
||||
'name': self.name,
|
||||
'no_follow': self.no_follow,
|
||||
'path': self.path,
|
||||
|
||||
Reference in New Issue
Block a user