11
11
from esp .customforms .forms import NameField , AddressField
12
12
from esp .customforms .DynamicModel import DMH
13
13
from esp .utils .forms import DummyField
14
- from esp .users .models import ContactInfo
14
+ from esp .users .models import ContactInfo , ESPUser
15
15
from esp .cache import cache_function
16
16
from esp .program .models import Program
17
17
@@ -623,7 +623,10 @@ def getResponseData(self, form):
623
623
624
624
# Add in the user column if form is not anonymous
625
625
if not form .anonymous :
626
- response_data ['questions' ].append (['user_id' , 'User' , 'fk' ])
626
+ response_data ['questions' ].append (['user_id' , 'User ID' , 'fk' ])
627
+ response_data ['questions' ].append (['user_display' , 'User' , 'textField' ])
628
+ response_data ['questions' ].append (['user_email' , 'User e-mail' , 'textField' ])
629
+ response_data ['questions' ].append (['username' , 'Username' , 'textField' ])
627
630
628
631
# Add in the column for link fields, if any
629
632
if form .link_type != "-1" :
@@ -646,14 +649,20 @@ def getResponseData(self, form):
646
649
# Include this field only if it isn't a dummy field
647
650
elif generic_fields [ftype ]['typeMap' ] is not DummyField :
648
651
response_data ['questions' ].append ([qname , field ['label' ], ftype ])
649
-
652
+
653
+ users = ESPUser .objects .in_bulk (map (lambda response : response ['user_id' ], responses ))
654
+
650
655
# Now let's set up the responses
651
656
for response in responses :
652
657
link_instances_cache = {}
653
658
654
659
# Add in user if form is not anonymous
655
660
if not form .anonymous :
661
+ user = users [response ['user_id' ]]
656
662
response ['user_id' ] = unicode (response ['user_id' ])
663
+ response ['user_display' ] = user .name ()
664
+ response ['user_email' ] = user .email
665
+ response ['username' ] = user .username
657
666
658
667
# Add in links
659
668
if only_fkey_model is not None :
0 commit comments