Beispiel #1
0
def delete_portlet(context, request):
    slot = request.GET['slot']
    portlet_uid = request.GET['portlet']
    manager = get_portlet_manager(context)
    manager.remove(slot, portlet_uid)
    url = request.resource_url(context, 'manage_portlets')
    return HTTPFound(location = url)
Beispiel #2
0
def delete_portlet(context, request):
    slot = request.GET['slot']
    portlet_uid = request.GET['portlet']
    manager = get_portlet_manager(context)
    manager.remove(slot, portlet_uid)
    url = request.resource_url(context, 'manage_portlets')
    return HTTPFound(location=url)
Beispiel #3
0
def add_portlet(context, request):
    slot = request.GET['slot']
    portlet_type = request.POST['portlet_type']
    manager = get_portlet_manager(context)
    portlet = manager.add(slot, portlet_type)
    url = request.resource_url(context, 'edit_portlet', query = {'slot': slot, 'portlet': portlet.uid})
    return HTTPFound(location = url)
Beispiel #4
0
def get_portlet(request, portlet_uid):
    slot = 'agenda_item'
    manager = get_portlet_manager(request.meeting, request.registry)
    slot_portlets = manager.get(slot, {})
    portlet = slot_portlets.get(portlet_uid, None)
    if portlet is None:
        raise HTTPNotFound("The preprocess portlet wasn't found")
    return portlet
Beispiel #5
0
 def render_portlet_slot(self, slot, **kw):
     results = []
     context = self.context
     while context:
         manager = get_portlet_manager(context, self.request.registry)
         if manager:
             #Use the view context when calling the portlets!
             results.extend(manager.render_slot(slot, self.context, self.request, self, **kw))
         context = getattr(context, '__parent__', None)
     return results
Beispiel #6
0
def evolve(root):
    """ Swap the existing Agenda portets for the fixed agenda portlet type.
    """
    from arche.portlets import get_portlet_manager
    for obj in root.values():
        if IMeeting.providedBy(obj):
            manager = get_portlet_manager(obj)
            for portlet in manager.get_portlets('left', 'agenda'):
                manager.remove('left', portlet.uid)
            if not manager.get_portlets('left_fixed', 'agenda_fixed'):
                manager.add('left_fixed', 'agenda_fixed')
Beispiel #7
0
 def __call__(self):
     forms = {}
     for (name, slotinfo) in self.slots.items():
         forms[name] = self.get_form(name, slotinfo)
     return {
         'slots':
         self.slots,
         'forms':
         forms,
         'portlet_manager':
         get_portlet_manager(self.context, self.request.registry)
     }
Beispiel #8
0
def enable_portlet_toggle(context, request):
    slot = request.GET['slot']
    portlet_uid = request.GET['portlet']
    manager = get_portlet_manager(context)
    try:
        portlet = manager[slot][portlet_uid]
    except KeyError:
        raise HTTPNotFound()
    #Toggle
    portlet.enabled = not portlet.enabled
    url = request.resource_url(context, 'manage_portlets')
    return HTTPFound(location = url)
Beispiel #9
0
def add_default_portlets_meeting(meeting):
    manager = get_portlet_manager(meeting)
    if manager is not None:
        if not manager.get_portlets('agenda_item', 'ai_polls'):
            manager.add('agenda_item', 'ai_polls')
        if not manager.get_portlets('agenda_item', 'ai_proposals'):
            ai_proposals = manager.add('agenda_item', 'ai_proposals')
            ai_proposals.settings = {'hide_proposal_states': ('retracted', 'denied', 'unhandled')}
        if not manager.get_portlets('agenda_item', 'ai_discussions'):
            manager.add('agenda_item', 'ai_discussions')
        if not manager.get_portlets('left_fixed', 'agenda_fixed'):
            manager.add('left_fixed', 'agenda_fixed')
Beispiel #10
0
def add_portlet(context, request):
    slot = request.GET['slot']
    portlet_type = request.POST['portlet_type']
    manager = get_portlet_manager(context)
    portlet = manager.add(slot, portlet_type)
    url = request.resource_url(context,
                               'edit_portlet',
                               query={
                                   'slot': slot,
                                   'portlet': portlet.uid
                               })
    return HTTPFound(location=url)
Beispiel #11
0
def add_portlet(context, request):
    slot = request.GET['slot']
    portlet_type = request.POST['portlet_type']
    manager = get_portlet_manager(context)
    portlet = manager.add(slot, portlet_type)
    settings_schema = getattr(portlet, 'schema_factory', None)
    if settings_schema:
        url = request.resource_url(context, 'edit_portlet', query = {'slot': slot, 'portlet': portlet.uid})
    else:
        fm = IFlashMessages(request)
        fm.add(_("Added"))
        url = request.resource_url(context, 'manage_portlets')
    return HTTPFound(location = url)
Beispiel #12
0
def insert_diff_text_portlet(context, event):
    if event.changed and 'diff_text_enabled' in event.changed:
        manager = get_portlet_manager(context)
        current = manager.get_portlets('agenda_item', 'diff_text')
        if not context.diff_text_enabled:
            for portlet in current:
                manager.remove('agenda_item', portlet.uid)
        else:
            if not current:
                new_portlet = manager.add('agenda_item', 'diff_text')
                ai_slot = manager['agenda_item']
                current_order = list(ai_slot.keys())
                current_order.remove(new_portlet.uid)
                current_order.insert(0, new_portlet.uid)
                ai_slot.order = current_order
