]>
git.datanom.net - wpp.git/blob - app/models.py
2 from config
import ADMINS
5 class Format(enum
.Enum
):
10 class Role(enum
.Enum
):
16 __tablename__
= 'user'
17 id = db
.Column(db
.Integer
, primary_key
=True, autoincrement
=True)
18 name
= db
.Column(db
.String(255))
19 email
= db
.Column(db
.String(255), index
=True, unique
=True)
20 username
= db
.Column(db
.String(255), index
=True, unique
=True)
21 password
= db
.Column(db
.String(255))
22 portfolios
= db
.relationship('Portfolio', backref
='owner', lazy
=True, cascade
='save-update, merge, delete, delete-orphan')
23 acl
= db
.relationship('AccessRight', backref
='user', lazy
=True)
26 def is_authenticated(self
):
34 def is_anonymous(self
):
39 return self
.email
in ADMINS
42 return str(self
.id) # python 3
45 return '<User Name: %r Email: %r username: %r>' % (self
.name
, self
.email
, self
.username
)
47 class Portfolio(db
.Model
):
48 __tablename__
= 'portfolio'
49 id = db
.Column(db
.Integer
, primary_key
=True, autoincrement
=True)
50 name
= db
.Column(db
.String(255))
51 user_id
= db
.Column(db
.ForeignKey('user.id', onupdate
='CASCADE', ondelete
='CASCADE'), nullable
=False)
52 albums
= db
.relationship('Album', backref
='portfolio', lazy
=True, cascade
='save-update, merge, delete, delete-orphan')
55 return '<Portfolio Name: %r Owner: %r>' % (self
.name
, self
.owner
)
57 class Album(db
.Model
):
58 __tablename__
= 'album'
59 id = db
.Column(db
.Integer
, primary_key
=True, autoincrement
=True)
60 name
= db
.Column(db
.String(255))
61 photos
= db
.relationship('Photo', backref
='album', lazy
=True, cascade
='save-update, merge, delete, delete-orphan')
62 portfolio_id
= db
.Column(db
.ForeignKey('portfolio.id', onupdate
='CASCADE', ondelete
='CASCADE'), nullable
=False)
65 return '<Album Name: %r Portfolio: %r>' % (self
.name
, self
.portfolio
)
67 class Photo(db
.Model
):
68 __tablename__
= 'photo'
69 id = db
.Column(db
.Integer
, primary_key
=True, autoincrement
=True)
70 file = db
.Column(db
.String(255))
71 name
= db
.Column(db
.String(255))
72 exif
= db
.Column(db
.Text
)
73 format
= db
.Column(db
.Enum(Format
))
74 sibling
= db
.Column(db
.ForeignKey('photo.id'))
75 album_id
= db
.Column(db
.ForeignKey('album.id', onupdate
='CASCADE', ondelete
='CASCADE'), nullable
=False)
78 return '<Photo Name: %r File: %r Format: %r Album: %r>' % (self
.name
, self
.file, self
.format
, self
.album
)
80 class AccessRight(db
.Model
):
81 __tablename__
= 'accessright'
82 id = db
.Column(db
.Integer
, primary_key
= True, autoincrement
=True)
83 right
= db
.Column(db
.Enum(Role
))
84 user_id
= db
.Column(db
.ForeignKey('user.id', onupdate
='CASCADE', ondelete
='CASCADE'), nullable
=False)
85 object = db
.Column(db
.Integer
)
88 return '<AccessRight Right: %r User: %r Object: %r>' % (self
.right
, self
.user
, self
.object)
This page took 0.148077 seconds and 6 git commands to generate.