class JenkinsConfigForm(wtf.Form): print_started = wtf.BooleanField( 'Print Started', validators=[wtf.Optional()], default=False, description=('If checked, sends a message for every started job.')) print_completed = wtf.BooleanField( 'Print Completed', validators=[wtf.Optional()], default=False, description=('If checked, sends a message for every completed job.')) print_finished = wtf.BooleanField( 'Print Finished', validators=[wtf.Optional()], default=True, description=('If checked, sends a message for every finished job.')) omit_phase = wtf.BooleanField( 'Omit Phase', validators=[wtf.Optional()], default=True, description=( 'If checked, does not add the job\'s current phase to the message. ' 'Recommended if only one of the above is checked.')) use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.'))
class BitbucketConfigForm(wtf.Form): branches = wtf.TextField( 'Branches', validators=[wtf.Optional(), wtf.Length(max=1024)], description=( 'A comma-seperated list of branches to forward, or blank for all.' ' Ex: "master, dev"')) use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.')) show_branch = wtf.BooleanField( 'Show Branch Names', validators=[wtf.Optional()], default=True, description=('If checked, show the branch for a commit.')) show_raw_author = wtf.BooleanField( 'Show Raw Author', validators=[wtf.Optional()], default=False, description=( 'If checked, shows the raw author for a commit. For example,' ' <code>Tyler Kennedy <[email protected]></code> instead of' ' <code>TkTech</code>.'))
class UserUpdateForm(wtf.Form): username = wtf.StringField('Username', [wtf.validators.required(), wtf.validators.length(min=3)], filters=[util.email_filter], ) name = wtf.StringField('Name', [wtf.validators.required()], filters=[util.strip_filter], ) email = wtf.StringField('Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter], ) admin = wtf.BooleanField('Admin') active = wtf.BooleanField('Active') permissions = wtf.SelectMultipleField('Permissions', filters=[util.sort_filter], ) _permission_choices = set() def __init__(self, *args, **kwds): super(UserUpdateForm, self).__init__(*args, **kwds) self.permissions.choices = [ (p, p) for p in sorted(UserUpdateForm._permission_choices) ] @auth.permission_registered.connect def _permission_registered_callback(sender, permission): UserUpdateForm._permission_choices.add(permission)
class ElectionForm(wtf.Form): summary = wtf.TextField( 'Summary', [wtf.validators.Required(), wtf.validators.Length(max=150)]) alias = wtf.TextField('Alias', [ wtf.validators.Required(), wtf.validators.Length(max=100), wtf.validators.Regexp('[a-z0-9_-]+', message=('Alias may only contain lower case ' 'letters, numbers, hyphens and ' 'underscores.')), ]) description = wtf.TextAreaField('Description', [wtf.validators.Required()]) url = wtf.TextField('URL', [ wtf.validators.Required(), wtf.validators.URL(), wtf.validators.Length(max=250) ]) start_date = wtf.DateField('Start date', [wtf.validators.Required()]) end_date = wtf.DateField('End date', [wtf.validators.Required()]) number_elected = wtf.IntegerField( 'Number elected', [wtf.validators.Required(), wtf.validators.NumberRange(min=1)], default=1) candidates_are_fasusers = wtf.BooleanField('Candidates are FAS users?') frontpage = wtf.BooleanField('Show on front page?') embargoed = wtf.BooleanField('Embargo results?', default=True) def __init__(form, election_id=None, *args, **kwargs): super(ElectionForm, form).__init__(*args, **kwargs) form._election_id = election_id def validate_summary(form, field): check = Election.query.filter_by(summary=form.summary.data).all() if check: if not (form._election_id and form._election_id == check[0].id): raise wtf.ValidationError('There is already another election ' 'with this summary.') def validate_alias(form, field): if form.alias.data == 'new': raise wtf.ValidationError( flask.Markup('The alias cannot be ' '<code>new</code>.')) check = Election.query.filter_by(alias=form.alias.data).all() if check: if not (form._election_id and form._election_id == check[0].id): raise wtf.ValidationError('There is already another election ' 'with this alias.') def validate_end_date(form, field): if form.end_date.data <= form.start_date.data: raise wtf.ValidationError('End date must be later than ' 'start date.')
class EventForm(ContentForm): start_datetime = DateTimeField(u"Start date/time", validators=[wtf.Required()]) end_datetime = DateTimeField(u"End date/time", validators=[wtf.Required()]) timezone = wtf.SelectField(u"Timezone", choices=timezone_list, validators=[wtf.Required()]) location_name = wtf.TextField(u"Location name", validators=[wtf.Required()]) location_address = wtf.TextField(u"Address", validators=[wtf.Required()]) map = wtf.QuerySelectField(u"Map", get_label='title', allow_blank=True) mapmarker = wtf.TextField(u"Map marker") capacity = wtf.IntegerField(u"Capacity", validators=[wtf.Required()]) allow_waitlisting = wtf.BooleanField(u"Allow wait-listing if over capacity", default=False) allow_maybe = wtf.BooleanField(u"Allow “Maybe” responses", default=True) participant_list = wtf.QuerySelectField(u"Participant list", get_label='title', allow_blank=True) properties = DictField(u"Properties")
class JIRAConfigForm(wtf.Form): use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=('If checked, messages will include minor mIRC coloring.')) prefer_username = wtf.BooleanField( 'Prefer Usernames', validators=[wtf.Optional()], default=True, description=( 'If checked, prefer displaying JIRA account names instead of' ' full names.'))
class JenkinsConfigForm(wtf.Form): phase = wtf.SelectMultipleField('Phase', default=['finalized'], choices=[ ('started', 'Started'), ('completed', 'Completed'), ('finalized', 'Finalized') ], description=( 'Print messages for selected fields.' )) status = wtf.SelectMultipleField('Status', default=['success', 'unstable', 'failure'], choices=[ ('success', 'Success'), ('unstable', 'Unstable'), ('failure', 'Failure') ], description=( 'Print messages for selected fields.' )) use_colors = wtf.BooleanField('Use Colors', validators=[ wtf.Optional() ], default=True, description=( 'If checked, messages will include minor mIRC coloring.' ))
class SigninForm(wtf.Form): email = wtf.TextField('email', validators=[ wtf.Required(message=u'请填写电子邮件'), wtf.Email(message=u'无效的电子邮件') ]) password = wtf.PasswordField('password', validators=[ wtf.Required(message=u'请填写密码'), wtf.Length(min=5, max=20, message=u'密应应为5到20位字符') ]) next = wtf.HiddenField('next') remember = wtf.BooleanField('remember') openid_identifier = wtf.HiddenField('openid_identifier') openid_provider = wtf.HiddenField('openid_provider') def __init__(self, *args, **kargs): wtf.Form.__init__(self, *args, **kargs) self.user = None def validate(self): # 验证邮箱是否注册 if wtf.Form.validate(self): user = get_user(email=self.email.data) if not user: self.email.errors.append(u'该邮箱尚未在本站注册') elif not user.check_password(self.password.data): self.password.errors.append(u'密码错误') else: self.user = user return len(self.errors) == 0
class ConfigUpdateForm(wtf.Form): analytics_id = wtf.StringField('Tracking ID', filters=[util.strip_filter]) announcement_html = wtf.TextAreaField('Announcement HTML', filters=[util.strip_filter]) announcement_type = wtf.SelectField( 'Announcement Type', choices=[(t, t.title()) for t in model.Config.announcement_type._choices]) brand_name = wtf.StringField('Brand Name', [wtf.validators.required()], filters=[util.strip_filter]) facebook_app_id = wtf.StringField('Facebook App ID', filters=[util.strip_filter]) facebook_app_secret = wtf.StringField('Facebook App Secret', filters=[util.strip_filter]) feedback_email = wtf.StringField( 'Feedback Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter]) flask_secret_key = wtf.StringField('Secret Key', [wtf.validators.optional()], filters=[util.strip_filter]) notify_on_new_user = wtf.BooleanField( 'Send an email notification when a user signs up') twitter_consumer_key = wtf.StringField('Twitter Consumer Key', filters=[util.strip_filter]) twitter_consumer_secret = wtf.StringField('Twitter Consumer Secret', filters=[util.strip_filter])
class ChannelDetailsForm(wtf.Form): channel = wtf.TextField( 'Channel', validators=[wtf.Required(), wtf.Length(min=1, max=80)]) host = wtf.TextField( 'Host', validators=[wtf.Required(), wtf.Length(min=1, max=255)], default='chat.freenode.net') port = wtf.IntegerField('Port', validators=[wtf.NumberRange(1024, 66552)], default=6667) ssl = wtf.BooleanField('Use SSL', default=False) public = wtf.BooleanField( 'Public', default=True, description=('Allow others to see that this channel exists.'))
class GithubForm(wtf.Form): update_projects = wtf.BooleanField( 'Update Projects', default=True, description=( 'If a project already exists, update it instead of skipping it.')) set_hooks = wtf.BooleanField( 'Set Hooks', default=False, description= ('Sets up each project you select with Github web hooks, so that they' ' start recieving commits immediately.')) set_commits = wtf.BooleanField( 'Add to #commits', default=True, description=( 'Sets up public projects you select to broadcast to #commits' ' on chat.freenode.net as a default channel (you can always remove' ' it later).'))
class UserUpdateForm(wtf.Form): username = wtf.StringField( 'Username', [wtf.validators.required(), wtf.validators.length(min=3)], filters=[util.email_filter], ) name = wtf.StringField( 'Name', [wtf.validators.required()], filters=[util.strip_filter], ) email = wtf.StringField( 'Email', [wtf.validators.optional(), wtf.validators.email()], filters=[util.email_filter], ) admin = wtf.BooleanField('Admin') active = wtf.BooleanField('Active')
class PostForm(wtf.Form): title = wtf.TextField('Title', validators=[wtf.Required()], description='This will be shown on the list.') body = wtf.TextAreaField('Body', validators=[wtf.Required()], description='Markdown format enabled.') sticky = wtf.BooleanField('Sticky', description='Show this post always on top.') submit = wtf.SubmitField('Submit')
class ResourceForm(Form): """ Edit a resource provided by an application """ name = wtf.TextField( 'Resource name', validators=[wtf.Required()], description="Name of the resource as a single word in lower case. " "This is provided by applications as part of the scope " "when requesting access to a user's resources.") title = wtf.TextField( 'Title', validators=[wtf.Required()], description='Resource title that is displayed to users') description = wtf.TextAreaField( 'Description', description='An optional description of what the resource is') siteresource = wtf.BooleanField( 'Site resource', description= 'Enable if this resource is generic to the site and not owned by specific users' ) trusted = wtf.BooleanField( 'Trusted applications only', description= 'Enable if access to the resource should be restricted to trusted ' 'applications. You may want to do this for sensitive information like billing data' ) def validate_name(self, field): if not valid_username(field.data): raise wtf.ValidationError("Name contains invalid characters.") if field.data in registry: raise wtf.ValidationError("This name is reserved for internal use") existing = Resource.query.filter_by(name=field.data).first() if existing and existing.id != self.edit_id: raise wtf.ValidationError( "A resource with that name already exists")
class LDAPLoginForm(wtf.Form): """ This is a form to be subclassed by your application. Once validiated will have a `form.user` object that contains a user object. """ username = wtf.TextField('Username', validators=[wtf.Required()]) password = wtf.PasswordField('Password', validators=[wtf.Required()]) remember_me = wtf.BooleanField('Remember Me', default=True) def validate_ldap(self): 'Validate the username/password data against ldap directory' ldap_mgr = current_app.ldap_login_manager username = self.username.data password = self.password.data try: userdata = ldap_mgr.ldap_login(username, password) except ldap.INVALID_CREDENTIALS: flash("Invalid LDAP credentials", 'danger') return False except ldap.LDAPError as err: if isinstance(err.message, dict): message = err.message.get('desc', str(err)) else: message = str(err.message) flash(message, 'danger') return False if userdata is None: flash("Invalid LDAP credentials", 'danger') return False self.user = ldap_mgr._save_user(username, userdata) return True def validate(self, *args, **kwargs): """ Validates the form by calling `validate` on each field, passing any extra `Form.validate_<fieldname>` validators to the field validator. also calls `validate_ldap` """ valid = wtf.Form.validate(self, *args, **kwargs) if not valid: return valid return self.validate_ldap()
class GithubConfigForm(wtf.Form): branches = wtf.TextField( 'Branches', validators=[wtf.Optional(), wtf.Length(max=1024)], description=( 'A comma-seperated list of branches to forward, or blank for all.' ' Ex: "master, dev"')) use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.')) show_branch = wtf.BooleanField( 'Show Branch Name', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include the branch name.')) show_tags = wtf.BooleanField( 'Show Tags', validators=[wtf.Optional()], default=True, description=('If checked, changes to tags will be shown.')) prefer_username = wtf.BooleanField( 'Prefer Usernames', validators=[wtf.Optional()], default=True, description=( 'If checked, show github usernames instead of commiter name when' ' possible.')) full_project_name = wtf.BooleanField( 'Full Project Name', validators=[wtf.Optional()], default=False, description= ('If checked, show the full github project name (ex: tktech/notifico)' ' instead of the Notifico project name (ex: notifico)')) title_only = wtf.BooleanField( 'Title Only', validators=[wtf.Optional()], default=False, description=( 'If checked, only the commits title (the commit message up to' ' the first new line) will be emitted.')) distinct_only = wtf.BooleanField( 'Distinct Commits Only', validators=[wtf.Optional()], default=True, description=( 'Commits will only be announced the first time they are seen.'))
class LoginForm(Form): username = wtf.TextField('Username or Email', validators=[wtf.Required()]) password = wtf.PasswordField('Password', validators=[wtf.Required()]) remember = wtf.BooleanField('Remember me') def validate_username(self, field): existing = getuser(field.data) if existing is None: raise wtf.ValidationError("User does not exist") def validate_password(self, field): user = getuser(self.username.data) if user is None or not user.password_is(field.data): raise wtf.ValidationError("Incorrect password") self.user = user
class ProjectDetailsForm(wtf.Form): name = wtf.TextField( 'Project Name', validators=[ wtf.Required(), wtf.Length(1, 50), wtf.Regexp( r'^[a-zA-Z0-9_\-\.]*$', message=( 'Project name must only contain a to z, 0 to 9, dashes' ' and underscores.')) ]) public = wtf.BooleanField('Public', validators=[], default=True) website = wtf.TextField('Project URL', validators=[ wtf.Optional(), wtf.Length(max=1024), wtf.validators.URL() ])
class NewPaste(wtf.Form): text = wtf.TextField('uid') # honeypot field paste = wtf.TextAreaField('text', validators=[wtf.Required()]) title = wtf.TextField('title', validators=[wtf.Optional()]) password = wtf.PasswordField('password', validators=[wtf.Optional()]) unlisted = wtf.BooleanField('Unlisted') submit = wtf.SubmitField('Paste') language = wtf.SelectField( 'language', choices=[ ('', ''), ('text', 'Text'), ('c', 'C'), ('csharp', 'C#'), ('cpp', 'C++'), ('css', 'CSS'), ('erlang', 'Erlang'), ('go', 'GO'), ('html', 'HTML'), ('java', 'Java'), ('javascript', 'Javascript'), ('json', 'JSON'), ('objectivec', 'Objective-C'), ('perl', 'Perl'), ('python', 'Python (2.X)'), ('python3', 'Python (3.X)'), ('pycon', 'Python Console'), ('pytb', 'Python 2 Traceback'), ('py3tb', 'Python 3 Traceback'), ('ruby', 'Ruby'), ('sql', 'SQL'), ('vbnet', 'VB.NET'), ] ) def validate_uid(form, field): """ This ensures the hidden honeypot field is left blank, only automated spambots should attempt to fill it in """ if field.data != '': raise wtf.validators.ValidationError()
class TravisConfigForm(wtf.Form): gh_user = wtf.TextField( 'GitHub username', validators=[wtf.Required(), wtf.Length(max=40)], description=('Case-sensitive GitHub username of repository owner.')) repo_name = wtf.TextField( 'Repo name', validators=[wtf.Required(), wtf.Length(max=100)], description=('Case-sensitive name of repository.')) token = wtf.TextField( 'Travis Token', validators=[wtf.Required(), wtf.Length(max=1024)], description= ('Used to authenticate incoming webhooks.<br>' 'Can be found on your ' '<a href="https://travis-ci.org/profile/">Travis CI profile page</a>.' )) use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.'))
class PlaylistForm(Form): title = wtf.TextField(u"Title", validators=[wtf.Required()], description=u"The name of your playlist") short_title = wtf.TextField( u"Short title", validators=[wtf.Optional()], description= u"Shorter title, displayed next to the channel's name when viewing a video" ) name = wtf.TextField( u"URL Name", validators=[wtf.Optional()], description=u"Optional. Will be automatically generated if left blank") description = RichTextField(u"Description") recorded_date = wtf.DateField( u"Recorded date", validators=[wtf.Optional()], description= u"Date on which the videos in this playlist were recorded, if applicable" ) published_date = wtf.DateField( u"Published date", validators=[wtf.Required()], default=date.today(), description=u"Date on which this playlist was created or made public") public = wtf.BooleanField(u"This playlist is public", default=True) def validate_name(self, field): if invalid_name.search(field.data): raise wtf.ValidationError( "The name cannot have spaces or non-alphanumeric characters") existing = Playlist.query.filter_by(channel=self.channel, name=field.data).first() if existing and existing.id != self.edit_id: raise wtf.ValidationError("That name is already in use")
class GithubConfigForm(wtf.Form): branches = wtf.TextField('Branches', validators=[ wtf.Optional(), wtf.Length(max=1024) ], description=( 'A comma-separated list of branches to forward, or blank for all.' ' Ex: "master, dev"' )) events = EventSelectField('Events', choices=[ ('commit_comment_created', 'Commit comment'), ('status_error', 'Commit status: error'), ('status_failure', 'Commit status: failure'), ('status_pending', 'Commit status: pending'), ('status_success', 'Commit status: success'), ('create_branch', 'Create branch'), ('create_tag', 'Create tag'), ('delete_branch', 'Delete branch'), ('delete_tag', 'Delete tag'), ('issue_comment_created', 'Issue comment'), ('issue_comment_deleted', 'Issue comment: deleted'), ('issue_comment_edited', 'Issue comment: edited'), ('issue_assigned', 'Issue: assigned'), ('issue_closed', 'Issue: closed'), ('issue_edited', 'Issue: edited'), ('issue_labeled', 'Issue: labeled'), ('issue_opened', 'Issue: opened'), ('issue_reopened', 'Issue: reopened'), ('issue_unassigned', 'Issue: unassigned'), ('issue_unlabeled', 'Issue: unlabeled'), ('pr_review_created', 'Pull request review comment'), ('pr_review_deleted', 'Pull request review comment: deleted'), ('pr_review_edited', 'Pull request review comment: edited'), ('pr_assigned', 'Pull request: assigned'), ('pr_closed', 'Pull request: closed'), ('pr_edited', 'Pull request: edited'), ('pr_labeled', 'Pull request: labeled'), ('pr_opened', 'Pull request: opened'), ('pr_reopened', 'Pull request: reopened'), ('pr_synchronize', 'Pull request: synchronize'), ('pr_unassigned', 'Pull request: unassigned'), ('pr_unlabeled', 'Pull request: unlabeled'), ('push', 'Push'), ('release_published', 'Release published'), ('member_added', 'Repo: added collaborator'), ('team_add', 'Repo: added to a team'), ('fork', 'Repo: forked'), ('public', 'Repo: made public'), ('watch_started', 'Repo: starred'), ('gollum_created', 'Wiki: created page'), ('gollum_edited', 'Wiki: edited page'), ]) use_colors = wtf.BooleanField('Use Colors', validators=[ wtf.Optional() ], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.' )) show_branch = wtf.BooleanField('Show Branch Name', validators=[ wtf.Optional() ], default=True, description=( 'If checked, commit messages will include the branch name.' )) show_tags = wtf.BooleanField('Show Tags', validators=[ wtf.Optional() ], default=True, description=( 'If checked, changes to tags will be shown.' )) prefer_username = wtf.BooleanField('Prefer Usernames', validators=[ wtf.Optional() ], default=True, description=( 'If checked, show github usernames instead of commiter name when' ' possible.' )) full_project_name = wtf.BooleanField('Full Project Name', validators=[ wtf.Optional() ], default=False, description=( 'If checked, show the full github project name (ex: tktech/notifico)' ' instead of the Notifico project name (ex: notifico)' )) title_only = wtf.BooleanField('Title Only', validators=[ wtf.Optional() ], default=False, description=( 'If checked, only the commits title (the commit message up to' ' the first new line) will be emitted.' )) distinct_only = wtf.BooleanField('Distinct Commits Only', validators=[ wtf.Optional() ], default=True, description=( 'Commits will only be announced the first time they are seen.' ))
class PlainTextConfigForm(wtf.Form): use_colours = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=False, description=('If checked, messages will include mIRC colouring.'))
class ImportForm(Form): import_file = wtf.FileField(u"Upload file", validators=[wtf.Required()]) import_updated = wtf.BooleanField( u"Only import newer nodes", default=True, description=u"Nodes that are newer locally will not be imported")
class SectionForm(wtf.Form): name = wtf.TextField('URL name', validators=[wtf.Required()]) title = wtf.TextField('Title', validators=[wtf.Required()]) description = wtf.TextAreaField('Description', validators=[wtf.Required()]) public = wtf.BooleanField('Public?')
class CIAConfigForm(wtf.Form): use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=('If checked, messages will include minor mIRC coloring.'))
class GitlabConfigForm(wtf.Form): branches = wtf.TextField( 'Branches', validators=[wtf.Optional(), wtf.Length(max=1024)], description=( 'A comma-separated of branches to forward, or blank for all.' ' Ex: "master, dev"')) events = EventSelectField( 'Events', choices=[('commit_comment', 'Commit comment'), ('snippet_comment', 'Snippet comment'), ('pipeline_created', 'Pipeline status: created'), ('pipeline_pending', 'Pipeline status: pending'), ('pipeline_running', 'Pipeline status: running'), ('pipeline_failed', 'Pipeline status: failed'), ('pipeline_success', 'Pipeline status: success'), ('pipeline_canceled', 'Pipeline status: canceled'), ('pipeline_skipped', 'Pipeline status: skipped'), ('build_created', 'Build status: created'), ('build_pending', 'Build status: pending'), ('build_running', 'Build status: running'), ('build_failed', 'Build status: failed'), ('build_success', 'Build status: success'), ('build_canceled', 'Build status: canceled'), ('build_skipped', 'Build status: skipped'), ('create_branch', 'Create branch'), ('create_tag', 'Create tag'), ('delete_branch', 'Delete branch'), ('delete_tag', 'Delete tag'), ('issue_comment', 'Issue comment'), ('issue_close', 'Issue: closed'), ('issue_update', 'Issue: updated'), ('issue_open', 'Issue: opened'), ('issue_reopen', 'Issue: reopened'), ('mr_comment', 'Merge request comment'), ('mr_close', 'Merge request: closed'), ('mr_update', 'Merge request: updated'), ('mr_open', 'Merge request: opened'), ('mr_reopen', 'Merge request: reopened'), ('mr_merge', 'Merge request: merged'), ('push', 'Push'), ('wiki_create', 'Wiki: created page'), ('wiki_edit', 'Wiki: edited page')]) use_colors = wtf.BooleanField( 'Use Colors', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include minor mIRC coloring.')) show_branch = wtf.BooleanField( 'Show Branch Name', validators=[wtf.Optional()], default=True, description=( 'If checked, commit messages will include the branch name.')) show_tags = wtf.BooleanField( 'Show Tags', validators=[wtf.Optional()], default=True, description=('If checked, changes to tags will be shown.')) full_project_name = wtf.BooleanField( 'Full Project Name', validators=[wtf.Optional()], default=False, description= ('If checked, show the full gitlab project name (ex: tktech/notifico)' ' instead of the Notifico project name (ex: notifico)')) title_only = wtf.BooleanField( 'Title Only', validators=[wtf.Optional()], default=False, description=( 'If checked, only the commits title (the commit message up to' ' the first new line) will be emitted.'))
class RegisterClientForm(Form): """ Register a new OAuth client application """ title = wtf.TextField('Application title', validators=[wtf.Required()], description="The name of your application") description = wtf.TextAreaField( 'Description', validators=[wtf.Required()], description="A description to help users recognize your application") client_owner = wtf.RadioField( 'Owner', validators=[wtf.Required()], description= "User or organization that owns this application. Changing the owner " "will revoke all currently assigned permissions for this app") website = wtf.html5.URLField( 'Application website', validators=[wtf.Required(), wtf.URL()], description="Website where users may access this application") redirect_uri = wtf.html5.URLField('Redirect URI', validators=[wtf.Optional(), wtf.URL()], description="OAuth2 Redirect URI") notification_uri = wtf.html5.URLField( 'Notification URI', validators=[wtf.Optional(), wtf.URL()], description= "Lastuser resource provider Notification URI. When another application requests access to " "resources provided by this app, Lastuser will post a notice to this URI with a copy of the access " "token that was provided to the other application. Other notices may be posted too " "(not yet implemented)") iframe_uri = wtf.html5.URLField( 'IFrame URI', validators=[wtf.Optional(), wtf.URL()], description= "Front-end notifications URL. This is loaded in a hidden iframe to notify the app that the " "user updated their profile in some way (not yet implemented)") resource_uri = wtf.html5.URLField( 'Resource URI', validators=[wtf.Optional(), wtf.URL()], description= "URI at which this application provides resources as per the Lastuser Resource API " "(not yet implemented)") allow_any_login = wtf.BooleanField( 'Allow anyone to login', default=True, description= "If your application requires access to be restricted to specific users, uncheck this, " "and only users who have been assigned a permission to the app will be able to login" ) team_access = wtf.BooleanField( 'Requires access to teams', default=False, description= "If your application is capable of assigning access permissions to teams, check this. " "Organization owners will then able to grant access to teams in their organizations" ) def validate_client_owner(self, field): if field.data == g.user.userid: self.user = g.user self.org = None else: orgs = [ org for org in g.user.organizations_owned() if org.userid == field.data ] if len(orgs) != 1: raise wtf.ValidationError("Invalid owner") self.user = None self.org = orgs[0]