* Make the character list a real character list again and move it /influences/charac...
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 23 Jan 2008 19:54:38 +0000 (20:54 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 23 Jan 2008 19:54:38 +0000 (20:54 +0100)
 * Make a new index at /influences/ with a list of characters and influences.

influences/views.py
templates/influences/character_list.html
templates/influences/index.html [new file with mode: 0644]
urls.py

index 84719024b46dfc642580a4719461936253370aa4..3b26dac9d3f2b0b9d8959141adc3129d07223fef 100644 (file)
@@ -1,6 +1,7 @@
 from django.shortcuts import render_to_response
 from django.shortcuts import get_object_or_404
 from django.utils.translation import ugettext as _
+from django.contrib.auth.models import User
 from ee.influences.models import Character
 from ee.influences.models import Influence
 from ee.tools.forms import ContextModelForm
@@ -45,3 +46,8 @@ def addCharacter(request):
         f = None
 
     return render_to_response('influences/add_character.html', {'message' : message, 'form' : f})
+
+def index(request):
+    characters = request.user.character_set.all()
+    influences = Influence.objects.filter(character__in=characters)
+    return render_to_response('influences/index.html', {'characters' : characters, 'influences' : influences})
index f6760cf93592b953cff023b17f8415e90a820c81..6673138cc4f2416b18492b86080ca548f07fe2c7 100644 (file)
@@ -11,4 +11,3 @@
 {% endif %}
 
 <p><a href="character/add">{% trans "Add character" %}</a></p>
-<p><a href="add">{% trans "Submit influence" %}</a></p>
diff --git a/templates/influences/index.html b/templates/influences/index.html
new file mode 100644 (file)
index 0000000..e95fd02
--- /dev/null
@@ -0,0 +1,28 @@
+{% load i18n %}
+<h2>{% trans "Your characters"%}</h2>
+{% if characters %}
+       <ul>
+       {% for character in characters %}
+               <li><a href="character/{{ character.id }}/">{{ character.name }}</a></li>
+       {% endfor %}
+       </ul>
+{% else %}
+       <p>{% trans "No characters. Add a character first, so you can submit your influences." %}</p>
+{% endif %}
+
+<p><a href="character/add">{% trans "Add character" %}</a></p>
+
+<h2>{% trans "Your influences" %}</h2>
+{% if influences %}
+       <ul>
+       {% for influence in influences %}
+               <!--<li><a href="character/{{ character.id }}/">{{
+        character.name }}</a></li>-->
+        <li>{{ influence.character }} -- {{ influence.contact }} -- {{ influence.description }}</li>
+       {% endfor %}
+       </ul>
+{% else %}
+       <p>{% trans "No influences yet." %}</p>
+{% endif %}
+
+<p><a href="add">{% trans "Submit influence" %}</a></p>
diff --git a/urls.py b/urls.py
index 8890ef5a22951149a7502d2f8d2b7c521d1c6e36..f3f7a1f350cd2665d118e4a2c07dae835d9a27d4 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -10,7 +10,8 @@ urlpatterns = patterns('',
        (r'^events/event/(?P<event_id>\d+)/$', 'ee.events.views.event.detail'),
        (r'^events/event/(?P<event_id>\d+)/regs$', 'ee.events.views.event.regs'),
        (r'^influences/add/(\d+)?/?$', 'ee.influences.views.add'),
-       (r'^influences/$', 'django.views.generic.list_detail.object_list', chars_dict),
+       (r'^influences/$', 'ee.influences.views.index'),
+       (r'^influences/character/$', 'django.views.generic.list_detail.object_list', chars_dict),
        (r'^influences/character/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', chars_dict),
        (r'^influences/character/add/$', 'ee.influences.views.addCharacter'),
        (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'base/login.html'}),