Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@view_config(
route_name="process_csv",
renderer="templates/create_corpus.pt"
)
class CreateCorpusView(FormView):
schema = CreateCorpusSchema()
preview = () # will hold preview results
preview_size = 5 # number of documents (csv rows) to preview
buttons = (
Button('preview', 'Preview'),
Button('generate_corpus', 'Generate Corpus'),
Button('save_pipeline', 'Save pipeline as template'),
)
@property
def document(self):
return document_name(self.request)
def _get_sorted_component_names(self, request):
""" Returns a list of (component names, params) from request
"""
data = parse(request.POST.items())
schemas = [] # establish position of widgets
for k, v in self.request.POST.items():
if (k == '__start__') and (':mapping' in v):
sk = v.split(':')[0]
class ForgotForm(Deform):
buttons = (deform.Button('Send code'),)
class ResetForm(Deform):
buttons = (deform.Button('Reset password'),)
class ActivateForm(Deform):
buttons = (deform.Button('Sign in'),)
class EditProfileForm(Deform):
buttons = (deform.Button('Save'),)
def includeme(config):
registry = config.registry
forms = [
(interfaces.ILoginForm, LoginForm),
(interfaces.IRegisterForm, RegisterForm),
(interfaces.IForgotPasswordForm, ForgotForm),
(interfaces.IResetPasswordForm, ResetForm),
(interfaces.IProfileForm, EditProfileForm),
]
for iface, imp in forms:
if not registry.queryUtility(iface):
registry.registerUtility(imp, iface)
def make_button(title, icon=None):
'''Conveniently create a button, optionally with a bootstrap icon.'''
b = d.Button(title)
b.icon = icon
return b
colander.Integer(),
title=_('A number between ${min} and ${max}',
mapping=minmax),
description=_('A number between ${min} and ${max}',
mapping=minmax),
validator = colander.Range(1, 10),
)
_LOCALE_ = colander.SchemaNode(
colander.String(),
widget = deform.widget.HiddenWidget(),
default=locale_name)
schema = Schema()
form = deform.Form(
schema,
buttons=[deform.Button('submit', _('Submit'))],
)
return self.render_form(form)
class UserEditFormView(EditFormView):
@property
def success_url(self):
return self.request.url
@staticmethod
def schema_factory():
return user_schema(PrincipalBasic())
class UserManageFormView(UserEditFormView):
buttons = (
Button("save", _("Save")),
Button("cancel", _("Cancel")),
Button("delete", _("Delete"), css_class="btn btn-danger"),
)
@staticmethod
def schema_factory():
schema = user_schema()
del schema["name"]
return schema
def before(self, form):
context = self.context.__dict__.copy()
context["password"] = ""
form.appstruct = _massage_groups_out(context)
def save_success(self, appstruct):
if appstruct.get("password"):
button_add = deform.Button('add', _(u"Add"))
button_cancel = deform.Button('cancel', _(u"Cancel"))
button_change = deform.Button('change', _(u"Change"))
button_delete = deform.Button('delete', _(u"Delete"))
button_login = deform.Button('login', _(u"Login"))
button_register = deform.Button('register', _(u"Register"))
button_request = deform.Button('request', _(u"Request"))
button_request_access = deform.Button('request_access', _(u"Request access"))
button_save = deform.Button('save', _(u"Save"))
button_update = deform.Button('update', _(u"Update"))
button_vote = deform.Button('vote', _(u"add_vote_button", default=u"Vote"))
button_resend = deform.Button('resend', _(u"Resend"))
button_download = deform.Button('download', _(u"Download"))
button_send = deform.Button('download', _(u"Send"))
button_search = deform.Button('search', _(u"Search"))
def add_csrf_token(context, request, schema):
""" Deprecated, kept for backward compat."""
return new_csrf_func(context, request, schema)
def add_came_from(context, request, schema):
""" Add came from to schema."""
referer = getattr(request, 'referer', '')
schema.add(colander.SchemaNode(
colander.String(),
name="came_from",
widget = deform.widget.HiddenWidget(),
default = referer,
missing=u'',
)
from voteit.core import VoteITMF as _
from voteit.core.schemas.common import add_csrf_token as new_csrf_func
#FIXME: Should this be here?
button_add = deform.Button('add', _(u"Add"))
button_cancel = deform.Button('cancel', _(u"Cancel"))
button_change = deform.Button('change', _(u"Change"))
button_delete = deform.Button('delete', _(u"Delete"))
button_login = deform.Button('login', _(u"Login"))
button_register = deform.Button('register', _(u"Register"))
button_request = deform.Button('request', _(u"Request"))
button_request_access = deform.Button('request_access', _(u"Request access"))
button_save = deform.Button('save', _(u"Save"))
button_update = deform.Button('update', _(u"Update"))
button_vote = deform.Button('vote', _(u"add_vote_button", default=u"Vote"))
button_resend = deform.Button('resend', _(u"Resend"))
button_download = deform.Button('download', _(u"Download"))
button_send = deform.Button('download', _(u"Send"))
button_search = deform.Button('search', _(u"Search"))
def add_csrf_token(context, request, schema):
""" Deprecated, kept for backward compat."""
return new_csrf_func(context, request, schema)
def add_came_from(context, request, schema):
""" Add came from to schema."""
referer = getattr(request, 'referer', '')
schema.add(colander.SchemaNode(
colander.String(),
name="came_from",
def button(title=_('Submit'), name=None, icon=None):
"""Conveniently generate a Deform button while setting its
``name`` attribute, translating the label and capitalizing it.
The button may also have a bootstrap icon.
"""
b = d.Button(title=translator(title).capitalize(),
name=name or title.lower())
b.icon = icon
return b