class RegisterForm(Form): """Register Form Class for creating an account in PYBOSSA.""" err_msg = lazy_gettext( "Full name must be between 3 and %(fullname)s " "characters long", fullname=USER_FULLNAME_MAX_LENGTH) fullname = TextField(lazy_gettext('Full name'), [ validators.Length(min=3, max=USER_FULLNAME_MAX_LENGTH, message=err_msg) ]) err_msg = lazy_gettext( "User name must be between 3 and %(username_length)s " "characters long", username_length=USER_NAME_MAX_LENGTH) err_msg_2 = lazy_gettext("The user name is already taken") name = TextField(lazy_gettext('User name'), [ validators.Length(min=3, max=USER_NAME_MAX_LENGTH, message=err_msg), pb_validator.NotAllowedChars(), pb_validator.Unique(user_repo.get_by, 'name', err_msg_2), pb_validator.ReservedName('account', current_app) ]) err_msg = lazy_gettext( "Email must be between 3 and %(email_length)s " "characters long", email_length=EMAIL_MAX_LENGTH) err_msg_2 = lazy_gettext("Email is already taken") email_addr = EmailField(lazy_gettext('Email Address'), [ validators.Length(min=3, max=EMAIL_MAX_LENGTH, message=err_msg), validators.Email(), pb_validator.UniqueCaseInsensitive(user_repo.search_by_email, 'email_addr', err_msg_2) ]) err_msg = lazy_gettext("Password cannot be empty") err_msg_2 = lazy_gettext("Passwords must match") if enable_strong_password: password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2), pb_validator.CheckPasswordStrength() ]) else: password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2) ]) confirm = PasswordField(lazy_gettext('Repeat Password')) project_slug = SelectMultipleField(lazy_gettext('Project'), choices=[]) consent = BooleanField(default='checked', false_values=("False", "false", '', '0', 0)) def generate_password(self): if self.data['password']: return password = util.generate_password() self.password.data = password self.confirm.data = password
class ProjectForm(Form): name = TextField(lazy_gettext('Name'), [ validators.Required(), pb_validator.Unique(project_repo.get_by, 'name', message=lazy_gettext("Name is already taken.")) ]) short_name = TextField(lazy_gettext('Short Name'), [ validators.Required(), pb_validator.NotAllowedChars(), pb_validator.Unique( project_repo.get_by, 'short_name', message=lazy_gettext("Short Name is already taken.")), pb_validator.ReservedName('project', current_app) ]) long_description = TextAreaField(lazy_gettext('Long Description'), [validators.Required()]) description = TextAreaField(lazy_gettext('Description'), [validators.Length(max=255)]) password = TextField(lazy_gettext('Password'), [ validators.Required(), pb_validator.CheckPasswordStrength(min_len=PROJECT_PWD_MIN_LEN, special=False) ])
class ProjectUpdateForm(ProjectForm): id = IntegerField(label=None, widget=HiddenInput()) description = TextAreaField(lazy_gettext('Description'), [ validators.Required( message=lazy_gettext("You must provide a description.")), validators.Length(max=255) ]) short_name = TextField(label=None, widget=HiddenInput()) long_description = TextAreaField(lazy_gettext('Long Description')) allow_anonymous_contributors = BooleanField( lazy_gettext('Allow Anonymous Contributors')) zip_download = BooleanField(lazy_gettext('Allow ZIP data download')) category_id = SelectField(lazy_gettext('Category'), coerce=int) hidden = BooleanField(lazy_gettext('Hide?')) email_notif = BooleanField(lazy_gettext('Email Notifications')) password = PasswordField( lazy_gettext('Password'), [ validators.Optional(), pb_validator.CheckPasswordStrength(min_len=PROJECT_PWD_MIN_LEN, special=False) ], render_kw={ 'placeholder': 'Minimum length {} characters, 1 uppercase, 1 lowercase and 1 numeric.' .format(PROJECT_PWD_MIN_LEN) }) webhook = TextField(lazy_gettext('Webhook'), [pb_validator.Webhook()]) sync_enabled = BooleanField(lazy_gettext('Enable Project Syncing'))
class ProjectUpdateForm(ProjectForm): id = IntegerField(label=None, widget=HiddenInput()) description = TextAreaField(lazy_gettext('Description'), [ validators.Required( message=lazy_gettext("You must provide a description.")), validators.Length(max=255) ]) long_description = TextAreaField(lazy_gettext('Long Description')) allow_anonymous_contributors = BooleanField( lazy_gettext('Allow Anonymous Contributors')) zip_download = BooleanField(lazy_gettext('Allow ZIP data download')) category_id = SelectField(lazy_gettext('Category'), coerce=int) hidden = BooleanField(lazy_gettext('Hide?')) email_notif = BooleanField(lazy_gettext('Email Notifications')) password = TextField(lazy_gettext('Password'), [ validators.Optional(), pb_validator.CheckPasswordStrength(min_len=PROJECT_PWD_MIN_LEN, special=False) ]) if data_access.data_access_levels: data_access = Select2Field( lazy_gettext('Access Level(s)'), [validators.Required()], choices=data_access.data_access_levels['valid_access_levels'], default=[]) webhook = TextField(lazy_gettext('Webhook'), [pb_validator.Webhook()]) sync_enabled = BooleanField(lazy_gettext('Enable Project Syncing'))
class ProjectCommonForm(Form): name = TextField(lazy_gettext('Name'), [validators.Required(), pb_validator.Unique(project_repo.get_by, 'name', message=lazy_gettext("Name is already taken."))]) short_name = TextField(lazy_gettext('Short Name'), [validators.Required(), pb_validator.NotAllowedChars(), pb_validator.Unique(project_repo.get_by, 'short_name', message=lazy_gettext( "Short Name is already taken.")), pb_validator.ReservedName('project', current_app)]) password = PasswordField( lazy_gettext('Password'), [validators.Required(), pb_validator.CheckPasswordStrength( min_len=PROJECT_PWD_MIN_LEN, special=False)], render_kw={'placeholder': 'Minimum length {} characters, 1 uppercase, 1 lowercase and 1 numeric.'.format(PROJECT_PWD_MIN_LEN)}) input_data_class = SelectFieldWithProps(lazy_gettext('Input Data Classification'), validators=[validators.Required()], choices=[], default='') output_data_class = SelectFieldWithProps(lazy_gettext('Output Data Classification'), validators=[validators.Required()], choices=[], default='') def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs)
class RegisterForm(Form): """Register Form Class for creating an account in PYBOSSA.""" err_msg = lazy_gettext( "Full name must be between 3 and %(fullname)s " "characters long", fullname=USER_FULLNAME_MAX_LENGTH) fullname = TextField(lazy_gettext('Full name'), [ validators.Length(min=3, max=USER_FULLNAME_MAX_LENGTH, message=err_msg) ]) err_msg = lazy_gettext( "User name must be between 3 and %(username_length)s " "characters long", username_length=USER_NAME_MAX_LENGTH) err_msg_2 = lazy_gettext("The user name is already taken") name = TextField(lazy_gettext('User name'), [ validators.Length(min=3, max=USER_NAME_MAX_LENGTH, message=err_msg), pb_validator.NotAllowedChars(), pb_validator.Unique(user_repo.get_by, 'name', err_msg_2), pb_validator.ReservedName('account', current_app) ]) err_msg = lazy_gettext( "Email must be between 3 and %(email_length)s " "characters long", email_length=EMAIL_MAX_LENGTH) err_msg_2 = lazy_gettext("Email is already taken") email_addr = EmailField(lazy_gettext('Email Address'), [ validators.Length(min=3, max=EMAIL_MAX_LENGTH, message=err_msg), validators.Email(), pb_validator.Unique(user_repo.get_by, 'email_addr', err_msg_2) ]) err_msg = lazy_gettext("Password cannot be empty") err_msg_2 = lazy_gettext("Passwords must match") if enable_strong_password: password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2), pb_validator.CheckPasswordStrength() ]) else: password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2) ]) confirm = PasswordField(lazy_gettext('Repeat Password')) consent = BooleanField(false_values=("False", "false", '', '0', 0))
class ResetPasswordForm(Form): """Class for resetting user's password.""" err_msg = lazy_gettext("Password cannot be empty") err_msg_2 = lazy_gettext("Passwords must match") if enable_strong_password: new_password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), pb_validator.CheckPasswordStrength(), validators.EqualTo('confirm', err_msg_2) ]) else: new_password = PasswordField(lazy_gettext('New Password'), [ validators.Required(err_msg), validators.EqualTo('confirm', err_msg_2) ]) confirm = PasswordField(lazy_gettext('Repeat Password'))
class ProjectForm(Form): name = TextField(lazy_gettext('Name'), [ validators.Required(), pb_validator.Unique(project_repo.get_by, 'name', message=lazy_gettext("Name is already taken.")) ]) short_name = TextField(lazy_gettext('Short Name'), [ validators.Required(), pb_validator.NotAllowedChars(), pb_validator.Unique( project_repo.get_by, 'short_name', message=lazy_gettext("Short Name is already taken.")), pb_validator.ReservedName('project', current_app) ]) long_description = TextAreaField(lazy_gettext('Long Description'), [validators.Required()]) description = TextAreaField(lazy_gettext('Description'), [validators.Length(max=255)]) password = TextField(lazy_gettext('Password'), [ validators.Required(), pb_validator.CheckPasswordStrength(min_len=PROJECT_PWD_MIN_LEN, special=False) ]) product = SelectField(lazy_gettext('Product'), [validators.Required()], choices=[("", "")], default="") subproduct = SelectField(lazy_gettext('Subproduct'), [validators.Required()], choices=[("", "")], default="") kpi = DecimalField(lazy_gettext( 'KPI - Estimate of amount of minutes to complete one task (0.1-120)'), places=2, validators=[ validators.Required(), NumberRange(Decimal('0.1'), 120) ]) def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs)
class ProjectUpdateForm(ProjectForm): id = IntegerField(label=None, widget=HiddenInput()) description = TextAreaField(lazy_gettext('Description'), [ validators.Required( message=lazy_gettext("You must provide a description.")), validators.Length(max=255) ]) short_name = TextField(label=None, widget=HiddenInput()) long_description = TextAreaField(lazy_gettext('Long Description')) allow_anonymous_contributors = BooleanField( lazy_gettext('Allow Anonymous Contributors')) zip_download = BooleanField(lazy_gettext('Allow ZIP data download')) category_id = SelectField(lazy_gettext('Category'), coerce=int) hidden = BooleanField(lazy_gettext('Hide?')) email_notif = BooleanField(lazy_gettext('Email Notifications')) password = TextField(lazy_gettext('Password'), [ validators.Optional(), pb_validator.CheckPasswordStrength(min_len=PROJECT_PWD_MIN_LEN, special=False) ]) webhook = TextField(lazy_gettext('Webhook'), [pb_validator.Webhook()]) sync_enabled = BooleanField(lazy_gettext('Enable Project Syncing')) dataset_description = TextAreaField(lazy_gettext('Dataset Description')) provider = SelectField(lazy_gettext('Annotation Provider'), choices=[(None, "NONE")] + [(x, x) for x in [ "PERSONNEL", "VENDOR", "CONTINGENT_WORKER", "FREELANCER", "CROWDSOURCING_WORKER" ]], coerce=lambda x: None if x == "None" else x) restrictions_and_permissioning = TextAreaField( lazy_gettext('Restrictions & Permissioning')) store_pvf = TextField(lazy_gettext('Annotation Store PVF')) sampling_method = TextField(lazy_gettext('Sampling Method')) sampling_script = TextField(lazy_gettext('Sampling Script Link')) label_aggregation_strategy = TextField( lazy_gettext('Label Aggregation Strategy')) task_input_schema = TextAreaField(lazy_gettext('Task Input Schema')) task_output_schema = TextAreaField(lazy_gettext('Task Output Schema'))
class ProjectUpdateForm(ProjectForm): id = IntegerField(label=None, widget=HiddenInput()) description = TextAreaField(lazy_gettext('Description'), [validators.Required( message=lazy_gettext( "You must provide a description.")), validators.Length(max=255)]) long_description = TextAreaField(lazy_gettext('Long Description')) allow_anonymous_contributors = BooleanField(lazy_gettext('Allow Anonymous Contributors')) category_id = SelectField(lazy_gettext('Category'), coerce=int) hidden = BooleanField(lazy_gettext('Hide?')) email_notif = BooleanField(lazy_gettext('Email Notifications')) password = TextField( lazy_gettext('Password'), [validators.Optional(), pb_validator.CheckPasswordStrength( min_len=PROJECT_PWD_MIN_LEN, special=False)]) webhook = TextField(lazy_gettext('Webhook'), [pb_validator.Webhook()]) sync_target_url = TextField(lazy_gettext('Target URL')) sync_target_key = TextField(lazy_gettext('API Key')) sync_enabled = BooleanField(lazy_gettext('Enable Project Syncing'))