class ISpeakerfolder(form.Schema):
    """A speaker folder. The speaker of the conference are created in the folder.
    """

    title = schema.TextLine(title=_(u"Name of the speaker folder"), )

    description = schema.Text(title=_(u"speakerfolder description"), )
Beispiel #2
0
class IRoomfolder(form.Schema):
    """A folder for the rooms of a conference.
    """

    title = schema.TextLine(title=_(u"Name of the room folder"), )

    description = schema.Text(title=_(u"roomfolder description"), )
 def __call__(self, context):
     return SimpleVocabulary([
         SimpleTerm(value=u'Talk', title=_(u'Talk')),
         SimpleTerm(value=u'Discussion', title=_(u'Discussion')),
         SimpleTerm(value=u'Hackfest', title=_(u'Hackfest')),
         SimpleTerm(value=u'Meta', title=_(u'Meta')),
         SimpleTerm(value=u'Workshop', title=_(u'Workshop')),
     ])
    def __call__(self, context):
        terms = []
        levels = [('morning', _(u'Morning')),
                  ('afternon', _(u'Afternon'))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        terms = []
        levels = [('english', _(u'English')),
                  ('portuguese', _(u'Portuguese')),
                  ('spanish', _(u'Spanish'))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        terms = []
        levels = [('half_day', _(u'Half day')),
                  ('one_day', _(u'1 day')),
                  ('two_days', _(u'2 days'))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' Genders '''
        terms = []
        genders = [('m', _(u'Male')),
                   ('f', _(u'Female'))]
        for key, value in genders:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' Look for an enclosing program
            list available languages in it '''
        terms = []
        levels = [('basic', _(u'Basic')),
                  ('advanced', _(u'Advanced'))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #9
0
    def __call__(self, context):
        terms = []
        levels = [
            ('morning', _(u'Morning')),
            ('afternon', _(u'Afternon')),
        ]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' Payment Method Options '''
        terms = []
        types = [('cash', _(u'Cash / At the conference')),
                 ('paypal', _(u'PayPal')),
                 ('pagseguro', _(u'Pagseguro'))]
        for key, value in types:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' Wall Options '''
        terms = []
        types = [('no', _(u'No, thanks')),
                 ('100', _(u'Yes, I support with R$100,00')),
                 ('200', _(u'Yes, I support with R$200,00')),
                 ('400', _(u'Yes, I support with R$400,00'))]
        for key, value in types:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' TShirt Sizes '''
        terms = []
        sizes = [('S', _(u'Small')),
                 ('M', _(u'Medium')),
                 ('L', _(u'Large')),
                 ('X', _(u'X-Large'))]
        for key, value in sizes:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
    def __call__(self, context):
        ''' Caipirinha Sprint Options'''
        terms = []
        types = [('no', _(u'No, I will not attend')),
                 ('yes_1', _(u'Yes, I will')),
                 ('yes_2', _(u'Yes and I will bring my SO')),
                 ('yes_3', _(u'Yes, plus 2 other people'))]
        for key, value in types:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #14
0
    def __call__(self, context):
        terms = []
        levels = [
            ('english', _(u'English')),
            ('portuguese', _(u'Portuguese')),
            ('spanish', _(u'Spanish')),
        ]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #15
0
    def __call__(self, context):
        terms = []
        levels = [
            ('half_day', _(u'Half day')),
            ('one_day', _(u'1 day')),
            ('two_days', _(u'2 days')),
        ]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #16
0
    def __call__(self, context):
        ''' Look for an enclosing program
            list available languages in it '''
        terms = []
        levels = [
            ('basic', _(u'Basic')),
            ('advanced', _(u'Advanced')),
        ]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #17
0
class ITalk(form.Schema):
    """
    A talk in a conference
    """

    language_talk = schema.Choice(
        title=_(u"Language"),
        required=True,
        description=_(u"Language of your talk."),
        vocabulary='collective.conference.languages',
    )

    global_theme = schema.Choice(
        title=_(u"Global theme"),
        required=True,
        description=_(u"What is the subject of your talk?"),
        vocabulary='collective.conference.theme',
    )

    level = schema.Choice(
        title=_(u"Level"),
        required=True,
        description=_(u"Level of your talk."),
        vocabulary='collective.conference.levels',
    )

    observations = schema.Text(
        title=_(u"Observations"),
        required=False,
        description=_(u"Do you want to give us another information?"),
    )
class ICallforpaper(form.Schema):
    """A call for paper for a conference. 
    A call for paper can contain incomming talks.
    """

    title = schema.TextLine(title=_(u"Call for paper title"), )

    description = schema.Text(title=_(u"Call for paper summary"), )

    form.primary('details')
    details = RichText(
        title=_(u"Details"),
        description=_(u"Details about the program"),
        required=True,
    )
    def create(self, data):
        inc = getattr(self.context, 'registrant_increment', 0) + 1
        data['id'] = 'participant-%s' % inc
        self.context.registrant_increment = inc
        obj = _createObjectByType(
            'collective.conference.participant',
            self.context, data['id']
        )

        publishinfo = data['publishinfo']
        del data['captcha']
        del data['publishinfo']
        for k, v in data.items():
            setattr(obj, k, v)

        portal_workflow = getToolByName(self.context, 'portal_workflow')
        if publishinfo:
            portal_workflow.doActionFor(obj, 'anon_publish')
        else:
            portal_workflow.doActionFor(obj, 'anon_hide')
        obj.reindexObject()
        IStatusMessage(self.request).addStatusMessage(
            _(u'Thank you. You are now registered.')
        )
        return obj
Beispiel #20
0
class IRoom(form.Schema):
    """A conference room.
    """
    
    title = schema.TextLine(
            title=_(u"Name of the Room"),
        )


    description = schema.Text(
            title=_(u"A description of the room and its location"),
        )

    
    picture = NamedBlobImage(
            title=_(u"A picture of the room"),
            description=_(u"Please upload an image"),
            required=False,
        )
    
    form.primary ('details')
    details = RichText(
             title=_(u"A full description of the room, it's location and the way to get there"),
             required=True,                          
        )
    
    capacity = schema.Int(
             title=_(u"Capacity of the room"),
             description=_(u"Please fill in the maximum number of attendees"),
             required=False,
        )
    def __call__(self, context):
        ''' Registration Types'''
        terms = []
        types = [('apyb', _(u'APyB Members')),
                 ('student', _(u'Student')),
                 ('individual', _(u'Individual')),
                 ('government', _(u'Government')),
                 ('group', _(u'Group/Corporate')),
                 ('speaker', _(u'Speaker')),
                 ('speaker_c', _(u'Speaker')),
                 ('sponsor', _(u'Sponsor')),
                 ('organizer', _(u'Organization'))]
        for key, value in types:
            term = (key, key, value)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
Beispiel #22
0
class ITrack(form.Schema):
    """A conference track. Tracks are managed inside Programs.
    """

    title = schema.TextLine(
        title=_(u"Title"),
        description=_(u"Track title"),
    )

    description = schema.Text(title=_(u"Track summary"), )

    form.primary('details')
    details = RichText(title=_(u"Track details"), required=False)

    start = schema.Datetime(
        title=_(u"Startdate"),
        description=_(u"Start date"),
        required=False,
    )

    end = schema.Datetime(
        title=_(u"Enddate"),
        description=_(u"End date"),
        required=False,
    )
    # use an autocomplete selection widget instead of the default content tree
    form.widget(room=AutocompleteFieldWidget)
    room = RelationChoice(
        title=_(u"Room"),
        source=ObjPathSourceBinder(object_provides=IRoom.__identifier__),
        required=False,
    )

    #    room = schema.TextLine(
    #            title= _(u"Room"),
    #        )

    @invariant
    def validateStartEnd(data):
        if data.start is not None and data.end is not None:
            if data.start > data.end:
                raise StartBeforeEnd(
                    _(u"The start date must be before the end date."))
 def create(self, data):
     obj = Session()
     inc = getattr(self.context, 'session_increment', 0) + 1
     data['id'] = 'session-%s' % inc
     data['startDate'] = self.context.startDate
     data['endDate'] = self.context.startDate + timedelta(0, 3600)
     self.context.session_increment = inc
     obj = _createObjectByType('collective.conference.session',
                               self.context, data['id'])
     del data['captcha']
     for k, v in data.items():
         setattr(obj, k, v)
     IStatusMessage(self.request).addStatusMessage(
         _(u'Thank you for your submission. Your submission is now held for approval and will appear on the site once it is approved')
     )
     obj.reindexObject()
     return obj
def is_url(value):
    """Is this a URL?

    >>> is_url("http://google.com/")
    True
    >>> is_url("https://google.com")
    True
    >>> is_url("http://example.org/folder/somepage")
    True
    >>> is_url("ssh://google.com")
    Traceback (most recent call last):
    ...
    Invalid: Not a valid link
    >>> is_url("nothing")
    Traceback (most recent call last):
    ...
    Invalid: Not a valid link
    >>> is_url("")
    Traceback (most recent call last):
    ...
    Invalid: Not a valid link
    >>> is_url(None)
    Traceback (most recent call last):
    ...
    Invalid: Not a valid link
    >>> is_url(object())
    Traceback (most recent call last):
    ...
    Invalid: Not a valid link

    """
    if isinstance(value, basestring):
        pattern = re.compile(r"^https?://[^\s\r\n]+")
        if pattern.search(value.strip()):
            return True
    raise Invalid(_(u"Not a valid link"))
Beispiel #25
0
class IProgram(form.Schema):
    """A conference program. Programs can contain Tracks.
    """

    title = schema.TextLine(title=_(u"Program name"), )

    description = schema.Text(title=_(u"Program summary"), )

    start = schema.Datetime(
        title=_(u"Start date"),
        required=False,
    )

    end = schema.Datetime(
        title=_(u"End date"),
        required=False,
    )

    form.primary('details')
    details = RichText(
        title=_(u"Details"),
        description=_(u"Details about the program"),
        required=False,
    )

    form.widget(organizer=AutocompleteFieldWidget)
    organizer = schema.Choice(
        title=_(u"Organiser"),
        vocabulary=u"plone.principalsource.Users",
        required=False,
    )

    @invariant
    def validateStartEnd(data):
        if data.start is not None and data.end is not None:
            if data.start > data.end:
                raise StartBeforeEnd(
                    _(u"The start date must be before the end date."))
from zope.interface import Interface, implements
from zope import schema
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.vocabulary import SimpleTerm

from collective.conference import _
from plone.app.users.userdataschema import IUserDataSchemaProvider
from plone.app.users.userdataschema import IUserDataSchema

gender_options = SimpleVocabulary(
    [SimpleTerm(value=u"f", title=_(u"Female")), SimpleTerm(value=u"m", title=_(u"Male"))]
)


def validateAccept(value):
    if not value == True:
        return False
    return True


class UserDataSchemaProvider(object):
    implements(IUserDataSchemaProvider)

    def getSchema(self):
        """
        """
        return IEnhancedUserDataSchema


class IEnhancedUserDataSchema(IUserDataSchema):
    """ Use all the fields from the default user data schema, and add various
 def __call__(self, context):
     return SimpleVocabulary.fromValues(
         [_(u'S'), _(u'M'), _(u'L'), _(u'XL'), _(u'XXL'), _(u'XXXL')]
     )
 def __call__(self, context):
     return SimpleVocabulary([
         SimpleTerm(value=u'Beginner', title=_(u'Beginner')),
         SimpleTerm(value=u'Intermediate', title=_(u'Intermediate')),
         SimpleTerm(value=u'Advanced', title=_(u'Advanced'))
     ])
from zope.interface import Interface, implements
from zope import schema
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.vocabulary import SimpleTerm

from collective.conference import MessageFactory as _
from plone.app.users.userdataschema import IUserDataSchemaProvider
from plone.app.users.userdataschema import IUserDataSchema

gender_options = SimpleVocabulary(
    [SimpleTerm(value=u'f', title=_(u'Female')),
     SimpleTerm(value=u'm', title=_(u'Male'))])


def validateAccept(value):
    if not value == True:
        return False
    return True


class UserDataSchemaProvider(object):
    implements(IUserDataSchemaProvider)

    def getSchema(self):
        """
        """
        return IEnhancedUserDataSchema


class IEnhancedUserDataSchema(IUserDataSchema):
    """ Use all the fields from the default user data schema, and add various
 def addressInvariant(data):
     check = check_apyb_membership(data.email)
     if check == 'invalid':
         raise Invalid(_(u"The email address you provided does not match any APyB merbership account."))
     elif check == 'inactive':
         raise Invalid(_(u"Your APyB merbership is inactive and needs to be renewed."))
class ISpeaker(form.Schema):
    """A conference speaker or leader of a workshop. Speaker can be added anywhere.
    """

    title = schema.TextLine(title=_(u"Your complete name"), )

    lastname = schema.TextLine(title=_(u"Last name"), )

    firstname = schema.TextLine(
        title=_(u"First name"),
        required=True,
    )

    street = schema.TextLine(
        title=_(u"Street"),
        description=
        _(u"For those requiring visa, please add your full postal address details"
          ),
        required=False,
    )

    city = schema.TextLine(
        title=_(u"City"),
        description=
        _(u"For those requiring visa, please add your full postal address details"
          ),
        required=False,
    )

    postalcode = schema.TextLine(
        title=_(u"Postal Code"),
        description=
        _(u"For those requiring visa, please add your full postal address details"
          ),
        required=False,
    )

    country = schema.TextLine(
        title=_(u"Country"),
        description=
        _(u"For those requiring visa, please add your full postal address details"
          ),
        required=False,
    )

    email = schema.TextLine(
        title=_(u"E-Mail"),
        required=True,
    )

    telephonenumber = schema.TextLine(
        title=_(u"Telephone Number"),
        description=
        _(u"Please fill in your telephone number so that we could get in contact with you by phone if necessary."
          ),
        required=False,
    )
    mobiletelepone = schema.TextLine(
        title=_(u"Mobile Telephone Number"),
        description=
        _(u"Please fill in your mobile telephone number so that we could get in contact with you during the conference."
          ),
        required=True,
    )

    organisation = schema.TextLine(
        title=_(u"Organisation"),
        required=False,
    )

    description = schema.Text(title=_(u"A short bio"), )

    bio = RichText(title=_(u"Bio"), required=False)

    picture = NamedBlobImage(
        title=_(u"Picture"),
        description=_(u"Please upload an image"),
        required=False,
    )
Beispiel #32
0
class ITalk(form.Schema):
    """A conference talk. Talks are managed inside tracks of the Program.
    """

    length = SimpleVocabulary([
        SimpleTerm(value=u'30', title=_(u'30 minutes')),
        SimpleTerm(value=u'45', title=_(u'45 minutes')),
        SimpleTerm(value=u'60', title=_(u'60 minutes'))
    ])

    #    talktrack = SimpleVocabulary(
    #       [SimpleTerm(value=u'UX', title=_(u'Usability')),
    #        SimpleTerm(value=u'Core-Development', title=_(u'Development in the Core')),
    #        SimpleTerm(value=u'Extension-Development', title=_(u'Development of Extensions')),]
    #        )

    title = schema.TextLine(
        title=_(u"Title"),
        description=_(u"Talk title"),
    )

    description = schema.Text(title=_(u"Talk summary"), )

    form.primary('details')
    details = RichText(title=_(u"Talk details"), required=True)

    # use an autocomplete selection widget instead of the default content tree
    form.widget(speaker=AutocompleteFieldWidget)
    speaker = RelationChoice(
        title=_(u"Presenter"),
        source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
        required=False,
    )
    form.widget(speaker=AutocompleteFieldWidget)
    speaker2 = RelationChoice(
        title=_(u"Co-Presenter"),
        source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
        required=False,
    )
    form.widget(track=AutocompleteFieldWidget)
    track = RelationChoice(
        title=_(u"Track"),
        source=ObjPathSourceBinder(object_provides=ITrack.__identifier__),
        required=False,
    )

    #
    #    start = schema.Datetime(
    #            title=_(u"Startdate"),
    #            description =_(u"Start date"),
    #            required=False,
    #        )
    #
    #    end = schema.Datetime(
    #            title=_(u"Enddate"),
    #            description =_(u"End date"),
    #            required=False,
    #        )
    #    talktrack= schema.Choice(
    #               title=_(u"Choose the Track for the Talk"),
    #               vocabulary=talktrack,
    #               required=True,
    #               )

    length = schema.Choice(
        title=_(u"Length"),
        vocabulary=length,
        required=True,
    )
    dexterity.write_permission(order='collective.conference.ModifyTrack')
    order = schema.Int(
        title=_(u"Orderintrack"),
        description=_(u"Order in the track: write in an Integer from 1 to 12"),
        min=1,
        max=12,
        required=False,
    )

    slides = NamedBlobFile(
        title=_(u"Presentation slides"),
        description=_(u"Please upload your presentation"),
        required=False,
    )

    creativecommonslicense = schema.Bool(
        title=_(
            u'label_creative_commons_license',
            default=
            u'License is Creative Commons Attribution-Share Alike 3.0 License.'
        ),
        description=_(
            u'help_creative_commons_license',
            default=
            u'You agree that your talk and slides are provided under the Creative Commons Attribution-Share Alike 3.0 License.'
        ),
        default=True)

    dexterity.read_permission(reviewNotes='cmf.ReviewPortalContent')
    dexterity.write_permission(reviewNotes='cmf.ReviewPortalContent')
    reviewNotes = schema.Text(
        title=u"Review notes",
        required=False,
    )
Beispiel #33
0
class StartBeforeEnd(Invalid):
    __doc__ = _(u"The start or end date is invalid")
 def validateStartEnd(data):
     if data.start is not None and data.end is not None:
         if data.start > data.end:
             raise StartBeforeEnd(_(
                 u"The start date must be before the end date."))
def validateEmail(value):
    if not checkEmail(value):
        raise Invalid(_(u"Invalid email address"))
    return True
Beispiel #36
0

grok.global_utility(TShirtSize, IVocabularyFactory, name="collective.conference.vocabulary.tshirtsize")


class Countries(object):
    def __call__(self, context):
        return SimpleVocabulary.fromValues(
            sorted([i.decode("utf-8") for i, c in countrydata.cn_to_ccn.items() if c != "248"])
        )


grok.global_utility(Countries, IVocabularyFactory, name="collective.conference.vocabulary.countries")

session_type = [
    ("Talk", "Talk", _(u"Talk")),
    ("Workshop", "Workshop", _(u"Workshop")),
    ("Discussion", "Discussion", _(u"Discussion")),
]
session_type_terms = [SimpleTerm(value, token, title) for value, token, title in session_type]


class SessionTypes(object):
    def __call__(self, context):
        return SimpleVocabulary(session_type_terms)


grok.global_utility(SessionTypes, IVocabularyFactory, name="collective.conference.vocabulary.sessiontype")

conference_type = [
    ("Regional Events", "Regional Events", _(u"Regional Events")),
class IWorkshop(form.Schema):
    """A conference workshop. Workshops are managed inside tracks of the Program.
    """
        
    length = SimpleVocabulary(
       [SimpleTerm(value=u'30', title=_(u'30 minutes')),
        SimpleTerm(value=u'45', title=_(u'45 minutes')),
        SimpleTerm(value=u'60', title=_(u'60 minutes'))]
        )
    

    title = schema.TextLine(
            title=_(u"Title"),
            description=_(u"Workshop title"),
        )

    description = schema.Text(
            title=_(u"Workshop summary"),
        )

    form.primary('details')
    details = RichText(
            title=_(u"Workshop details"),
            required=False
        )

    # use an autocomplete selection widget instead of the default content tree
    form.widget(speaker=AutocompleteFieldWidget)
    speaker = RelationChoice(
            title=_(u"Presenter"),
            source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
            required=False,
        )
    form.widget(speaker=AutocompleteFieldWidget)
    speaker2 = RelationChoice(
            title=_(u"Co-Presenter"),
            source=ObjPathSourceBinder(object_provides=ISpeaker.__identifier__),
            required=False,
        )
    form.widget(track=AutocompleteFieldWidget)
    track = RelationChoice(
            title=_(u"Track"),
            source=ObjPathSourceBinder(object_provides=ITrack.__identifier__),
            required=False,
        )
    
        
    
#    start = schema.Datetime(
#            title=_(u"Startdate"),
#            description =_(u"Start date"),
#            required=False,
#        )
#
#    end = schema.Datetime(
#            title=_(u"Enddate"),
#            description =_(u"End date"),
#            required=False,
#        )
    
            
    length= schema.Choice(
            title=_(u"Length"),
            vocabulary=length,
            required=True,
        )
  

      
    order=schema.Int(
           title=_(u"Orderintrack"),               
           description=_(u"Order in the track: write in an Integer"),
           required=False,
        )
                    
    
    slides = NamedBlobFile(
            title=_(u"Workshop slides / material"),
            description=_(u"Please upload your workshop presentation or material about the content of the workshop."),
            required=False,
        )    
Beispiel #38
0
 def validateStartEnd(data):
     if data.start is not None and data.end is not None:
         if data.start > data.end:
             raise StartBeforeEnd(
                 _(u"The start date must be before the end date."))
Beispiel #39
0
    def __call__(self, context):
        terms = []
        levels = [
            ('cloud_system_administration_networks',
             _(u'Cloud, System Administration and Networks')),
            ('community_education', _(u'Community and Education')),
            ('django', _(u'Django')),
            ('enterprise_management', _(u'Enterprise and Management')),
            ('media_networks', _(u'Media and Networks')),
            ('mobility_embedded_systems', _(u'Mobility and Embedded Systems')),
            ('plone', _(u'Plone')),
            ('pyramid', _(u'Pyramid')),
            ('scipy', _(u'Scipy')),
            ('web_wevelopment', _(u'Web Development')),
            ('other', _(u'Other')),
        ]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
def emailValidator(value):
    try:
        return checkEmailAddress(value)
    except:
        raise Invalid(_(u"Invalid email address"))
    def __call__(self, context):
        terms = []
        levels = [('cloud_system_administration_networks',
                   _(u'Cloud, System Administration and Networks')),
                  ('community_education', _(u'Community and Education')),
                  ('django', _(u'Django')),
                  ('enterprise_management', _(u'Enterprise and Management')),
                  ('media_networks', _(u'Media and Networks')),
                  ('mobility_embedded_systems',
                   _(u'Mobility and Embedded Systems')),
                  ('plone', _(u'Plone')),
                  ('pyramid', _(u'Pyramid')),
                  ('scipy', _(u'Scipy')),
                  ('web_wevelopment', _(u'Web Development')),
                  ('other', _(u'Other'))]
        for code, text in levels:
            term = (code, code, text)
            terms.append(SimpleVocabulary.createTerm(*term))

        return SimpleVocabulary(terms)
def maxPhotoSize(value):
    if value is not None:
        if value.getSize()/1024 > 512:
            raise schema.ValidationError(_(u"Please upload image smaller than 512KB"))
class ITraining(form.Schema):
    """
    A training in a conference
    """

    duration = schema.Choice(
        title=_(u'Duration'),
        description=_(u''),
        required=True,
        vocabulary='collective.conference.duration',
    )

    language_talk = schema.Choice(
        title=_(u"Language"),
        required=True,
        description=_(u"Language of your training."),
        vocabulary='collective.conference.languages',
    )

    infrastructure_requirements = schema.Text(
        title=_(u"Training requirements"),
        required=False,
        description=
        _(u"Which software do the student must have installed on her/his own computer?"
          ),
    )

    global_theme = schema.Choice(
        title=_(u"Global theme"),
        required=True,
        description=_(u"What is the subject of your training?"),
        vocabulary='collective.conference.theme',
    )

    level = schema.Choice(
        title=_(u"Level"),
        required=True,
        description=_(u"Level of your training."),
        vocabulary='collective.conference.levels',
    )

    observations = schema.Text(
        title=_(u"Observations"),
        required=False,
        description=_(u"Do you want to give us another information?"),
    )
def emailsValidator(value):
    for email in value:
        try:
            return checkEmailAddress(email)
        except:
            raise Invalid(_(u'%s is an invalid email address') % email)