app/soc/models/seed_db.py
changeset 1904 63b026919efd
parent 1903 9d95d3e20773
child 1905 8065fd1f3e4c
equal deleted inserted replaced
1903:9d95d3e20773 1904:63b026919efd
   406       }
   406       }
   407 
   407 
   408   return properties
   408   return properties
   409 
   409 
   410 
   410 
       
   411 def seed_mentor(request, i):
       
   412   """Returns the properties of a new student proposal.
       
   413   """
       
   414 
       
   415   account, current_user = ensureUser()
       
   416   org = Organization.get_by_key_name('google/gsoc2009/%d' % i)
       
   417 
       
   418   if not org:
       
   419     raise Error('Run seed_many for at least %d orgs first.' % i)
       
   420 
       
   421   properties = {
       
   422       'key_name': 'google/gsoc2009/org_%d/mentor' % i,
       
   423       'link_id': 'mentor',
       
   424       'scope': org,
       
   425       'scope_path': org.key().name(),
       
   426       'user': current_user,
       
   427       'given_name': 'Mentor',
       
   428       'surname': 'Man',
       
   429       'name_on_documents': 'Mentor Man',
       
   430       'email': 'mentor@example.com',
       
   431       'res_street': 'Some Street',
       
   432       'res_city': 'Some City',
       
   433       'res_state': 'Some State',
       
   434       'res_country': 'United States',
       
   435       'res_postalcode': '12345',
       
   436       'phone': '1-555-BANANA',
       
   437       'birth_date': db.DateProperty.now(),
       
   438       'agreed_to_tos': True,
       
   439       'program': org.scope,
       
   440       }
       
   441 
       
   442   return properties
       
   443 
       
   444 
   411 def seed_many(request, *args, **kwargs):
   445 def seed_many(request, *args, **kwargs):
   412   """Seeds many instances of the specified type.
   446   """Seeds many instances of the specified type.
   413   """
   447   """
   414 
   448 
   415   get_args = request.GET
   449   get_args = request.GET
   418     return http.HttpResponse('Missing get args.')
   452     return http.HttpResponse('Missing get args.')
   419 
   453 
   420   seed_types = {
   454   seed_types = {
   421     'user': (seed_user, User),
   455     'user': (seed_user, User),
   422     'org': (seed_org, Organization),
   456     'org': (seed_org, Organization),
       
   457     'mentor': (seed_mentor, Mentor),
   423     }
   458     }
   424 
   459 
   425   goal = int(get_args['goal'])
   460   goal = int(get_args['goal'])
   426   start = int(get_args['start'])
   461   start = int(get_args['start'])
   427   end = int(get_args['end'])
   462   end = int(get_args['end'])