def create_record_from_invitation(obj, invitation, action,
                                  actor_userid=None, date=None):
    record = ActivityRecord(obj, action,
                            actor_userid=actor_userid, date=date)
    record.attrs['invitation:inviter'] = invitation.inviter
    record.attrs['invitation:email'] = invitation.email
    record.attrs['invitation:roles'] = tuple(invitation.roles)
    return record
示例#2
0
    def test_get_actor_info_for_non_existing_user(self):
        record = ActivityRecord(create(Builder('document')),
                                'added',
                                actor_userid='john.doe')

        self.assertEquals(
            {'url': '',
             'portrait_url': 'http://nohost/plone/defaultUser.png',
             'fullname': 'john.doe'},
            record.get_actor_info())
示例#3
0
def comment_removed(context, comment, actor_userid=None, date=None):
    soup = get_activity_soup()
    record = ActivityRecord(context, 'comment:removed',
                            actor_userid=actor_userid, date=date)
    record.attrs['comment_id'] = comment.comment_id
    record.attrs['comment_text'] = comment.text
    record.attrs['comment_text_mime_type'] = comment.mime_type
    if comment.in_reply_to:
        record.attrs['comment_in_reply_to'] = comment.in_reply_to
    return soup.add(record)
示例#4
0
    def test_get_pretty_date(self):
        doc = create(Builder('document').titled('Foo'))
        record = ActivityRecord(doc, 'added')

        with freeze(datetime(2010, 1, 2)) as clock:
            record = ActivityRecord(doc, 'added')

            clock.forward(days=1)
            self.assertEquals({'relative': u'yesterday',
                               'absolute': DateTime('2010/01/02')},
                              record.get_pretty_date())
示例#5
0
def object_transition(context, actor_userid=None, date=None,
                      transition=None, workflow=None,
                      old_state=None, new_state=None):
    soup = get_activity_soup()
    record = ActivityRecord(context, 'transition',
                            actor_userid=actor_userid, date=date)
    record.attrs['transition'] = transition
    record.attrs['workflow'] = workflow
    record.attrs['old_state'] = old_state
    record.attrs['new_state'] = new_state
    return soup.add(record)
def notification_email_sent_activity(
        obj, event, actor_userid=None, date=None,
        comment=None, to_userids=None, cc_userids=None):
    record = ActivityRecord(obj, 'notification:email_sent',
                            actor_userid=actor_userid, date=date)

    record.attrs['notification:comment'] = comment or event.comment
    record.attrs['notification:to_userids'] = tuple(
        to_userids or event.to_userids)
    record.attrs['notification:cc_userids'] = tuple(
        cc_userids or event.cc_userids)
    return get_activity_soup().add(record)
示例#7
0
    def test_get_object_of_record__dexterity(self):
        doc = create(Builder('dx type').titled(u'Foo'))
        record = ActivityRecord(doc, 'added')

        self.assertEquals(doc, record.get_object())

        aq_parent(aq_inner(doc)).manage_delObjects([doc.getId()])
        self.assertEquals(None, record.get_object(),
                          'get_object should return None if the object is deleted.')

        create(Builder('dx type').titled(u'Foo'))
        self.assertEquals(None, record.get_object(),
                          'get_object should return None when the object at the path'
                          ' is not the same object.')
示例#8
0
    def test_get_actor_info(self, browser):
        self.portal.invokeFactory('Folder', 'Members')
        mtool = getToolByName(self.portal, 'portal_membership')
        mtool.setMemberareaCreationFlag()

        hugo = create(Builder('user').named('Hugo', 'Boss'))
        mtool.createMemberArea(hugo.getId())
        record = ActivityRecord(create(Builder('document')),
                                'added',
                                actor_userid=hugo.getId())

        self.assertEquals(
            {'url': 'http://nohost/plone/Members/hugo.boss',
             'portrait_url': 'http://nohost/plone/defaultUser.png',
             'fullname': 'Boss Hugo'},
            record.get_actor_info())
示例#9
0
def object_moved(context, actor_userid=None, date=None,
                 old_parent=None, new_parent=None):
    soup = get_activity_soup()
    record = ActivityRecord(context, 'moved',
                            actor_userid=actor_userid, date=date)

    if old_parent:
        record.attrs['old_parent_path'] = '/'.join(
            old_parent.getPhysicalPath())
        record.attrs['old_parent_uuid'] = IUUID(old_parent, None)

    if new_parent:
        record.attrs['new_parent_path'] = '/'.join(
            new_parent.getPhysicalPath())
        record.attrs['new_parent_uuid'] = IUUID(new_parent, None)

    return soup.add(record)
示例#10
0
def role_changed(obj, event, actor_userid=None, date=None):
    record = ActivityRecord(obj, 'participation:role_changed',
                            actor_userid=actor_userid, date=date)
    record.attrs['roles:userid'] = event.userid
    record.attrs['roles:old'] = tuple(event.old_roles)
    record.attrs['roles:new'] = tuple(event.new_roles)
    record.attrs['roles:removed'] = tuple(
        set(event.old_roles) - set(event.new_roles))
    record.attrs['roles:added'] = tuple(
        set(event.new_roles) - set(event.old_roles))
    return get_activity_soup().add(record)
示例#11
0
 def test_translated_portal_type(self):
     record = ActivityRecord(create(Builder('document')), 'added')
     self.assertEquals('Document', record.translated_portal_type())
示例#12
0
def role_removed(obj, event, actor_userid=None, date=None):
    record = ActivityRecord(obj, 'participation:role_removed',
                            actor_userid=actor_userid, date=date)
    record.attrs['roles:userid'] = event.userid
    return get_activity_soup().add(record)