Skip to content

Commit

Permalink
Added first draft of additional fields for education person
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschulz committed May 15, 2024
1 parent 685a4af commit 45c82ac
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
Empty file.
21 changes: 21 additions & 0 deletions backend/src/plone/edu/behaviors/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="collective.person"
>

<include
package="plone.behavior"
file="meta.zcml"
/>

<!-- EduPerson Behavior -->
<plone:behavior
name="plone.edu.eduperson"
title="Education Person Behavior"
description="Fields with education person information"
provides=".eduperson.IEduPersonData"
/>
</configure>
43 changes: 43 additions & 0 deletions backend/src/plone/edu/behaviors/eduperson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from plone.autoform.interfaces import IFormFieldProvider
from plone.edu import _
from plone.namedfile.field import NamedBlobImage
from plone.schema import Email
from plone.schema import JSONField
from plone.supermodel import model
from zope.interface import provider
from zope.schema import TextLine


import json

AFFILIATION_SCHEMA = json.dumps(
{
'type': 'object',
'properties': {'items': {'type': 'array', 'items': {'type': 'object', 'properties': {}}}},
}
)

@provider(IFormFieldProvider)
class IEduPersonData(model.Schema):
"""A Person in context of educational institutions."""

academic_title = TextLine(
title=_("label_academic_title", default="Academic title"),
description=_("help_academic_title", default="The academic titles of the person."),
required=False,
)

image = NamedBlobImage(
title=_("label_image", default="Person image"),
description=_("help_image", default="A picture of the person."),
required=False,
)

affiliation = JSONField(
title='Mixedfield: datagrid field for Plone',
required=False,
schema=AFFILIATION_SCHEMA,
widget='affiliation_widget',
default={'items': []},
missing_value={'items': []},
)
2 changes: 2 additions & 0 deletions backend/src/plone/edu/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
<include file="permissions.zcml" />
<include file="profiles.zcml" />

<include package=".behaviors" />

</configure>

0 comments on commit 45c82ac

Please sign in to comment.