def model(request, content_type_id): """ ``Actor`` focused activity stream for actor defined by ``content_type_id``, ``object_id`` """ ctype = get_object_or_404(ContentType, pk=content_type_id) actor = ctype.model_class() return render_to_response('activity/actor.html', { 'action_list': model_stream(actor),'ctype':ctype,'actor':ctype#._meta.verbose_name_plural.title() }, context_instance=RequestContext(request))
def test_zombies(self): from random import choice, randint humans = [Player.objects.create() for i in range(10)] zombies = [Player.objects.create(state=1) for _ in range(2)] while len(humans): for z in zombies: if not len(humans): break victim = choice(humans) humans.pop(humans.index(victim)) victim.state = 1 victim.save() zombies.append(victim) action.send(z,verb='killed',target=victim) self.assertEqual(map(unicode,model_stream(Player))[:5], map(unicode,Action.objects.order_by('-timestamp')[:5]))
def items(self, model): i = model_stream(model) if i: return i[:30] return []