projects
/
matthijs
/
projects
/
xerxes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f24d380
)
* In the add influence view, preselect the first character if it is the user's only...
author
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 23 Jan 2008 20:11:44 +0000
(21:11 +0100)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 23 Jan 2008 20:11:44 +0000
(21:11 +0100)
influences/views.py
patch
|
blob
|
history
diff --git
a/influences/views.py
b/influences/views.py
index 3b26dac9d3f2b0b9d8959141adc3129d07223fef..41a1ecbe08cbd3db595a3e9b69344a47f80136ab 100644
(file)
--- a/
influences/views.py
+++ b/
influences/views.py
@@
-20,18
+20,23
@@
def add(request, character_id):
message = None
initial = {}
message = None
initial = {}
+ # Get the current user's characters
+ chars = request.user.character_set.all()
+
if (character_id):
initial['character'] = character_id
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
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:
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})
return render_to_response('influences/add.html', {'message' : message, 'form' : f})