Ejemplo n.º 1
0
def _get_poll_plugin(context, request):
    assert IPoll.providedBy(context), "Not a poll object"
    try:
        return request.registry.getAdapter(context, IPollPlugin, context.poll_plugin_name)
    except ComponentLookupError:
        msg = _(u"poll_plugin_not_found_error",
                default = u"This poll uses a plugin that can't be found. Make sure a poll "
                          u"plugin with the name '${name}' is installed",
                mapping = {'name': context.poll_plugin_name})
        raise HTTPForbidden(msg)
Ejemplo n.º 2
0
def _get_poll_plugin(context, request):
    assert IPoll.providedBy(context), "Not a poll object"
    try:
        return request.registry.getAdapter(context, IPollPlugin,
                                           context.poll_plugin_name)
    except ComponentLookupError:
        msg = _(
            u"poll_plugin_not_found_error",
            default=
            u"This poll uses a plugin that can't be found. Make sure a poll "
            u"plugin with the name '${name}' is installed",
            mapping={'name': context.poll_plugin_name})
        raise HTTPForbidden(msg)
Ejemplo n.º 3
0
def proposal_choices_widget(node, kw):
    context = kw['context']
    #Proposals to vote on
    proposal_choices = set()
    agenda_item = find_interface(context, IAgendaItem)
    if agenda_item is None:
        Exception("Couldn't find the agenda item from this polls context")
        
    #Get valid proposals - should be in states 'published' to be selectable
    for prop in agenda_item.get_content(iface=IProposal, states='published', sort_on='title'):
        proposal_choices.add((prop.uid, prop.title, ))

    # get currently chosen proposals
    if IPoll.providedBy(context):
        for prop in context.get_proposal_objects():
            proposal_choices.add((prop.uid, prop.title, ))

    proposal_choices = sorted(proposal_choices, key=lambda proposal: proposal[1].lower())
    return deform.widget.CheckboxChoiceWidget(values=proposal_choices)
Ejemplo n.º 4
0
def proposal_choices_widget(node, kw):
    context = kw['context']
    #Proposals to vote on
    proposal_choices = set()
    agenda_item = find_interface(context, IAgendaItem)
    if agenda_item is None:
        Exception("Couldn't find the agenda item from this polls context")
        
    #Get valid proposals - should be in states 'published' to be selectable
    for prop in agenda_item.get_content(iface=IProposal, states='published', sort_on='title'):
        proposal_choices.add((prop.uid, prop.title, ))

    # get currently chosen proposals
    if IPoll.providedBy(context):
        for prop in context.get_proposal_objects():
            proposal_choices.add((prop.uid, prop.title, ))

    proposal_choices = sorted(proposal_choices, key=lambda proposal: proposal[1].lower())
    return deform.widget.CheckboxChoiceWidget(values=proposal_choices)
Ejemplo n.º 5
0
def evolve(root):
    """ Change all poll descriptions to plaintext. """
    from arche.interfaces import ICataloger
    from arche.utils import find_all_db_objects
    from webhelpers.html.render import sanitize

    #Move description to body
    root.body = root.description
    root.description = ""
    ICataloger(root).index_object()

    for obj in find_all_db_objects(root):
        if IPoll.providedBy(obj):
            #Turn description into plaintext
            obj.description = sanitize(obj.description)
            ICataloger(obj).index_object()
        elif IMeeting.providedBy(obj):
            #Move HTML field content to body
            obj.body = obj.description
            obj.description = ""
            ICataloger(obj).index_object()