2017-06-04 11:22:59 -04:00
import string
import random
2017-07-24 06:33:33 -04:00
from . . import db
from . . models import User , Role , Region
2017-06-04 11:22:59 -04:00
from flask_wtf import FlaskForm , RecaptchaField
from wtforms import StringField , PasswordField , BooleanField , SubmitField , SelectField , DecimalField
from wtforms import validators , ValidationError
2018-02-07 11:19:55 -05:00
from wtforms . fields . html5 import EmailField , DecimalRangeField
class OrderForm ( FlaskForm ) :
cpu = DecimalRangeField ( ' Processor Cores ' , default = 2 )
memory = DecimalRangeField ( ' Memory ' , default = 512 )
storage = DecimalRangeField ( ' Storage ' , default = 20 )
alias = StringField ( ' Machine Alias: ' , [ validators . Regexp ( message = ' ex.: myservice1.com, myservice2.local ' , regex = ' ^[a-zA-Z0-9][a-zA-Z0-9-_] { 0,61}[a-zA-Z0-9] { 0,1} \ .([a-zA-Z] { 1,6}|[a-zA-Z0-9-] { 1,30} \ .[a-zA-Z] { 2,3})$ ' ) , validators . Length ( 6 , 64 ) ] )
submit = SubmitField ( ' Create ' )
2017-06-04 11:22:59 -04:00
class ChargeForm ( FlaskForm ) :
2017-06-06 09:49:32 -04:00
amount = DecimalField ( ' Стойност: ' , [ validators . DataRequired ( ) , validators . NumberRange ( min = 1 , max = 500 ) ] )
2017-06-04 11:22:59 -04:00
submit = SubmitField ( ' Зареди ' )
2017-07-24 06:33:33 -04:00
class Addr2PoolForm ( FlaskForm ) :
#regions = Region.query.all()
#region_choices = []
#for region in regions:
# region_choices.expand((region.pid, str(region.description)))
region_choices = [ ( 1 , ' Plovdiv, Bulgaria ' ) ]
region = SelectField ( ' Region ' , choices = region_choices , coerce = int )
2018-03-15 19:14:48 -04:00
ip = StringField ( ' IP Address: ' , [ validators . DataRequired ( ) , validators . Regexp ( message = ' 172.16.0.1 ' , regex = ' ^ \ d { 1,3} \ . \ d { 1,3} \ . \ d { 1,3} \ . \ d { 1,3}$ ' ) ] )
rdns = StringField ( ' Reverse DNS: ' , [ validators . Regexp ( message = ' must be fqdn ' , regex = ' ^[a-zA-Z0-9][a-zA-Z0-9-_] { 0,61}[a-zA-Z0-9] { 0,1} \ .([a-zA-Z] { 1,6}|[a-zA-Z0-9-] { 1,30} \ .[a-zA-Z] { 2,3})$ ' ) ] )
2017-07-24 06:33:33 -04:00
reserved = BooleanField ( ' Reserved: ' )
submit = SubmitField ( ' Add IP ' )