45 from soc.models.sponsor import Sponsor |
45 from soc.models.sponsor import Sponsor |
46 from soc.models.timeline import Timeline |
46 from soc.models.timeline import Timeline |
47 from soc.models.user import User |
47 from soc.models.user import User |
48 |
48 |
49 |
49 |
50 def seed(*args, **kwargs): |
50 def seed(request, *args, **kwargs): |
51 """Seeds the datastore with some default values. |
51 """Seeds the datastore with some default values. |
|
52 |
|
53 Understands the following GET args: |
|
54 many_users: create 200 users instead of 15, out of which 100 have |
|
55 a e-mail address in the auth domain |
|
56 many_orgs: create 200 pre-accepted and 200 pre-denied org apps |
|
57 instead of just 1- pre-accepted ones, also create 200 |
|
58 orgs instead of just 15. |
52 """ |
59 """ |
|
60 |
|
61 get_args = request.GET |
53 |
62 |
54 |
63 |
55 site_properties = { |
64 site_properties = { |
56 'key_name': 'site', |
65 'key_name': 'site', |
57 'link_id': 'site', |
66 'link_id': 'site', |
75 |
84 |
76 current_user = User(**user_properties) |
85 current_user = User(**user_properties) |
77 current_user.put() |
86 current_user.put() |
78 |
87 |
79 |
88 |
80 for i in range(100): |
89 many_users = get_args.get('many_users') |
|
90 |
|
91 for i in range(100 if many_users else 15): |
81 user_properties = { |
92 user_properties = { |
82 'key_name': 'user_%d' % i, |
93 'key_name': 'user_%d' % i, |
83 'link_id': 'user_%d' % i, |
94 'link_id': 'user_%d' % i, |
84 'account': users.User(email='user_%d@example.com' % i), |
95 'account': users.User(email='user_%d@example.com' % i), |
85 'name': 'User %d' % i, |
96 'name': 'User %d' % i, |
86 } |
97 } |
87 entity = User(**user_properties) |
98 entity = User(**user_properties) |
88 entity.put() |
99 entity.put() |
89 |
100 |
90 |
101 |
91 for i in range(100, 200): |
102 for i in range(100, 200) if many_users else []: |
92 user_properties = { |
103 user_properties = { |
93 'key_name': 'user_%d' % i, |
104 'key_name': 'user_%d' % i, |
94 'link_id': 'user_%d' % i, |
105 'link_id': 'user_%d' % i, |
95 'account': users.User(email='user_%d' % i), |
106 'account': users.User(email='user_%d' % i), |
96 'name': 'User %d' % i, |
107 'name': 'User %d' % i, |
199 }) |
210 }) |
200 |
211 |
201 ghop2009 = Program(**program_properties) |
212 ghop2009 = Program(**program_properties) |
202 ghop2009.put() |
213 ghop2009.put() |
203 |
214 |
|
215 |
|
216 many_orgs = get_args.get('many_orgs') |
204 |
217 |
205 org_app_properties = { |
218 org_app_properties = { |
206 'scope_path': 'google/gsoc2009', |
219 'scope_path': 'google/gsoc2009', |
207 'scope': gsoc2009, |
220 'scope': gsoc2009, |
208 'applicant': current_user, |
221 'applicant': current_user, |
222 'encourage_contribs': 'We offer them cookies.', |
235 'encourage_contribs': 'We offer them cookies.', |
223 'continued_contribs': 'We promise them a cake.', |
236 'continued_contribs': 'We promise them a cake.', |
224 'agreed_to_admin_agreement': True, |
237 'agreed_to_admin_agreement': True, |
225 } |
238 } |
226 |
239 |
227 for i in range(15): |
240 for i in range(200 if many_orgs else 10): |
228 org_app_properties['key_name'] = 'google/gsoc2009/wannabe_%d' % i |
241 org_app_properties['key_name'] = 'google/gsoc2009/wannabe_%d' % i |
229 org_app_properties['link_id'] = 'wannabe_%d' % i |
242 org_app_properties['link_id'] = 'wannabe_%d' % i |
230 org_app_properties['name'] = 'Wannabe %d' % i |
243 org_app_properties['name'] = 'Wannabe %d' % i |
|
244 entity = OrgApplication(**org_app_properties) |
|
245 entity.put() |
|
246 |
|
247 |
|
248 org_app_properties['status'] = 'pre-rejected' |
|
249 |
|
250 for i in range(200, 400) if many_orgs else []: |
|
251 org_app_properties['key_name'] = 'google/gsoc2009/loser_%d' % i |
|
252 org_app_properties['link_id'] = 'loser_%d' % i |
|
253 org_app_properties['name'] = 'Loser %d' % i |
231 entity = OrgApplication(**org_app_properties) |
254 entity = OrgApplication(**org_app_properties) |
232 entity.put() |
255 entity.put() |
233 |
256 |
234 |
257 |
235 group_properties.update({ |
258 group_properties.update({ |
249 melange.put() |
272 melange.put() |
250 # create a new ranker |
273 # create a new ranker |
251 ranker_root_logic.create(student_proposal.DEF_RANKER_NAME, melange, |
274 ranker_root_logic.create(student_proposal.DEF_RANKER_NAME, melange, |
252 student_proposal.DEF_SCORE, 100) |
275 student_proposal.DEF_SCORE, 100) |
253 |
276 |
|
277 |
254 group_properties.update({ |
278 group_properties.update({ |
255 'scope_path': 'google/gsoc2009', |
279 'scope_path': 'google/gsoc2009', |
256 'scope': gsoc2009, |
280 'scope': gsoc2009, |
257 }) |
281 }) |
258 |
282 |
259 for i in range(15): |
283 for i in range(200 if many_orgs else 15): |
260 group_properties.update({ |
284 group_properties.update({ |
261 'key_name': 'google/gsoc2009/org_%d' % i, |
285 'key_name': 'google/gsoc2009/org_%d' % i, |
262 'link_id': 'org_%d' % i, |
286 'link_id': 'org_%d' % i, |
263 'name': 'Organization %d' % i, |
287 'name': 'Organization %d' % i, |
264 'short_name': 'Org %d' % i, |
288 'short_name': 'Org %d' % i, |