]>
git.datanom.net - pwp.git/blob - app/models.py
1 from config
import ADMINS
2 from enum
import IntEnum
4 #from flask_login import mixins
16 class User(DB
.baseorm
.BaseOrm
):
17 __tablename__
= 'user'
33 def email(self
, email
):
39 return self
.__username
42 def username(self
, username
):
43 self
.__username
= username
48 return self
.__password
51 def password(self
, password
):
52 self
.__password
= password
55 def __init__(self
, name
, email
, username
, password
):
60 self
.username
= username
61 self
.password
= password
63 def is_authenticated(self
):
69 def is_anonymous(self
):
73 return self
.email
in ADMINS
76 return '<User ID: %s Name: %s Email: %s username: %s>' % (self
.id, self
.name
, self
.email
, self
.username
)
78 class Portfolio(DB
.baseorm
.BaseOrm
):
79 __tablename__
= 'portfolio'
94 def public(self
, public
):
95 self
.__public
= public
102 def visible(self
, visible
):
103 self
.__visible
= visible
110 def user(self
, user
):
113 def __init__(self
, name
, user
):
119 if not isinstance(user
, User
):
120 raise Exception("{0}: Not a 'User'".format(user
))
123 def set_user_count(self
, usercount
):
124 self
.usercount
= usercount
127 return '<Portfolio Name: %s Owner: %s>' % (self
.name
, self
.user
)
129 class Album(DB
.baseorm
.BaseOrm
):
130 __tablename__
= 'album'
137 def name(self
, name
):
145 def public(self
, public
):
146 self
.__public
= public
150 return self
.__visible
153 def visible(self
, visible
):
154 self
.__visible
= visible
158 return self
.__portfolio
161 def portfolio(self
, portfolio
):
162 self
.__portfolio
= portfolio
164 def __init__(self
, name
, portfolio
):
170 if not isinstance(portfolio
, Portfolio
):
171 raise Exception("{0}: Not a 'Portfolio'".format(portfolio
))
172 self
.portfolio
= portfolio
174 def set_user_count(self
, usercount
):
175 self
.usercount
= usercount
178 return '<Album Name: %r Portfolio: %r>' % (self
.name
, self
.portfolio
)
180 class Photo(DB
.baseorm
.BaseOrm
):
181 __tablename__
= 'photo'
188 def name(self
, name
):
196 def public(self
, public
):
197 self
.__public
= public
201 return self
.__visible
204 def visible(self
, visible
):
205 self
.__visible
= visible
212 def album(self
, album
):
220 def file(self
, file):
228 def exif(self
, exif
):
236 def format(self
, format
):
237 self
.__format
= format
239 def __init__(self
, name
, album
):
245 if not isinstance(album
, Album
):
246 raise Exception("{0}: Not a 'Album'".format(album
))
250 self
.format
= Format
.raw
.value
253 return '<Photo Name: %r File: %r Format: %r Album: %r>' % (self
.name
, self
.file, self
.format
, self
.album
)
255 class AccessRight(DB
.baseorm
.BaseOrm
):
256 __tablename__
= 'accessright'
263 def perm(self
, perm
):
271 def user(self
, user
):
274 def __init__(self
, user
):
277 self
.perm
= Role
.read
.value
278 if not isinstance(user
, User
):
279 raise Exception("{0}: Not a 'User'".format(user
))
283 return '<AccessRight Right: %r User: %r>' % (self
.perm
, self
.user
)
285 #class MyAnonymous(mixins.AnonymousUserMixin):
287 # name = 'Anonymous User'
288 # email = 'no@email.com'
292 # def is_authenticated(self):
296 # def is_admin(self):
302 # def __repr__(self):
303 # return '<User Name: %r Email: %r username: %r>' % (self.name, self.email, self.username)
This page took 0.20783 seconds and 6 git commands to generate.