class FavoritingActionAddForm(AddForm):
    form_fields = form.FormFields(IFavoritingAction)
    label = _(u'Add favoriting action')
    description = _(u'An action which can add or remove an object '
                    u'to the user favorites')
    form_name = _p(u'Configure element')

    def create(self, data):
        a = FavoritingAction()
        form.applyChanges(a, self.form_fields, data)
        return a
class IFavoritingAction(interface.Interface):
    """Definition of the configuration available for a favoriting action."""

    favoriting = schema.Choice(
        title=_(u"Change favoriting"),
        vocabulary=favoritingChoice
    )
class FavoritingActionEditForm(EditForm):
    form_fields = form.FormFields(IFavoritingAction)
    label = _(u'Edit favoriting action')
    description = _(u'An action which can add or remove an object '
                    u'to the user favorites')
    form_name = _p(u'Configure element')
class FavoritingAction(SimpleItem):
    interface.implements(IFavoritingAction, IRuleElementData)

    favoriting = 'favorite'
    element = 'collective.favoriting.actions.Favoriting'
    summary = _(u'Change if the object is in the user\'s favorites or not.')
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

from collective.favoriting.i18n import _

favoritingChoice = SimpleVocabulary([
    SimpleTerm('favorite', 'favorite', _(u'Add to favorite')),
    SimpleTerm('unfavorite', 'unfavorite', _(u'Remove from favorite')),
])