Only allow users to add NPC or Player characters. master
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 13 Jan 2010 10:21:25 +0000 (11:21 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 13 Jan 2010 15:22:08 +0000 (16:22 +0100)
This prevents normal users from adding contacts. Not sure if this is
what we want yet, though.

influences/views.py

index 8b2961bcb9a5a23b19e806995df18b6366ff4dd3..cf6429f0755dfa98ca21e73225089cc54fce8d88 100644 (file)
@@ -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.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):
 
 @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)
 @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
     if (f.is_valid()):
         character = f.save(commit=False)
         character.player = request.user