From: Matthijs Kooijman Date: Wed, 13 Jan 2010 10:21:25 +0000 (+0100) Subject: Only allow users to add NPC or Player characters. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=matthijs%2Fprojects%2Fxerxes.git Only allow users to add NPC or Player characters. This prevents normal users from adding contacts. Not sure if this is what we want yet, though. --- diff --git a/influences/views.py b/influences/views.py index 8b2961b..cf6429f 100644 --- a/influences/views.py +++ b/influences/views.py @@ -14,7 +14,7 @@ from threadedcomments.views import free_comment, _preview from xerxes.influences.models import Character from xerxes.influences.models import Influence from forms import get_influence_comment_form, InfluenceForm, CharacterForm -from xerxes.tools.misc import make_choices +from xerxes.tools.misc import make_choices, filter_choices @login_required def add_influence(request, character_id=None): @@ -60,6 +60,10 @@ def add_influence(request, character_id=None): @login_required def add_character(request): f = CharacterForm(request=request) + f.fields['type'].choices = filter_choices( + f.fields['type'].choices, + [Character.PLAYER, Character.NPC] + ) if (f.is_valid()): character = f.save(commit=False) character.player = request.user