Esempio n. 1
0
def SearchableText_AgendaDiaria(obj):
    """ Indexa os dados dos compromissos dentro desta AgendaDiaria
        para prover busca por texto integral
    """
    children = obj.objectValues()
    SearchableText = []
    for child in children:
        if not ICompromisso.providedBy(child):
            continue
        # Campos indexaveis
        SearchableText.append(child.title)
        SearchableText.append(child.description)
        SearchableText.append(child.autoridade)
        SearchableText.append(child.location)
        SearchableText.append(child.attendees)
    if not SearchableText:
        SearchableText.append(obj.autoridade)
        SearchableText.append(obj.location)
    # Alteracao da agenda
    update = obj.update
    if safe_hasattr(update, 'output'):
        update = update.output
    SearchableText.append(update)
    return ' '.join(
        [text for text in SearchableText if isinstance(text, basestring)])
def SearchableText_AgendaDiaria(obj):
    """ Indexa os dados dos compromissos dentro desta AgendaDiaria
        para prover busca por texto integral
    """
    children = obj.objectValues()
    SearchableText = []
    for child in children:
        if not ICompromisso.providedBy(child):
            continue
        # Campos indexaveis
        SearchableText.append(child.title)
        SearchableText.append(child.description)
        SearchableText.append(child.autoridade)
        SearchableText.append(child.location)
        SearchableText.append(child.attendees)
    if not SearchableText:
        SearchableText.append(obj.autoridade)
        SearchableText.append(obj.location)
    # Alteracao da agenda
    update = obj.update
    if hasattr(update, 'output'):
        update = update.output
    SearchableText.append(update)
    return ' '.join([text for text in SearchableText
                     if isinstance(text, basestring)])
Esempio n. 3
0
def move_compromisso_para_agendadiaria(event, obj=None):
    """ Toda vez que um tipo compromisso for criado ou tiver sua
        data alterada
        ele sera movido para dentro de uma agenda diaria
    """
    if not obj:
        obj = event.object

    if not ICompromisso.providedBy(obj):  # nao eh um compromisso
        return

    start_date = getattr(obj, 'start_date', None)
    if not start_date:
        return

    formatted_date = start_date.strftime(AGENDADIARIAFMT)
    origin = aq_parent(obj)
    agenda = _get_agenda(origin)

    old_id = obj.getId()
    destination_id = formatted_date

    destination = _get_destination(agenda, obj, origin, destination_id)
    if not IAgendaDiaria.providedBy(destination):
        logger.warn('Objeto %s nao foi movido' % str(obj))
        # Reindexamos o SearchableText de origin
        origin.reindexObject(idxs=[
            'SearchableText',
        ])
        return None

    new_id = _generate_id(destination, old_id)

    # Prepare to move object
    notify(ObjectWillBeMovedEvent(obj, origin, old_id, destination, new_id))
    obj.manage_changeOwnershipType(explicit=1)

    # Remove object from origin
    origin._delObject(old_id, suppress_events=True)
    obj = aq_base(obj)

    # Set new_id -- which is unique on destination
    obj._setId(new_id)

    # Persist object in destination
    destination._setObject(new_id, obj, set_owner=0, suppress_events=True)
    obj = destination._getOb(new_id)
    notify(ObjectMovedEvent(obj, origin, old_id, destination, new_id))
    notifyContainerModified(origin)
    notifyContainerModified(destination)
    obj._postCopy(destination, op=1)
    # try to make ownership implicit if possible
    obj.manage_changeOwnershipType(explicit=0)
    # Reindexamos o SearchableText de destination
    destination.reindexObject(idxs=[
        'SearchableText',
    ])
Esempio n. 4
0
def move_compromisso_para_agendadiaria(event, obj=None):
    """ Toda vez que um tipo compromisso for criado ou tiver sua
        data alterada
        ele sera movido para dentro de uma agenda diaria
    """
    if not obj:
        obj = event.object

    if not ICompromisso.providedBy(obj):  # nao eh um compromisso
        return

    start_date = getattr(obj, 'start_date', None)
    if not start_date:
        return

    formatted_date = start_date.strftime(AGENDADIARIAFMT)
    origin = aq_parent(obj)
    agenda = _get_agenda(origin)

    old_id = obj.getId()
    destination_id = formatted_date

    destination = _get_destination(agenda, obj, origin, destination_id)
    if not IAgendaDiaria.providedBy(destination):
        logger.warn('Objeto %s nao foi movido' % str(obj))
        # Reindexamos o SearchableText de origin
        origin.reindexObject(idxs=['SearchableText', ])
        return None

    new_id = _generate_id(destination, old_id)

    # Prepare to move object
    notify(ObjectWillBeMovedEvent(obj, origin, old_id, destination, new_id))
    obj.manage_changeOwnershipType(explicit=1)

    # Remove object from origin
    origin._delObject(old_id, suppress_events=True)
    obj = aq_base(obj)

    # Set new_id -- which is unique on destination
    obj._setId(new_id)

    # Persist object in destination
    destination._setObject(new_id, obj, set_owner=0, suppress_events=True)
    obj = destination._getOb(new_id)
    notify(ObjectMovedEvent(obj, origin, old_id, destination, new_id))
    notifyContainerModified(origin)
    notifyContainerModified(destination)
    obj._postCopy(destination, op=1)
    # try to make ownership implicit if possible
    obj.manage_changeOwnershipType(explicit=0)
    # Reindexamos o SearchableText de destination
    destination.reindexObject(idxs=['SearchableText', ])
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='Compromisso')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(ICompromisso.providedBy(new_object))
 def test_adding(self):
     self.assertTrue(ICompromisso.providedBy(self.compromisso))
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='Compromisso')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(ICompromisso.providedBy(new_object))
 def test_adding(self):
     self.assertTrue(ICompromisso.providedBy(self.compromisso))