Exemplo n.º 1
0
def create_event_for_new_photo(sender, instance, created, **kwargs):
    """
    Create event in timeline
    """

    if created:
        activity.create_event(
            actor_name=instance.author.username,
            actor_id=instance.author.id,
            actor_url=instance.author.profile.get_absolute_url(),
            action_id='project_photo_created',
            action_name='uploaded',
            object_id=instance.id,
            object_name=instance.title,
            object_url=instance.image.url,
            category_id=instance.project.event.id,
            subcategory_id=instance.project.id
        )
Exemplo n.º 2
0
    def setUp(self):
        for i in xrange(3):
            activity.create_event(
                actor_name='Test User %d' % i,
                actor_id='test_user_%d' % i,
                action_name='created',
                action_id='test_event_creation',
                object_name='Test Event %d' % i,
                object_id='test_event_%d' % i,
                category_id='no_aggregation_category'
            )

        for i in xrange(3):
            activity.create_event(
                actor_name='Test User',
                actor_id='test_user',
                action_name='created',
                action_id='test_event_creation',
                object_name='Test Event %d' % i,
                object_id='test_event_%d' % i,
                category_id='aggregation_by_actor'
            )

        for i in xrange(3):
            activity.create_event(
                actor_name='Test User',
                actor_id='test_user',
                action_name='created',
                action_id='test_event_creation',
                object_name='Test Event %d' % i,
                object_id='test_event_%d' % i,
                category_id='aggregation_by_actor_time_splitted'
            )
        for i in xrange(3, 6):
            activity.create_event(
                actor_name='Test User',
                actor_id='test_user',
                action_name='created',
                action_id='test_event_creation',
                object_name='Test Event %d' % i,
                object_id='test_event_%d' % i,
                category_id='aggregation_by_actor_time_splitted',
                created=datetime.now() - timedelta(days=5)
            )

        for i in xrange(3):
            activity.create_event(
                actor_name='Test User %d' % i,
                actor_id='test_user_%d' % i,
                action_name='created',
                action_id='test_event_creation',
                object_name='Test Event',
                object_id='test_event',
                category_id='aggregation_by_object'
            )

        for i in xrange(3):
            for t in xrange(3):
                activity.create_event(
                    actor_name='Test User %d' % i,
                    actor_id='test_user_%d' % i,
                    action_name='created',
                    action_id='test_event_creation',
                    object_name='Test Event %d' % t,
                    object_id='test_event_%d' % t,
                    category_id='aggregation_by_object_and_actor'
                )