From d55284fdb62ff1b4d8dec653bf13cf44b4b01022 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 27 Nov 2008 23:33:31 +0100 Subject: [PATCH] Rename Influence.character to iniatator. SQL: ALTER TABLE `influences_influence` CHANGE `character_id` `initiator_id` INT( 11 ) NOT NULL; --- influences/admin.py | 6 +++--- influences/forms.py | 2 +- influences/models.py | 2 +- influences/views.py | 12 ++++++------ templates/influences/influence_detail.html | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/influences/admin.py b/influences/admin.py index 8abe6cc..487b237 100644 --- a/influences/admin.py +++ b/influences/admin.py @@ -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') diff --git a/influences/forms.py b/influences/forms.py index 7db7517..a5f414f 100644 --- a/influences/forms.py +++ b/influences/forms.py @@ -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: diff --git a/influences/models.py b/influences/models.py index f9fc526..796d8f4 100644 --- a/influences/models.py +++ b/influences/models.py @@ -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")) diff --git a/influences/views.py b/influences/views.py index 7f7b262..b202c07 100644 --- a/influences/views.py +++ b/influences/views.py @@ -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 diff --git a/templates/influences/influence_detail.html b/templates/influences/influence_detail.html index 61547ea..5194041 100644 --- a/templates/influences/influence_detail.html +++ b/templates/influences/influence_detail.html @@ -5,7 +5,7 @@

{{ object.summary }}

- + {% if object.longterm %} {% endif %} -- 2.30.2
{% trans "Contact" %}:{{ object.contact }}
{% trans "Character" %}:{{ object.character }}
{% trans "Iniator" %}:{{ object.initiator }}
{% trans "Long term" %}:{{ object.longterm|yesno|capfirst }}