class StateMeta(MappingSchema): """Workflow state.""" title = SingleLine(missing='') description = Text(missing='') acm = ACM() display_only_to_roles = Roles(missing=[]) """Hint for the fronted, this is not security related."""
class CommentSchema(colander.MappingSchema): """Comment sheet data structure. `content`: Text """ refers_to = Reference(reftype=CommentRefersToReference) content = Text()
class ProposalSchema(MappingSchema): """Data structure for plan stellungsname information.""" name = SingleLine(missing=required) street_number = SingleLine(missing=required) postal_code_city = SingleLine(missing=required) email = Email() statement = Text(missing=required, validator=Length(max=17500))
class HeardFromSchema(colander.MappingSchema): heard_from_colleague = Boolean() heard_from_website = Boolean() heard_from_newsletter = Boolean() heard_from_facebook = Boolean() # There is no heard_from_elsewhere Boolean, since that automatically # follows iff heard_elsewhere is not empty heard_elsewhere = Text()
class StateData(MappingSchema): """Resource specific data for a workflow state.""" missing = drop default = None name = StateName() description = Text(missing='', default='') start_date = DateTime(missing=None, default=None)
class ProposalSchema(colander.MappingSchema): """Data structure for organizational information.""" # TODO: check exact length restrictions budget = CurrencyAmount(missing=colander.required, validator=colander.Range(min=0, max=50000)) creator_participate = Boolean() location_text = SingleLine(validator=colander.Length(max=100)) address = Text()
class ParagraphSchema(MappingSchema): """Paragraph Section sheet data structure. `content`: Text `documents`: Documents referencing this paragraph """ text = Text() documents = UniqueReferences(reftype=DocumentElementsReference, readonly=True, backref=True)
class PartnersSchema(MappingSchema): has_partners = Boolean() partner1_name = SingleLine() partner1_website = URL() partner1_country = ISOCountryCode() partner2_name = SingleLine() partner2_website = URL() partner2_country = ISOCountryCode() partner3_name = SingleLine() partner3_website = URL() partner3_country = ISOCountryCode() other_partners = Text()
class EmbedSchema(MappingSchema): """Embed sheet data structure. `embed_code`: html code to embed the `context` resource in web pages. `external_url`: canonical URL that embeds the `context` resource. """ embed_code = Text( default=deferred_default_embed_code, widget=TextAreaWidget(rows=10), ) external_url = URL()
class TopicSchema(MappingSchema): topic = TopicEnums(validator=Length(min=1, max=2)) topic_other = Text() def validator(self, node: SchemaNode, value: dict): """Extra validation depending on the status of the topic.""" topics = value.get('topic', []) if 'other' in topics: if not value.get('topic_other', None): raise Invalid(node['topic_other'], msg='Required if "other" in topic') if _has_duplicates(topics): raise Invalid(node['topic'], msg='Duplicates are not allowed')
class LocationSchema(MappingSchema): location = SingleLine() is_online = Boolean() has_link_to_ruhr = Boolean(missing=required, default=False) link_to_ruhr = Text() def validator(self, node, value): """Extra validation depending on the status of the location. Make `link_to_ruhr` required if `has_link_to_ruhr` == `True`. """ has_link_to_ruhr = value.get('has_link_to_ruhr', None) if has_link_to_ruhr: if not value.get('link_to_ruhr', None): link_to_ruhr = node['link_to_ruhr'] raise Invalid(link_to_ruhr, msg='Required iff has_link_to_ruhr == True')
class IntroductionSchema(colander.MappingSchema): """Data structure for the proposal introduction.""" teaser = Text(validator=colander.Length(min=1, max=300)) picture = Reference(reftype=IntroImageReference)
class StorySchema(MappingSchema): story = Text(validator=Length(min=1, max=800))
class PartnersSchema(colander.MappingSchema): partners = Text(validator=colander.Length(min=1, max=800))
class StepsSchema(colander.MappingSchema): steps = Text(validator=colander.Length(min=1, max=800))
class FinancialPlanningSchema(MappingSchema): budget = CurrencyAmount(missing=required) requested_funding = CurrencyAmount(missing=required, validator=Range(min=1, max=50000)) major_expenses = Text(missing=required)
class POSTReportAbuseViewRequestSchema(colander.Schema): """Schema for abuse reports.""" url = URL(missing=colander.required) remark = Text(missing='')
class PartnersSchema(MappingSchema): partners = Text(validator=Length(min=1, max=800))
class ValueSchema(MappingSchema): value = Text(validator=Length(min=1, max=800))
class StepsSchema(MappingSchema): steps = Text(validator=Length(min=1, max=800))
class OutcomeSchema(MappingSchema): outcome = Text(validator=Length(min=1, max=800))
class DescriptionSchema(colander.MappingSchema): """Data structure for for proposal description.""" description = Text(validator=colander.Length(min=1, max=1000))
class OutcomeSchema(colander.MappingSchema): outcome = Text(validator=colander.Length(min=1, max=800))
class PracticalRelevanceSchema(MappingSchema): """Datastruct for the challenge field.""" practicalrelevance = Text(missing=required, validator=Length(min=3, max=500))
class ValueSchema(colander.MappingSchema): value = Text(validator=colander.Length(min=1, max=800))
class POSTMessageUserViewRequestSchema(MappingSchema): """Schema for messages to a user.""" recipient = Reference(missing=required, reftype=MessageUserReference) title = SingleLine(missing=required) text = Text(missing=required)
class ExperienceSchema(colander.MappingSchema): """Data structure for additional fields.""" experience = Text()
def make_one(self): from adhocracy_core.schema import Text return Text()
class POSTReportAbuseViewRequestSchema(MappingSchema): """Schema for abuse reports.""" url = URL(missing=required) remark = Text(missing='')
class ExtraFundingSchema(MappingSchema): other_sources = Text(missing='') secured = Boolean(default=False)