Show the influence list sorted by character.
authorMatthijs Kooijman <matthijs@stdin.nl>
Fri, 30 Jan 2009 19:39:55 +0000 (20:39 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Fri, 30 Jan 2009 19:39:55 +0000 (20:39 +0100)
(Note that I really mean sorted, not ordered). In addition, this also
shows, for each influence, if the character is only involved in it, or
if he/she initiated it.

influences/views.py
templates/influences/index.html
templates/influences/influence_list_block.html

index e741605e9acad8e94efb4f96552c1ea2daa85c0f..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
index 5f53b5ecca4aab7e511db54dbf0ae6d0ac32ed27..a6a3998bab4e75aed8e1e44c3800b3838cd6f103 100644 (file)
@@ -40,9 +40,7 @@ single page, but I'll add that if that would help.</p>
 {% endwith %}
 
 {% if characters %}
-{% with influences as object_list %}
 {% include "influences/influence_list_block.html" %}
-{% endwith %}
 {% endif %}
 
 {% endblock %}
index e59216f65f9d848a014e234e2de6352ffece8be8..4d74e401ee36594d1dd5d5c60e927a5be8620de0 100644 (file)
@@ -1,14 +1,36 @@
 {% load i18n %}
 
+{# Note that this template looks quite like character_detail_block, it is #}
+{# still different enough to not try and factor out the common parts #}
+{# currently...  #}
+
 <h1>{% trans "Your influences" %}</h1>
-{% if object_list %}
-       <ul>
-       {% for influence in object_list %}
-        <li><a href="{% url influences_influence_detail influence.id %}">{{influence.contact }} -- {{ influence.summary }}</a></li>
-       {% endfor %}
-       </ul>
+{% if characters %}
+       {% for character in characters %}
+               <h2>{{ character.name }}</h2>
+        {% if character.initiated_influences.all or character.influences_involved_in.all %}
+            {% if character.initiated_influences.all %}
+                <p>{% blocktrans with character.name as name %}Influences initiated by {{ name }}:{% endblocktrans %}</p>
+                <ul>
+                {% for influence in character.initiated_influences.all %}
+                    <li><a href="{% url influences_influence_detail influence.id %}">{{influence.contact }} -- {{ influence.summary }}</a></li>
+                {% endfor %}
+                </ul>
+            {% endif %}
+            {% if character.influences_involved_in.all %}
+                <p>{% blocktrans with character.name as name %}Influences {{ name }} is involved in:{% endblocktrans %}</p>
+                <ul>
+                {% for influence in character.influences_involved_in.all %}
+                    <li><a href="{% url influences_influence_detail influence.id %}">{{influence.contact }} -- {{ influence.summary }}</a></li>
+                {% endfor %}
+                </ul>
+            {% endif %}
+        {% else %}
+            <p>{% trans "No influences yet." %}</p>
+        {% endif %}
+    {% endfor %}
 {% else %}
-       <p>{% trans "No influences yet." %}</p>
+       <p>{% trans "No characters. Add a character first, so you can submit your influences." %}</p>
 {% endif %}
 
 <p><a href="{% url influences_add_influence %}">{% trans "Submit influence" %}</a></p>