Beispiel #13
0
def insert_diff_text_portlet(context, event):
    if event.changed and 'diff_text_enabled' in event.changed:
        manager = get_portlet_manager(context)
        current = manager.get_portlets('agenda_item', 'diff_text')
        if not context.diff_text_enabled:
            for portlet in current:
                manager.remove('agenda_item', portlet.uid)
        else:
            if not current:
                new_portlet = manager.add('agenda_item', 'diff_text')
                ai_slot = manager['agenda_item']
                current_order = list(ai_slot.keys())
                current_order.remove(new_portlet.uid)
                current_order.insert(0, new_portlet.uid)
                ai_slot.order = current_order
Beispiel #14
0
 def render_portlet_slot(self, slot, **kw):
     results = []
     context = self.context
     while context:
         manager = get_portlet_manager(context, self.request.registry)
         if manager:
             #Use the view context when calling the portlets!
             try:
                 results.extend(manager.render_slot(slot, self.context, self.request, self, **kw))
             except Exception as exc:
                 if self.request.registry.settings['arche.debug']:
                     results.append(str(exc))
                 else:
                     warnings.warn(str(exc))
         context = getattr(context, '__parent__', None)
     return results
Beispiel #15
0
 def toggle_portlet(self, enable=True):
     manager = get_portlet_manager(self.context)
     current = manager.get_portlets('agenda_item', 'voteit_debate')
     if not enable:
         for portlet in current:
             manager.remove('agenda_item', portlet.uid)
     else:
         if not current:
             new_portlet = manager.add('agenda_item', 'voteit_debate')
             ai_slot = manager['agenda_item']
             current_order = list(ai_slot.keys())
             pos = current_order.index(new_portlet.uid)
             #Find a good position to insert it - above discussions or proposals
             types = ('ai_proposals', 'ai_discussions')
             for portlet in ai_slot.values():
                 if portlet.portlet_type in types:
                     pos = current_order.index(portlet.uid)
                     break
             current_order.remove(new_portlet.uid)
             current_order.insert(pos, new_portlet.uid)
             ai_slot.order = current_order
Beispiel #16
0
def evolve(root):
    """ Change the Proposals so title and text are separated.
        Old proposals used to have only a title field that could be really long.
        
        Also add portlets to all meetings.
    """
    from arche.utils import find_all_db_objects
    from arche.portlets import get_portlet_manager
    from voteit.core.models.meeting import add_default_portlets_meeting

    manager = get_portlet_manager(root)
    if not manager.get_portlets('right', 'meeting_list'):
        manager.add('right', 'meeting_list')

    for obj in find_all_db_objects(root):
        if IProposal.providedBy(obj):
            try:
                obj.text = obj.field_storage.pop('title')
            except KeyError:
                pass
        elif IMeeting.providedBy(obj):
            add_default_portlets_meeting(obj)
Beispiel #17
0
def adjust_poll_portlet(context, mv_version=True):
    """ Adjust poll portlet to this type"""
    PSLOT = "agenda_item"
    if mv_version:
        portlet_name = MULTI_VOTES_POLLS_PORTLET
        remove_portlet_name = DEFAULT_POLLS_PORTLET
    else:
        portlet_name = DEFAULT_POLLS_PORTLET
        remove_portlet_name = MULTI_VOTES_POLLS_PORTLET
    meeting = find_interface(context, IMeeting)
    assert meeting
    manager = get_portlet_manager(meeting)
    unwanted_portlet = None
    for p in manager.get_portlets(PSLOT, remove_portlet_name):
        unwanted_portlet = p
    if unwanted_portlet:
        manager.remove(PSLOT, unwanted_portlet.uid)
    if not manager.get_portlets(PSLOT, portlet_name):
        added_portlet = manager.add(PSLOT, portlet_name)
        portlet_folder = manager[PSLOT]
        order = list(portlet_folder.order)
        order.remove(added_portlet.uid)
        order.insert(0, added_portlet.uid)
        portlet_folder.order = order
Beispiel #18
0
 def manager(self):
     return get_portlet_manager(self.context, self.request.registry)
Beispiel #19
0
def _add_meeting_list_portlet(root, event):
    from arche.portlets import get_portlet_manager
    manager = get_portlet_manager(root)
    if not manager.get_portlets('right', 'meeting_list'):
        manager.add('right', 'meeting_list')
Beispiel #20
0
def _add_meeting_list_portlet(root, event):
    from arche.portlets import get_portlet_manager
    manager = get_portlet_manager(root)
    if not manager.get_portlets('right', 'meeting_list'):
        manager.add('right', 'meeting_list')
Beispiel #21
0
 def __call__(self):
     manage_portlets_js.need()
     custom_slots = set(self.slots.keys()) - set(['right', 'left', 'top', 'bottom'])
     return {'slots': self.slots,
             'custom_slots': custom_slots,
             'portlet_manager': get_portlet_manager(self.context, self.request.registry)}
Beispiel #22
0
 def portlet_manager(self):
     return get_portlet_manager(self.context, self.request.registry)
Beispiel #23
0
 def __call__(self):
     forms = {}
     for (name, slotinfo) in self.slots.items():
         forms[name] = self.get_form(name, slotinfo)
     return {'slots': self.slots, 'forms': forms,
             'portlet_manager': get_portlet_manager(self.context, self.request.registry)}