SQL: ALTER TABLE `influences_influence` CHANGE `character_id` `initiator_id` INT( 11 ) NOT NULL;
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')
class InfluenceForm(ContextModelForm):
class Meta:
model = Influence
- fields = ('character', 'contact', 'summary', 'description')
+ fields = ('initiator', 'contact', 'summary', 'description')
class CharacterForm(ContextModelForm):
class Meta:
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"))
# 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)
# 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.
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))
#
@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):
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
<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 %}