I have added a new 'Event Attendees' behavior, which works OK.
I will use this for several content types.
It would be nice if I could use the default Event View. Is there a way to show the 'fullname' instead of the useid (which it does now)?
Current code:
@provider(IFormFieldProvider)
class IMeetingAttendees(IEventAttendees):
"""MEETING Attendees Schema."""
attendees = schema.List(
# or Tuple
title= "Attendees",
description= "List of attendees.",
required=False,
value_type=schema.Choice(
title="Attendee",
required=False,
vocabulary= 'My.Addon.FullnamesVocabulary'
)
)
directives.widget("attendees", AjaxSelectFieldWidget, vocabulary= 'My.Addon.FullnamesVocabulary', klass="event_attendees")
def FullnamesVocabulary(context):
members = api.user.get_users()
# Maybe this is faster/better?
# portal_membership = getToolByName(portal, 'portal_membership')
# # Get a list of member objects
# members = portal_membership.listMembers()
if members:
# Create a list of SimpleTerms for each full name
terms = [SimpleTerm(value=member.getId(), token=member.getId(), title=member.getProperty('fullname')) for member in members]
return SimpleVocabulary(terms)
return SimpleVocabulary([])
directlyProvides(FullnamesVocabulary, IVocabularyFactory)