Exemple #1
0
 def submit(self, args):
 	from utils.appengine_utilities.sessions import Session
 	session = Session()
 	if not session['user']: return False
 	from .model.account import Account
 	from .model.user import Profile
 	sponsor_type = "personal" # or corporate
 	package = args[0]
 	award_type = args[1]
 	raw_target = [args[2]] # for more than one user. TODO: Front-end.
 	target = []
 	activated = []
 	single_target = False
 	for u in raw_target:
 		# for now, it really is just for one person.  
 	    t = Profile.get(u)
 	    if len(raw_target) > 1: single_target = t
 	    #if single_target == session['user'].key(): return False # can't sponsor yourself 
 	    target.append(t.key())
 	    activated.append(False)
 	from model.account import SponsorPledge
 	new_pledge = SponsorPledge( #specify key name if uniqueness is important, but its not high priority for now. 
 	                           sponsor = session['user'],
 	                           sponsor_type = sponsor_type,
 	                           package = package,
 	                           award_type = award_type,
 	                           target = target,
 	                           type = type,
 	                           activated = activated)
 	
 	# if only a single person is receiving the pledge
 	if single_target:
 		new_pledge.single_target = single_target
 	# if any subject was chosen
 	if args[3] != "any_subject":
 		from model.proficiency import Proficiency
 		new_pledge.proficiency = Proficiency.get(args[3])
 		
 	db.put(new_pledge)
 	return True
Exemple #2
0
 def get(self):
         path = tpl_path(QUIZTAKER_PATH + '/widget/widget.html')
         proficiencies = [Proficiency.get(self.request.get('proficiency'))]
         template_values = {'proficiencies': proficiencies}
         self.response.out.write(template.render(path, template_values))