equal
deleted
inserted
replaced
20 __authors__ = [ |
20 __authors__ = [ |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
22 ] |
22 ] |
23 |
23 |
24 |
24 |
25 import datetime |
|
26 import itertools |
25 import itertools |
27 import logging |
26 import logging |
28 import random |
27 import random |
29 |
28 |
30 from google.appengine.api import users |
29 from google.appengine.api import users |
52 from soc.models.timeline import Timeline |
51 from soc.models.timeline import Timeline |
53 from soc.models.user import User |
52 from soc.models.user import User |
54 |
53 |
55 |
54 |
56 class Error(Exception): |
55 class Error(Exception): |
|
56 """Base class for all exceptions raised by this module. |
|
57 """ |
|
58 |
57 pass |
59 pass |
58 |
60 |
59 |
61 |
60 def ensureUser(): |
62 def ensureUser(): |
61 """Returns the current user account and associated user object. |
63 """Returns the current user account and associated user object. |
122 |
124 |
123 site = Site(**site_properties) |
125 site = Site(**site_properties) |
124 site.put() |
126 site.put() |
125 |
127 |
126 |
128 |
127 account, current_user = ensureUser() |
129 _, current_user = ensureUser() |
128 |
130 |
129 |
131 |
130 for i in range(15): |
132 for i in range(15): |
131 seed_and_put_example_user(i) |
133 seed_and_put_example_user(i) |
132 |
134 |
403 |
405 |
404 def seed_org_app(request, i): |
406 def seed_org_app(request, i): |
405 """Returns the properties for a new org proposal, |
407 """Returns the properties for a new org proposal, |
406 """ |
408 """ |
407 |
409 |
408 account, current_user = ensureUser() |
410 _, current_user = ensureUser() |
409 status = request.GET.get('status', 'pre-accepted') |
411 status = request.GET.get('status', 'pre-accepted') |
410 gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
412 gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
411 |
413 |
412 if not gsoc2009: |
414 if not gsoc2009: |
413 raise Error('Run seed_db first') |
415 raise Error('Run seed_db first') |
442 |
444 |
443 def seed_org(request, i): |
445 def seed_org(request, i): |
444 """Returns the properties for a new org entity. |
446 """Returns the properties for a new org entity. |
445 """ |
447 """ |
446 |
448 |
447 account, current_user = ensureUser() |
449 _, current_user = ensureUser() |
448 gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
450 gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
449 |
451 |
450 if not gsoc2009: |
452 if not gsoc2009: |
451 raise Error('Run seed_db first') |
453 raise Error('Run seed_db first') |
452 |
454 |
476 |
478 |
477 def seed_mentor(request, i): |
479 def seed_mentor(request, i): |
478 """Returns the properties of a new student proposal. |
480 """Returns the properties of a new student proposal. |
479 """ |
481 """ |
480 |
482 |
481 account, current_user = ensureUser() |
483 _, current_user = ensureUser() |
482 org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
484 org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
483 |
485 |
484 if not org: |
486 if not org: |
485 raise Error('Run seed_many for at least %d orgs first.' % i) |
487 raise Error('Run seed_many for at least %d orgs first.' % i) |
486 |
488 |
509 |
511 |
510 def seed_student_proposal(request, i): |
512 def seed_student_proposal(request, i): |
511 """Returns the properties of a new student proposal. |
513 """Returns the properties of a new student proposal. |
512 """ |
514 """ |
513 |
515 |
514 account, current_user = ensureUser() |
516 _, current_user = ensureUser() |
515 org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
517 org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
516 mentor = Mentor.get_by_key_name('google/gsoc2009/org_%d/mentor' % i) |
518 mentor = Mentor.get_by_key_name('google/gsoc2009/org_%d/mentor' % i) |
517 |
519 |
518 if not org: |
520 if not org: |
519 raise Error('Run seed_many for at least %d orgs first.' % i) |
521 raise Error('Run seed_many for at least %d orgs first.' % i) |
682 """ |
684 """ |
683 |
685 |
684 # there no explicit ranker model anywhere, so make one for |
686 # there no explicit ranker model anywhere, so make one for |
685 # our own convenience to delete all rankers |
687 # our own convenience to delete all rankers |
686 class ranker(db.Model): |
688 class ranker(db.Model): |
|
689 """ranker model used with ranklist module. |
|
690 """ |
|
691 |
687 pass |
692 pass |
688 |
693 |
689 # TODO(dbentley): If there are more than 1000 instances of any model, |
694 # TODO(dbentley): If there are more than 1000 instances of any model, |
690 # this method will not clear all instances. Instead, it should continually |
695 # this method will not clear all instances. Instead, it should continually |
691 # call .all(), delete all those, and loop until .all() is empty. |
696 # call .all(), delete all those, and loop until .all() is empty. |