<commit_before>from flask_wtf import Form
from wtforms import StringField, BooleanField, TextAreaField, RadioField, DecimalField, IntegerField, SelectField
from wtforms.validators import DataRequired, Length, Optional, Regexp

from .strong import *
from .models import User

class LoginForm(Form):
    openid = StringField('openid', validators=[DataRequired()])
    remember_me = BooleanField('remember_me', default=False)

class EditForm(Form):
    username = StringField('username', validators=[DataRequired(), Regexp('^\w+$')])
    about_me = TextAreaField('about_me', validators=[Length(min=0, max=140)])

    def __init__(self, original_username, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)
        self.original_username = original_username

    def validate(self):
        if not Form.validate(self):
            return False
        if self.username.data == self.original_username:
            return True
        user = User.query.filter_by(username=self.username.data).first()
        if user != None:
            self.username.errors.append('This username is already in use. Please choose another one.')
            return False
        return True

class WilksForm(Form):
    sex = RadioField('sex', choices=[('male','Male'), ('female','Female')], default='male', validators=[DataRequired()])
    units = RadioField('units', choices=[('lb','Pounds'), ('kg','Kilograms')], default='lb', validators=[DataRequired()])
    weight = DecimalField('weight', validators=[DataRequired()])
    squat = DecimalField('squat', validators=[Optional()])
    bench = DecimalField('bench', validators=[Optional()])
    deadlift = DecimalField('deadlift', validators=[Optional()])

class TrackSetForm(Form):
    bw = DecimalField('bw')
    lift = SelectField('lift', choices=[(choice, choice) for choice in lift_choices], validators=[DataRequired()])
    weight = DecimalField('weight', validators=[DataRequired()])<commit_msg>added min/max username length<commit_after>from flask_wtf import Form
from wtforms import StringField, BooleanField, TextAreaField, RadioField, DecimalField, IntegerField, SelectField
from wtforms.validators import DataRequired, Length, Optional, Regexp

from .strong import *
from .models import User

class LoginForm(Form):
    openid = StringField('openid', validators=[DataRequired()])
    remember_me = BooleanField('remember_me', default=False)

class EditForm(Form):
    username = StringField('username', validators=[Length(min=3, max=64), DataRequired(), Regexp('^\w+$')])
    about_me = TextAreaField('about_me', validators=[Length(min=0, max=140)])

    def __init__(self, original_username, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)
        self.original_username = original_username

    def validate(self):
        if not Form.validate(self):
            return False
        if self.username.data == self.original_username:
            return True
        user = User.query.filter_by(username=self.username.data).first()
        if user != None:
            self.username.errors.append('This username is already in use. Please choose another one.')
            return False
        return True

class WilksForm(Form):
    sex = RadioField('sex', choices=[('male','Male'), ('female','Female')], default='male', validators=[DataRequired()])
    units = RadioField('units', choices=[('lb','Pounds'), ('kg','Kilograms')], default='lb', validators=[DataRequired()])
    weight = DecimalField('weight', validators=[DataRequired()])
    squat = DecimalField('squat', validators=[Optional()])
    bench = DecimalField('bench', validators=[Optional()])
    deadlift = DecimalField('deadlift', validators=[Optional()])

class TrackSetForm(Form):
    bw = DecimalField('bw')
    lift = SelectField('lift', choices=[(choice, choice) for choice in lift_choices], validators=[DataRequired()])
    weight = DecimalField('weight', validators=[DataRequired()])
{'fraction_non_alphanumeric': 0.14519009951518244, 'fraction_numerical': 0.0028068384792038787, 'mean_word_length': 4.756240822320118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6557519', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1081, 'n_words': 262}