author | Sverre Rabbelier <srabbelier@gmail.com> |
Mon, 16 Mar 2009 23:55:04 +0000 | |
changeset 1907 | 8e1ea5609325 |
parent 1906 | 224f597846b5 |
child 1929 | 1ce28a2dd71f |
permissions | -rw-r--r-- |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
2 |
# |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
4 |
# |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
7 |
# You may obtain a copy of the License at |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
8 |
# |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
10 |
# |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
15 |
# limitations under the License. |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
16 |
|
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
17 |
"""Seeds or clears the datastore. |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
18 |
""" |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
19 |
|
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
20 |
__authors__ = [ |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
22 |
] |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
23 |
|
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
24 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
25 |
import datetime |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
import itertools |
1905
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
27 |
import random |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
29 |
from google.appengine.api import users |
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
30 |
from google.appengine.api import memcache |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
31 |
from google.appengine.ext import db |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
33 |
from django import http |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
34 |
|
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
35 |
from soc.logic.models.ranker_root import logic as ranker_root_logic |
1798
ba4c00bc0c39
Use accounts.getCurrentAccount instead of users.get_current_user
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1794
diff
changeset
|
36 |
from soc.logic import accounts |
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
37 |
from soc.logic import dicts |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
38 |
from soc.models import student_proposal |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
39 |
from soc.models.document import Document |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
40 |
from soc.models.host import Host |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
41 |
from soc.models.mentor import Mentor |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
from soc.models.notification import Notification |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
43 |
from soc.models.org_admin import OrgAdmin |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
44 |
from soc.models.organization import Organization |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
45 |
from soc.models.org_app import OrgApplication |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
46 |
from soc.models.program import Program |
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
47 |
from soc.models.ranker_root import RankerRoot |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
48 |
from soc.models.site import Site |
1905
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
49 |
from soc.models.student_proposal import StudentProposal |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
50 |
from soc.models.sponsor import Sponsor |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
51 |
from soc.models.timeline import Timeline |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
52 |
from soc.models.user import User |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
55 |
class Error(Exception): |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
56 |
pass |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
57 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
58 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
59 |
def ensureUser(): |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
60 |
"""Returns the current user account and associated user object. |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
61 |
""" |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
62 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
63 |
account = accounts.getCurrentAccount() |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
64 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
65 |
if not account: |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
66 |
account = users.User(email='test@example.com') |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
67 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
68 |
user_properties = { |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
69 |
'key_name': 'test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
70 |
'link_id': 'test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
71 |
'account': account, |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
72 |
'name': 'Test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
73 |
} |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
74 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
75 |
current_user = User(**user_properties) |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
76 |
current_user.put() |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
77 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
78 |
return account, current_user |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
79 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
80 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
81 |
def seed(request, *args, **kwargs): |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
"""Seeds the datastore with some default values. |
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
83 |
|
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
84 |
Understands the following GET args: |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
85 |
many_users: create 200 users instead of 15, out of which 100 have |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
86 |
a e-mail address in the auth domain |
1792
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
87 |
user_start: where to start adding new users at |
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
88 |
user_end: where to stop adding new users at |
1793
fd77432057b0
Make it possible to only add users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1792
diff
changeset
|
89 |
user_goal: how many users to add in total, implies user_only |
1792
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
90 |
user_step: how many users to add per request, defaults to 15 |
1793
fd77432057b0
Make it possible to only add users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1792
diff
changeset
|
91 |
user_only: stop after adding new users |
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
92 |
many_orgs: create 200 pre-accepted and 200 pre-denied org apps |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
93 |
instead of just 1- pre-accepted ones, also create 200 |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
94 |
orgs instead of just 15. |
1792
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
95 |
|
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
96 |
user is redirected to if user_end < user_goal, incrementing both |
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
97 |
user_start and user_end with user_step. |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
98 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
99 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
100 |
get_args = request.GET |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
101 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
102 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
103 |
site_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
104 |
'key_name': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
105 |
'link_id': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
106 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
107 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
108 |
site = Site(**site_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
109 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
110 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
111 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
112 |
account, current_user = ensureUser() |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
113 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
114 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
115 |
for i in range(15): |
1602
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
116 |
user_properties = { |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
117 |
'key_name': 'user_%d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
118 |
'link_id': 'user_%d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
119 |
'account': users.User(email='user_%d@example.com' % i), |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
120 |
'name': 'User %d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
121 |
} |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
122 |
entity = User(**user_properties) |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
123 |
entity.put() |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
124 |
|
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
125 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
126 |
group_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
'key_name': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
'link_id': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
'name': 'Google Inc.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
130 |
'short_name': 'Google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
131 |
'founder': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
'email': 'ospo@google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
'description': 'This is the profile for Google.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
135 |
'contact_street': 'Some Street', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
'contact_city': 'Some City', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
'contact_country': 'United States', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
'contact_postalcode': '12345', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
'phone': '1-555-BANANA', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
140 |
'status': 'active', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
141 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
143 |
google = Sponsor(**group_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
144 |
google.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
145 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
146 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
147 |
role_properties = { |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
148 |
'key_name': 'google/test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
149 |
'link_id': 'test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
150 |
'scope': google, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
151 |
'scope_path': 'google', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
152 |
'user': current_user, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
153 |
'given_name': 'Test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
154 |
'surname': 'Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
155 |
'name_on_documents': 'Test Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
156 |
'email': 'test@example.com', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
157 |
'res_street': 'Some Street', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
158 |
'res_city': 'Some City', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
159 |
'res_state': 'Some State', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
160 |
'res_country': 'United States', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
161 |
'res_postalcode': '12345', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
162 |
'phone': '1-555-BANANA', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
163 |
'birth_date': db.DateProperty.now(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
164 |
'agreed_to_tos': True, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
165 |
} |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
166 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
167 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
168 |
google_host = Host(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
169 |
google_host.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
170 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
171 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
172 |
timeline_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
173 |
'key_name': 'google/gsoc2009', |
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
174 |
'link_id': 'gsoc2009', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
175 |
'scope_path': 'google', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
176 |
'scope': google, |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
177 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
178 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
179 |
gsoc2009_timeline = Timeline(**timeline_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
180 |
gsoc2009_timeline.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
181 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
182 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
183 |
program_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
184 |
'key_name': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
185 |
'link_id': 'gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
186 |
'scope_path': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
187 |
'scope': google, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
188 |
'name': 'Google Summer of Code 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
'short_name': 'GSoC 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
190 |
'group_label': 'GSOC', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
191 |
'description': 'This is the program for GSoC 2009.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
192 |
'apps_tasks_limit': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
193 |
'slots': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
194 |
'workflow': 'gsoc', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
195 |
'timeline': gsoc2009_timeline, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
196 |
'status': 'visible', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
197 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
198 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
199 |
gsoc2009 = Program(**program_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
200 |
gsoc2009.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
201 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
202 |
|
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
203 |
timeline_properties = { |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
204 |
'key_name': 'google/ghop2009', |
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
205 |
'link_id': 'ghop2009', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
206 |
'scope_path': 'google', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
207 |
'scope': google, |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
208 |
} |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
209 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
210 |
ghop2009_timeline = Timeline(**timeline_properties) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
211 |
ghop2009_timeline.put() |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
212 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
213 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
214 |
program_properties.update({ |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
215 |
'key_name': 'google/ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
216 |
'link_id': 'ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
217 |
'name': 'Google Highly Open Participation Contest 2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
218 |
'short_name': 'GHOP 2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
219 |
'group_label': 'GHOP', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
220 |
'description': 'This is the program for GHOP 2009.', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
221 |
'workflow': 'ghop', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
222 |
'timeline': ghop2009_timeline, |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
223 |
}) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
224 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
225 |
ghop2009 = Program(**program_properties) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
226 |
ghop2009.put() |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
227 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
228 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
229 |
org_app_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
230 |
'scope_path': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
231 |
'scope': gsoc2009, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
232 |
'applicant': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
233 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
234 |
'email': 'org@example.com', |
1562
0e1a93e0c54d
Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1475
diff
changeset
|
235 |
'irc_channel': '#care', |
0e1a93e0c54d
Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1475
diff
changeset
|
236 |
'pub_mailing_list': 'http://groups.google.com', |
0e1a93e0c54d
Made mailing lists and IRC channel required for group/org applications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1475
diff
changeset
|
237 |
'dev_mailing_list': 'http://groups.google.com', |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
238 |
'description': 'This is an awesome org!', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
239 |
'why_applying': 'Because we can', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
240 |
'member_criteria': 'They need to be awesome', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
241 |
'status': 'pre-accepted', |
1429
cfa0c3f2dc19
Update seed_db as WTFPL is no longer an allowed license
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1415
diff
changeset
|
242 |
'license_name': 'Apache License, 2.0', |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
243 |
'ideas': 'http://code.google.com/p/soc/issues', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
244 |
'contrib_disappears': 'We use google to find them', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
245 |
'member_disappears': 'See above', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
246 |
'encourage_contribs': 'We offer them cookies.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
247 |
'continued_contribs': 'We promise them a cake.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
248 |
'agreed_to_admin_agreement': True, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
249 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
250 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
251 |
for i in range(10): |
1368
bd710a3ee7e7
Typo fix in seed_db module which caused loaded organization applications not to work correctly (wrong keyname).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1363
diff
changeset
|
252 |
org_app_properties['key_name'] = 'google/gsoc2009/wannabe_%d' % i |
1362 | 253 |
org_app_properties['link_id'] = 'wannabe_%d' % i |
254 |
org_app_properties['name'] = 'Wannabe %d' % i |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
255 |
entity = OrgApplication(**org_app_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
256 |
entity.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
257 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
258 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
259 |
org_app_properties['status'] = 'pre-rejected' |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
260 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
261 |
for i in range(10, 20): |
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
262 |
org_app_properties['key_name'] = 'google/gsoc2009/loser_%d' % i |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
263 |
org_app_properties['link_id'] = 'loser_%d' % i |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
264 |
org_app_properties['name'] = 'Loser %d' % i |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
265 |
entity = OrgApplication(**org_app_properties) |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
266 |
entity.put() |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
267 |
|
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
268 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
269 |
group_properties.update({ |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
270 |
'key_name': 'google/ghop2009/melange', |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
271 |
'link_id': 'melange', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
272 |
'name': 'Melange Development Team', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
273 |
'short_name': 'Melange', |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
274 |
'scope_path': 'google/ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
275 |
'scope': ghop2009, |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
276 |
'home_page': 'http://code.google.com/p/soc', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
277 |
'description': 'Melange, share the love!', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
278 |
'license_name': 'Apache License', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
279 |
'ideas': 'http://code.google.com/p/soc/issues', |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
280 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
281 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
282 |
melange = Organization(**group_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
283 |
melange.put() |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
284 |
# create a new ranker |
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
285 |
ranker_root_logic.create(student_proposal.DEF_RANKER_NAME, melange, |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
286 |
student_proposal.DEF_SCORE, 100) |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
287 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
288 |
|
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
289 |
group_properties.update({ |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
290 |
'scope_path': 'google/gsoc2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
291 |
'scope': gsoc2009, |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
292 |
}) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
293 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
294 |
for i in range(15): |
1362 | 295 |
group_properties.update({ |
296 |
'key_name': 'google/gsoc2009/org_%d' % i, |
|
297 |
'link_id': 'org_%d' % i, |
|
298 |
'name': 'Organization %d' % i, |
|
299 |
'short_name': 'Org %d' % i, |
|
300 |
'description': 'Organization %d!' % i, |
|
301 |
}) |
|
302 |
||
303 |
entity = Organization(**group_properties) |
|
304 |
entity.put() |
|
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
305 |
# create a new ranker |
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
306 |
ranker_root_logic.create(student_proposal.DEF_RANKER_NAME, entity, |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
307 |
student_proposal.DEF_SCORE, 100) |
1362 | 308 |
|
309 |
||
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
310 |
role_properties.update({ |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
311 |
'key_name': 'google/ghop2009/melange/test', |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
312 |
'link_id': 'test', |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
313 |
'scope_path': 'google/ghop2009/melange', |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
314 |
'scope': melange, |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
315 |
'program': ghop2009, |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
316 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
317 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
318 |
melange_admin = OrgAdmin(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
319 |
melange_admin.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
320 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
321 |
melange_mentor = Mentor(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
322 |
melange_mentor.put() |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
323 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
324 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
325 |
document_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
326 |
'key_name': 'site/site/home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
327 |
'link_id': 'home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
328 |
'scope_path': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
329 |
'scope': site, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
330 |
'prefix': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
331 |
'author': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
332 |
'title': 'Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
333 |
'short_name': 'Home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
334 |
'content': 'This is the Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
335 |
'modified_by': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
336 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
337 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
338 |
home_document = Document(**document_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
339 |
home_document.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
340 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
341 |
|
1415
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
342 |
document_properties = { |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
343 |
'key_name': 'user/test/notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
344 |
'link_id': 'notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
345 |
'scope_path': 'test', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
346 |
'scope': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
347 |
'prefix': 'user', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
348 |
'author': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
349 |
'title': 'My Notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
350 |
'short_name': 'Notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
351 |
'content': 'These are my notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
352 |
'modified_by': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
353 |
} |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
354 |
|
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
355 |
notes_document = Document(**document_properties) |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
356 |
notes_document.put() |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
357 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
358 |
site.home = home_document |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
359 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
360 |
|
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
361 |
memcache.flush_all() |
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
362 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
363 |
return http.HttpResponse('Done') |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
364 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
365 |
|
1902
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
366 |
def seed_user(request, i): |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
367 |
"""Returns the properties for a new user entity. |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
368 |
""" |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
369 |
|
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
370 |
properties = { |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
371 |
'key_name': 'user_%(num)d' % i, |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
372 |
'link_id': 'user_%(num)d' % i, |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
373 |
'account': users.User(email='user_%(num)d@example.com' % i), |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
374 |
'name': 'User %(num)d' % i, |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
375 |
} |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
376 |
|
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
377 |
return properties |
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
378 |
|
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
379 |
|
1907
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
380 |
def seed_org_app(request, i): |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
381 |
"""Returns the properties for a new org proposal, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
382 |
""" |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
383 |
|
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
384 |
account, current_user = ensureUser() |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
385 |
status = request.GET.get('status', 'pre-accepted') |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
386 |
gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
387 |
|
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
388 |
if not gsoc2009: |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
389 |
raise Error('Run seed_db first') |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
390 |
|
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
391 |
properties = { |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
392 |
'key_name': 'google/gsoc2009/org_app_%d' % i, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
393 |
'link_id': 'org_app_%d' % i, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
394 |
'name': 'Org App %d' % i, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
395 |
'scope_path': 'google/gsoc2009', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
396 |
'scope': gsoc2009, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
397 |
'status': status, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
398 |
'applicant': current_user, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
399 |
'home_page': 'http://www.google.com', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
400 |
'email': 'org@example.com', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
401 |
'irc_channel': '#care', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
402 |
'pub_mailing_list': 'http://groups.google.com', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
403 |
'dev_mailing_list': 'http://groups.google.com', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
404 |
'description': 'This is an awesome org!', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
405 |
'why_applying': 'Because we can', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
406 |
'member_criteria': 'They need to be awesome', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
407 |
'license_name': 'Apache License, 2.0', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
408 |
'ideas': 'http://code.google.com/p/soc/issues', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
409 |
'contrib_disappears': 'We use google to find them', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
410 |
'member_disappears': 'See above', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
411 |
'encourage_contribs': 'We offer them cookies.', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
412 |
'continued_contribs': 'We promise them a cake.', |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
413 |
'agreed_to_admin_agreement': True, |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
414 |
} |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
415 |
|
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
416 |
return properties |
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
417 |
|
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
418 |
|
1903
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
419 |
def seed_org(request, i): |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
420 |
"""Returns the properties for a new org entity. |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
421 |
""" |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
422 |
|
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
423 |
account, current_user = ensureUser() |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
424 |
gsoc2009 = Program.get_by_key_name('google/gsoc2009') |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
425 |
|
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
426 |
if not gsoc2009: |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
427 |
raise Error('Run seed_db first') |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
428 |
|
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
429 |
properties = { |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
430 |
'key_name': 'google/gsoc2009/%d' % i, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
431 |
'link_id': 'org_%d' % i, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
432 |
'name': 'Organization %d' % i, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
433 |
'short_name': 'Org %d' % i, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
434 |
'founder': current_user, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
435 |
'scope_path': 'google/gsoc2009', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
436 |
'scope': gsoc2009, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
437 |
'email': 'org_%i@example.com' % i, |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
438 |
'home_page': 'http://code.google.com/p/soc', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
439 |
'description': 'Melange, share the love!', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
440 |
'license_name': 'Apache License', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
441 |
'contact_street': 'Some Street', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
442 |
'contact_city': 'Some City', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
443 |
'contact_country': 'United States', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
444 |
'contact_postalcode': '12345', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
445 |
'phone': '1-555-BANANA', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
446 |
'ideas': 'http://code.google.com/p/soc/issues', |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
447 |
} |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
448 |
|
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
449 |
return properties |
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
450 |
|
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
451 |
|
1904
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
452 |
def seed_mentor(request, i): |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
453 |
"""Returns the properties of a new student proposal. |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
454 |
""" |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
455 |
|
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
456 |
account, current_user = ensureUser() |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
457 |
org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
458 |
|
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
459 |
if not org: |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
460 |
raise Error('Run seed_many for at least %d orgs first.' % i) |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
461 |
|
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
462 |
properties = { |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
463 |
'key_name': 'google/gsoc2009/org_%d/mentor' % i, |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
464 |
'link_id': 'mentor', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
465 |
'scope': org, |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
466 |
'scope_path': org.key().name(), |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
467 |
'user': current_user, |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
468 |
'given_name': 'Mentor', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
469 |
'surname': 'Man', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
470 |
'name_on_documents': 'Mentor Man', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
471 |
'email': 'mentor@example.com', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
472 |
'res_street': 'Some Street', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
473 |
'res_city': 'Some City', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
474 |
'res_state': 'Some State', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
475 |
'res_country': 'United States', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
476 |
'res_postalcode': '12345', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
477 |
'phone': '1-555-BANANA', |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
478 |
'birth_date': db.DateProperty.now(), |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
479 |
'agreed_to_tos': True, |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
480 |
'program': org.scope, |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
481 |
} |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
482 |
|
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
483 |
return properties |
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
484 |
|
1905
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
485 |
def seed_student_proposal(request, i): |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
486 |
"""Returns the properties of a new student proposal. |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
487 |
""" |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
488 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
489 |
account, current_user = ensureUser() |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
490 |
org = Organization.get_by_key_name('google/gsoc2009/%d' % i) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
491 |
mentor = Mentor.get_by_key_name('google/gsoc2009/org_%d/mentor' % i) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
492 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
493 |
if not org: |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
494 |
raise Error('Run seed_many for at least %d orgs first.' % i) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
495 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
496 |
if not mentor: |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
497 |
raise Error('Run seed_many for at least %d mentors first.' % i) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
498 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
499 |
all_properties = [] |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
500 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
501 |
for i in range(random.randint(5, 20)): |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
502 |
link_id = 'proposal_%s_%d' % (org.key().name(), i) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
503 |
scope_path = current_user.key().name() |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
504 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
505 |
properties = { |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
506 |
'link_id': link_id, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
507 |
'scope_path': scope_path, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
508 |
'scope': current_user, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
509 |
'key_name': '%s/%s' % (scope_path, link_id), |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
510 |
'title':'The Awesome Proposal', |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
511 |
'abstract': 'This is an Awesome Proposal, look at its awesomeness!', |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
512 |
'content': 'Sorry, too Awesome for you to read!', |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
513 |
'additional_info': 'http://www.zipit.com', |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
514 |
'mentor': mentor, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
515 |
'status': 'pending', |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
516 |
'org': org, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
517 |
'program': org.scope, |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
518 |
} |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
519 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
520 |
all_properties.append(properties) |
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
521 |
|
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
522 |
return all_properties |
1904
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
523 |
|
1901
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
524 |
def seed_many(request, *args, **kwargs): |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
525 |
"""Seeds many instances of the specified type. |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
526 |
""" |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
527 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
528 |
get_args = request.GET |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
529 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
530 |
if not dicts.containsAll(get_args, ['goal', 'start', 'end', 'seed_type']): |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
531 |
return http.HttpResponse('Missing get args.') |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
532 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
533 |
seed_types = { |
1902
be3dbaa17114
Added seed user to seed many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1901
diff
changeset
|
534 |
'user': (seed_user, User), |
1903
9d95d3e20773
Added seed org support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1902
diff
changeset
|
535 |
'org': (seed_org, Organization), |
1907
8e1ea5609325
Added org app seeding to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1906
diff
changeset
|
536 |
'org_app': (seed_org_app, OrgApplication), |
1904
63b026919efd
Add seed mentor support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1903
diff
changeset
|
537 |
'mentor': (seed_mentor, Mentor), |
1905
8065fd1f3e4c
Added seed student proposal support to seed_many
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1904
diff
changeset
|
538 |
'student_proposal': (seed_student_proposal, StudentProposal), |
1901
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
539 |
} |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
540 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
541 |
goal = int(get_args['goal']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
542 |
start = int(get_args['start']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
543 |
end = int(get_args['end']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
544 |
step = int(get_args.get('step', '15')) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
545 |
seed_type = get_args['seed_type'] |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
546 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
547 |
if not seed_type in seed_types: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
548 |
return http.HttpResponse('Unknown seed_type: "%s".' % seed_type) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
549 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
550 |
action, model = seed_types[seed_type] |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
551 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
552 |
for i in range(start, end): |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
553 |
try: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
554 |
props = action(request, i) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
555 |
except Error, error: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
556 |
return http.HttpResponse(error.message) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
557 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
558 |
for properties in props if isinstance(props, list) else [props]: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
559 |
entity = model(**properties) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
560 |
entity.put() |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
561 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
562 |
if end < goal: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
563 |
info = { |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
564 |
'start': start + step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
565 |
'end': end + step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
566 |
'goal': goal, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
567 |
'step': step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
568 |
'seed_type': seed_type, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
569 |
} |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
570 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
571 |
args = ["%s=%s" % (k, v) for k, v in info.iteritems()] |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
572 |
url = '/seed_many?' + '&'.join(args) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
573 |
return http.HttpResponseRedirect(url) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
574 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
575 |
return http.HttpResponse('Done.') |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
576 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
577 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
578 |
def clear(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
579 |
"""Removes all entities from the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
580 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
581 |
|
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
582 |
# there no explicit ranker model anywhere, so make one for |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
583 |
# our own convenience to delete all rankers |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
584 |
class ranker(db.Model): |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
585 |
pass |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
586 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
587 |
entities = itertools.chain(*[ |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
588 |
Notification.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
589 |
Mentor.all(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
590 |
OrgAdmin.all(), |
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
591 |
ranker.all(), |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
592 |
RankerRoot.all(), |
1906
224f597846b5
Added StudentProposal to clean_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1905
diff
changeset
|
593 |
StudentProposal.all(), |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
594 |
Organization.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
595 |
OrgApplication.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
596 |
Timeline.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
597 |
Program.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
598 |
Host.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
599 |
Sponsor.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
600 |
User.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
601 |
Site.all(), |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
602 |
Document.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
603 |
]) |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
604 |
|
1799
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
605 |
try: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
606 |
for entity in entities: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
607 |
entity.delete() |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
608 |
except db.Timeout: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
609 |
return http.HttpResponseRedirect('#') |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
610 |
|
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
611 |
memcache.flush_all() |
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
612 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
613 |
return http.HttpResponse('Done') |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
614 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
615 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
616 |
def reseed(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
617 |
"""Clears and seeds the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
618 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
619 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
620 |
clear(*args, **kwargs) |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
621 |
seed(*args, **kwargs) |
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
622 |
|
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
623 |
return http.HttpResponse('Done') |