Rename Influence.character to iniatator.
authorMatthijs Kooijman <matthijs@stdin.nl>
Thu, 27 Nov 2008 22:33:31 +0000 (23:33 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Sat, 10 Jan 2009 12:04:37 +0000 (13:04 +0100)
SQL: ALTER TABLE `influences_influence` CHANGE `character_id` `initiator_id` INT( 11 ) NOT NULL;

influences/admin.py
influences/forms.py
influences/models.py
influences/views.py
templates/influences/influence_detail.html

index 8abe6cc5334ec9c26847747d4b57baf6f5268216..487b237344c0c3c09a0c59936c64df73ea4e27fe 100644 (file)
@@ -18,9 +18,9 @@ class CharacterAdmin(admin.ModelAdmin):
 admin.site.register(Character, CharacterAdmin)
 
 class InfluenceAdmin(admin.ModelAdmin):
-    list_filter=('character', 'status', 'longterm', 'todo')
-    search_fields=('character', 'summary', 'description', 'contact')
-    list_display=('character', 'contact', 'summary', 'longterm', 'status') 
+    list_filter=('initiator', 'status', 'longterm', 'todo')
+    search_fields=('initiator', 'summary', 'description', 'contact')
+    list_display=('initiator', 'summary', 'longterm', 'status') 
 
     class Media:
         js = ('base/js/yahoo-dom-event.js', 'base/js/logger-debug.js')
index 7db751735048eb1affbf7ad7608b4a41606b9ffc..a5f414fcf3a5b4f0392a36f9ff0b3b771a10afed 100644 (file)
@@ -67,7 +67,7 @@ def _get_influence_comment_form(allow_markup, allow_public, allow_private):
 class InfluenceForm(ContextModelForm):
     class Meta:
         model = Influence
-        fields = ('character', 'contact', 'summary', 'description')
+        fields = ('initiator', 'contact', 'summary', 'description')
 
 class CharacterForm(ContextModelForm):
     class Meta:
index f9fc526352da7948987ae39b0739ad613dbacf5c..796d8f43c83bb9c7342172d58ec5ae385fc6c3f5 100644 (file)
@@ -38,7 +38,7 @@ class Influence(models.Model):
     created     = models.DateField(auto_now_add=1, verbose_name = _("Creation time"))
     modified    = models.DateField(auto_now=1, verbose_name = _("Modification time"))
     
-    character   = models.ForeignKey(Character, verbose_name = _("Character"))
+    initiator   = models.ForeignKey(Character, verbose_name = _("Initiator"), related_name='initiated_influences')
     contact     = models.CharField(max_length=255, verbose_name = _("Contact Name"))
     summary     = models.CharField(max_length=255, verbose_name = _("Summary"))
     description = models.TextField(verbose_name = _("Description"))
index 7f7b2621f918a588e03e7e356853b0d45514ffb7..b202c075efab02375cbe8a735a15cc14607b111d 100644 (file)
@@ -24,9 +24,9 @@ def add_influence(request, character_id=None):
     # If a character_id was specified in the url, or there is only one
     # character, preselect it.
     if (character_id):
-        initial['character'] = character_id
+        initial['initiator'] = character_id
     elif (chars.count() == 1):
-        initial['character'] = chars[0].id
+        initial['initiator'] = chars[0].id
 
 
     f = InfluenceForm(request=request, initial=initial)
@@ -34,7 +34,7 @@ def add_influence(request, character_id=None):
     # Only allow characters of the current user. Putting this here also
     # ensures that a form will not validate when any other choice was
     # selected (perhaps through URL crafting).
-    f.fields['character']._set_queryset(chars)
+    f.fields['initiator']._set_queryset(chars)
 
     if (f.is_valid()):
         # The form was submitted, let's save it.
@@ -59,7 +59,7 @@ def add_character(request):
 def index(request):
     # Only show this player's characters and influences
     characters = request.user.character_set.all()
-    influences = Influence.objects.filter(character__player=request.user)
+    influences = Influence.objects.filter(initiator__player=request.user)
     return render_to_response('influences/index.html', {'characters' : characters, 'influences' : influences}, RequestContext(request))
 
 #
@@ -86,7 +86,7 @@ def character_detail(request, object_id):
 @login_required
 def influence_list(request):
     # Only show this player's influences
-    os = Influence.objects.filter(character__player=request.user)
+    os = Influence.objects.filter(initiator__player=request.user)
     return render_to_response('influences/influence_list.html', {'object_list' : os}, RequestContext(request))
 
 def influence_comment_preview(request, context_processors, extra_context, **kwargs):
@@ -101,7 +101,7 @@ 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.character.player != request.user):
+    if (not request.user.is_staff and o.initiator.player != request.user):
         return HttpResponseForbidden("Forbidden -- Trying to view influences of somebody else's character")
 
     # Show all comments to staff, but only public comments to other
index 61547ea59935c3699326f4d5816c51ce20195c56..51940414dc21cda68eb6f73265ad695ea9c12590 100644 (file)
@@ -5,7 +5,7 @@
 <h1>{{ object.summary }}</h1>
 <table>
 <tr><td>{% trans "Contact" %}:</td><td>{{ object.contact }}</td></tr>
-<tr><td>{% trans "Character" %}:</td><td><a href="{% url influences_character_detail object.character.id %}">{{ object.character }}</a></td></tr>
+<tr><td>{% trans "Iniator" %}:</td><td><a href="{% url influences_character_detail object.initiator.id %}">{{ object.initiator }}</a></td></tr>
 {% if object.longterm %}
 <tr><td>{% trans "Long term" %}:</td><td>{{ object.longterm|yesno|capfirst }}</td></tr>
 {% endif %}