Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
meeting_title = colander.SchemaNode(colander.String(),
title = _(u"Meeting"),
description = _(u"support_schema_meeting_description",
default = u"Is this support request about a specific meeting? "
u"In that case, what's the title of the meeting? "
u"(It doesn't have to be exact, it's just so we know what to look for!)"),
default = deferred_meeting_title,
validator = no_html_validator,
missing = u"",)
message = colander.SchemaNode(colander.String(),
title = _(u'What do you need help with?'),
description = _(u"support_schema_message_description",
default = u"Please take time to describe what you need help with, or what went wrong. "
u"If you're submitting an error report, please explain what you were doing and how we can reproduce the error. "
u"The more information you send us, the better. We're really bad at reading minds..."),
widget = deform.widget.TextAreaWidget(rows=10, cols=40),
validator = no_html_validator,)
def includeme(config):
config.add_content_schema('Root', SupportSchema, 'support')
config.add_content_schema('Meeting', SupportSchema, 'support')
email = email_node()
first_name = first_name_node()
last_name = last_name_node()
@schema_factory('EditUserSchema', title = _(u"Edit user"), description = _(u"Use this form to edit a user"))
class EditUserSchema(colander.Schema):
""" Regular edit. """
email = email_node()
first_name = first_name_node()
last_name = last_name_node()
about_me = colander.SchemaNode(colander.String(),
title = _(u"About me"),
description = _(u"user_about_me_description",
default=u"Please note that anything you type here will be visible to all users in the same meeting as you."),
widget = deform.widget.TextAreaWidget(rows=10, cols=60),
missing=u"",
validator=html_string_validator,)
profile_image_plugin = colander.SchemaNode(colander.String(),
title = _(u"Profile image provider"),
description = _(u"profile_image_plugin_description",
default=u""),
widget = profile_image_plugin_choices_widget,
default = deferred_default_profile_image_plugin,)
@schema_factory('ManageConnectedProfilesSchema', title = _(u"Manage connected profiles"),
description = _(u"manage_connected_profiles_schema_description",
default = u"You can remove local authentication information for any connected services. "
u"This will make you unable to login with that service. "
u"Be sure to have other means of login in before doing so!"))
class ManageConnectedProfilesSchema(colander.Schema):
catalog = self.context.__parent__
if ICatalog.providedBy(catalog):
catalog.reindex(indexes=[index_name])
self.request.sdiapi.flash('Index "%s" reindexed' % index_name,
'success')
else:
self.request.sdiapi.flash(
'Cannot reindex an index unless it is contained in a catalog',
'danger'
)
return HTTPFound(location=self.redir_location)
class SearchSchema(Schema):
cqe_expression = colander.SchemaNode(
colander.String(),
widget = deform.widget.TextAreaWidget(rows=10, cols=120),
title='CQE Expression',
)
@mgmt_view(context=ICatalog, name='search_catalog',
permission='sdi.manage-catalog',
renderer='templates/search.pt', tab_title='Search')
class SearchCatalogView(FormView):
schema = SearchSchema(title='Expression')
buttons = ('search',)
catalog_results = None
logger = logger
parse_query = staticmethod(parse_query) # for testing
find_objectmap = staticmethod(find_objectmap) # for testing
def search_success(self, appstruct):
""" Accept a CQE expression and a permitted value and return a
_WIDGETS = {
sa_types.BigInteger: deform.widget.TextInputWidget,
sa_types.Boolean: HiddenCheckboxWidget,
sa_types.Date: deform.widget.DateInputWidget,
sa_types.DateTime: deform.widget.DateTimeInputWidget,
sa_types.Enum: deform.widget.SelectWidget,
sa_types.Float: deform.widget.TextInputWidget,
sa_types.Integer: deform.widget.TextInputWidget,
sa_types.Numeric: deform.widget.TextInputWidget,
sa_types.SmallInteger: deform.widget.TextInputWidget,
sa_types.String: deform.widget.TextInputWidget,
sa_types.Text: deform.widget.TextAreaWidget,
sa_types.Time: deform.widget.TextInputWidget,
sa_types.Unicode: deform.widget.TextInputWidget,
sa_types.UnicodeText: deform.widget.TextAreaWidget,
JSON: deform.widget.TextAreaWidget,
HSTORE: HstoreWidget,
sqlalchemy.ForeignKey: deform.widget.SelectWidget,
ChoiceType: deform.widget.SelectWidget,
FileStore: deform.widget.FileUploadWidget,
ElfinderString: ElfinderWidget,
SlugType: SlugWidget,
}
class Dict2Obj(object):
"""
Turns a dictionary into a class
"""
def __init__(self, dictionary):
"""Constructor"""
for key in dictionary:
class ContactSchema(c.MappingSchema):
name = c.SchemaNode(
c.Str(), title=_('Name'),
widget=d.widget.TextInputWidget(size=60, maxlength=160))
email = c.SchemaNode(
c.Str(), title=_('Email'),
validator=c.Email(),
widget=d.widget.TextInputWidget(size=50, maxlength=160,
type='email'))
subject = c.SchemaNode(
c.Str(), title=_('Subject'),
widget=d.widget.TextInputWidget(size=60, maxlength=160))
message = c.SchemaNode(
c.Str(), title=_('Message'),
widget=d.widget.TextAreaWidget(cols=60, rows=12))
if len_name:
name.widget.maxlength = len_name.get('max')
name.validator = c.Length(**len_name)
if len_subject:
subject.validator = c.Length(**len_subject)
if len_message:
message.validator = c.Length(**len_message)
return ContactView
from kotti.views.form import ObjectType
from kotti.views.form import deferred_tag_it_widget
from kotti.views.form import get_appstruct
from kotti.views.form import validate_file_size_limit
class ContentSchema(colander.MappingSchema):
title = colander.SchemaNode(
colander.String(),
title=_("Title"),
validator=colander.Length(max=Node.title.property.columns[0].type.length),
)
description = colander.SchemaNode(
colander.String(),
title=_("Description"),
widget=TextAreaWidget(cols=40, rows=5),
missing="",
)
tags = colander.SchemaNode(
ObjectType(), title=_("Tags"), widget=deferred_tag_it_widget, missing=[]
)
class DocumentSchema(ContentSchema):
body = colander.SchemaNode(
colander.String(),
title=_("Body"),
widget=RichTextWidget(
# theme='advanced', width=790, height=500
height=500
),
missing="",
return TypeOverridesHandling.drop, {}
if column.foreign_keys:
# Handled by relationship mapper
return TypeOverridesHandling.drop, {}
elif isinstance(column_type, (PostgreSQLUUID, columns.UUID)):
# UUID's cannot be edited
if mode in (EditMode.add, EditMode.edit):
return TypeOverridesHandling.drop, {}
# But let's show them
return fields.UUID(), dict(missing=colander.drop, widget=FriendlyUUIDWidget(readonly=True))
elif isinstance(column_type, Text):
return colander.String(), dict(widget=deform.widget.TextAreaWidget(), validator=validator)
elif isinstance(column_type, JSONB):
return JSONValue(), dict(widget=JSONWidget())
elif isinstance(column_type, (LargeBinary, Geometry)):
# Can't edit binary and geometry
return TypeOverridesHandling.drop, {}
elif isinstance(column_type, (INET, columns.INET)):
return colander.String(), dict(validator=validator)
else:
# Default mapping / unknown, let the parent handle
return TypeOverridesHandling.unknown, dict(validator=validator)
roles = colander.SchemaNode(
colander.Set(),
title = _(u"Roles"),
default = (security.ROLE_VIEWER, security.ROLE_DISCUSS, security.ROLE_PROPOSE, security.ROLE_VOTER),
description = _(u"add_tickets_roles_description",
default = u"""One user can have more than one role. Note that to be able to propose,
discuss and vote you need respective role. This is selected by default. If you want
to add a user that can only view, select View and uncheck everything else."""),
widget = deform.widget.CheckboxChoiceWidget(values=security.MEETING_ROLES,),
)
emails = colander.SchemaNode(colander.String(),
title = _(u"add_tickets_emails_titles",
default=u"Email addresses to give the roles above."),
description = _(u"add_tickets_emails_description",
default=u'Separate email addresses with a single line break.'),
widget = deform.widget.TextAreaWidget(rows=7, cols=40),
preparer = strip_and_lowercase,
validator = colander.All(no_html_validator, multiple_email_validator),
)
message = colander.SchemaNode(colander.String(),
title = _(u"Welcome text of the email that will be sent"),
description = _(u"ticket_message_description",
default = u"The mail will contain instructions on how to access the meeting, "
u"so focus on anything that might be specific for your participants."),
widget = deform.widget.TextAreaWidget(rows=5, cols=40),
missing = u"",
validator = no_html_validator,
)
def includeme(config):
config.add_content_schema('Meeting', AddTicketsSchema, 'add_tickets')
agenda_item = AgendaItemSchema(title=_(u'Agenda item'))
# @schema_factory('AgendaTemplateSchema',
# title = _(u"Agenda template"))
class AgendaTemplateSchema(colander.Schema):
title = colander.SchemaNode(
colander.String(),
title=_("Template name"),
validator=html_string_validator,)
description = colander.SchemaNode(
colander.String(),
title = _("Description"),
description = _("agenda_template_description_description",
default="Describe the purpose of this agenda"),
widget=deform.widget.TextAreaWidget(rows=5, cols=40),
)
agenda_items = AgendaItemSequenceSchema(title=_('Agenda items'))
def includeme(config):
config.add_content_schema('AgendaTemplate', AgendaTemplateSchema, 'edit')
config.add_content_schema('AgendaTemplate', AgendaTemplateSchema, 'add')