Page Menu
Home
Search
Configure Global Search
Log In
Files
F13095314
forms.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
2 KB
Subscribers
None
forms.py
View Options
from
flask_login
import
current_user
from
flask_wtf
import
Form
from
pillar.web
import
system_util
from
pillarsdk.users
import
User
from
wtforms
import
BooleanField
from
wtforms
import
PasswordField
from
wtforms
import
RadioField
from
wtforms
import
SelectMultipleField
from
wtforms
import
StringField
from
wtforms.validators
import
DataRequired
from
wtforms.validators
import
Length
from
wtforms.validators
import
Regexp
class
UserLoginForm
(
Form
):
username
=
StringField
(
'Username'
,
validators
=
[
DataRequired
()])
password
=
PasswordField
(
'Password'
,
validators
=
[
DataRequired
()])
remember_me
=
BooleanField
(
'Remember Me'
)
def
__init__
(
self
,
csrf_enabled
=
False
,
*
args
,
**
kwargs
):
super
(
UserLoginForm
,
self
)
.
__init__
(
csrf_enabled
=
False
,
*
args
,
**
kwargs
)
class
UserProfileForm
(
Form
):
full_name
=
StringField
(
'Full Name'
,
validators
=
[
DataRequired
(),
Length
(
min
=
3
,
max
=
128
,
message
=
"Min. 3 and max. 128 chars please"
)])
username
=
StringField
(
'Username'
,
validators
=
[
DataRequired
(),
Length
(
min
=
3
,
max
=
128
,
message
=
"Min. 3, max. 128 chars please"
),
Regexp
(
r'^[\w.@+-]+$'
,
message
=
"Please do not use spaces"
)])
def
__init__
(
self
,
csrf_enabled
=
False
,
*
args
,
**
kwargs
):
super
(
UserProfileForm
,
self
)
.
__init__
(
csrf_enabled
=
False
,
*
args
,
**
kwargs
)
def
validate
(
self
):
rv
=
Form
.
validate
(
self
)
if
not
rv
:
return
False
api
=
system_util
.
pillar_api
()
user
=
User
.
find
(
current_user
.
objectid
,
api
=
api
)
if
user
.
username
!=
self
.
username
.
data
:
username
=
User
.
find_first
(
{
'where'
:
'{"username": "
%s
"}'
%
self
.
username
.
data
},
api
=
api
)
if
username
:
self
.
username
.
errors
.
append
(
'Sorry, username already exists!'
)
return
False
self
.
user
=
user
return
True
class
UserSettingsEmailsForm
(
Form
):
choices
=
[
(
1
,
'Keep me updated with Blender Cloud news.'
),
(
0
,
'Do not mail me news update.'
)]
email_communications
=
RadioField
(
'Notifications'
,
choices
=
choices
,
coerce
=
int
)
class
UserEditForm
(
Form
):
role_choices
=
[(
'admin'
,
'admin'
),
(
'subscriber'
,
'subscriber'
),
(
'demo'
,
'demo'
)]
roles
=
SelectMultipleField
(
'Roles'
,
choices
=
role_choices
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sun, May 22, 7:51 PM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9d/95/3613c75423d6995550a2c4cd9870
Attached To
rPS Pillar
Event Timeline
Log In to Comment