message = None
initial = {}
+ # Get the current user's characters
+ chars = request.user.character_set.all()
+
if (character_id):
initial['character'] = character_id
+ elif (chars.count() == 1):
+ initial['character'] = chars[0].id
f = InfluenceForm(request=request, initial=initial)
if (f.is_valid()):
f.save()
message = _("Influence added.")
f = None
-
+
+ # Only allow characters of the current user
if f:
- # Only allow characters of the current user
- f.fields['character']._set_queryset(request.user.character_set.all())
+ f.fields['character']._set_queryset(chars)
return render_to_response('influences/add.html', {'message' : message, 'form' : f})