Show the influence list sorted by character.
[matthijs/projects/xerxes.git] / influences / views.py
index b202c075efab02375cbe8a735a15cc14607b111d..ed23bb24d92c7c45560a05a1da94d5f013735c8b 100644 (file)
@@ -85,9 +85,9 @@ def character_detail(request, object_id):
 
 @login_required
 def influence_list(request):
-    # Only show this player's influences
-    os = Influence.objects.filter(initiator__player=request.user)
-    return render_to_response('influences/influence_list.html', {'object_list' : os}, RequestContext(request))
+    # Only show the influences related to this player's characters
+    characters = request.user.character_set.all()
+    return render_to_response('influences/influence_list.html', {'characters' : characters}, RequestContext(request))
 
 def influence_comment_preview(request, context_processors, extra_context, **kwargs):
     # Use a custom template
@@ -101,8 +101,8 @@ def influence_detail(request, object_id):
 
     o = Influence.objects.get(pk=object_id)
     # Don't show other player's influences
-    if (not request.user.is_staff and o.initiator.player != request.user):
-        return HttpResponseForbidden("Forbidden -- Trying to view influences of somebody else's character")
+    if (not request.user.is_staff and not request.user in o.related_players):
+        return HttpResponseForbidden("Forbidden -- Trying to view influences you are not involved in.")
 
     # Show all comments to staff, but only public comments to other
     # users