author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 15 Feb 2009 22:29:22 +0000 | |
changeset 1360 | f62c462037b6 |
parent 1355 | 7a00bcfa0371 |
child 1362 | 31b2cb6b75d8 |
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 |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
28 |
from google.appengine.api import users |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
29 |
from google.appengine.ext import db |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
31 |
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
|
32 |
from soc.models.host import Host |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
33 |
from soc.models.mentor import Mentor |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
from soc.models.organization import Organization |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
37 |
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
|
38 |
from soc.models.program import Program |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
39 |
from soc.models.site import Site |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
40 |
from soc.models.sponsor import Sponsor |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
41 |
from soc.models.timeline import Timeline |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
42 |
from soc.models.user import User |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
def seed(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
"""Seeds the datastore with some default values. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
49 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
50 |
site_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
51 |
'key_name': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
52 |
'link_id': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
53 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
54 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
55 |
site = Site(**site_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
56 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
57 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
58 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
account = users.get_current_user() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
61 |
if not account: |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
62 |
account = users.User(email='test@example.com') |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
63 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
64 |
user_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
'key_name': 'test', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
'link_id': 'test', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
'account': account, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
'name': 'Test', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
71 |
current_user = User(**user_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
current_user.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
74 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
75 |
group_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
'key_name': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
'link_id': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
'name': 'Google Inc.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
'short_name': 'Google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
'founder': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
81 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
'email': 'ospo@google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
'description': 'This is the profile for Google.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
84 |
'contact_street': 'Some Street', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
85 |
'contact_city': 'Some City', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
'contact_country': 'United States', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
'contact_postalcode': '12345', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
'phone': '1-555-BANANA', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
'status': 'active', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
90 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
92 |
google = Sponsor(**group_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
93 |
google.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
95 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
96 |
role_properties = { |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
97 |
'key_name': 'google/test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
98 |
'link_id': 'test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
99 |
'scope': google, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
100 |
'scope_path': 'google', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
101 |
'user': current_user, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
102 |
'given_name': 'Test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
103 |
'surname': 'Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
104 |
'name_on_documents': 'Test Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
105 |
'email': 'test@example.com', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
106 |
'res_street': 'Some Street', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
107 |
'res_city': 'Some City', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
108 |
'res_state': 'Some State', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
109 |
'res_country': 'United States', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
110 |
'res_postalcode': '12345', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
111 |
'phone': '1-555-BANANA', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
112 |
'birth_date': db.DateProperty.now(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
113 |
'agreed_to_tos': True, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
114 |
} |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
115 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
116 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
117 |
google_host = Host(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
118 |
google_host.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
119 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
120 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
121 |
timeline_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
'key_name': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
123 |
'scope_path': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
124 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
125 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
126 |
gsoc2009_timeline = Timeline(**timeline_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
gsoc2009_timeline.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
130 |
program_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
131 |
'key_name': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
'link_id': 'gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
'scope_path': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
'scope': google, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
135 |
'name': 'Google Summer of Code 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
'short_name': 'GSoC 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
'group_label': 'GSOC', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
'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
|
139 |
'apps_tasks_limit': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
140 |
'slots': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
141 |
'workflow': 'gsoc', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
'timeline': gsoc2009_timeline, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
143 |
'status': 'visible', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
144 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
145 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
146 |
gsoc2009 = Program(**program_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
147 |
gsoc2009.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
148 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
149 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
150 |
org_app_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
151 |
'scope_path': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
152 |
'scope': gsoc2009, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
153 |
'applicant': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
154 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
155 |
'email': 'org@example.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
156 |
'description': 'This is an awesome org!', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
157 |
'why_applying': 'Because we can', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
158 |
'member_criteria': 'They need to be awesome', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
159 |
'status': 'pre-accepted', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
160 |
'license_name': 'WTFPL', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
161 |
'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
|
162 |
'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
|
163 |
'member_disappears': 'See above', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
164 |
'encourage_contribs': 'We offer them cookies.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
165 |
'continued_contribs': 'We promise them a cake.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
166 |
'agreed_to_admin_agreement': True, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
167 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
168 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
169 |
for i in range(15): |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
170 |
org_app_properties['key_name'] = 'google/gsoc2009/org_%d' % i |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
171 |
org_app_properties['link_id'] = 'org_%d' % i |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
172 |
org_app_properties['name'] = 'Organization %d' % i |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
173 |
entity = OrgApplication(**org_app_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
174 |
entity.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
175 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
176 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
177 |
group_properties.update({ |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
178 |
'key_name': 'google/gsoc2009/melange', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
179 |
'link_id': 'melange', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
180 |
'name': 'Melange Development Team', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
181 |
'short_name': 'Melange', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
182 |
'scope_path': 'google/gsoc2009', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
183 |
'scope': gsoc2009, |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
184 |
'home_page': 'http://code.google.com/p/soc', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
185 |
'description': 'Melange, share the love!', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
186 |
'license_name': 'Apache License', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
187 |
'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
|
188 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
189 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
190 |
melange = Organization(**group_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
191 |
melange.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
192 |
|
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
193 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
194 |
role_properties.update({ |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
195 |
'key_name': 'google/gsoc2009/melange/test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
196 |
'link_id': 'test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
197 |
'scope_path': 'google/gsoc2009/melange', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
198 |
'scope': melange, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
199 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
200 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
201 |
melange_admin = OrgAdmin(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
202 |
melange_admin.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
203 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
204 |
melange_mentor = Mentor(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
205 |
melange_mentor.put() |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
206 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
207 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
208 |
document_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
209 |
'key_name': 'site/site/home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
210 |
'link_id': 'home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
211 |
'scope_path': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
212 |
'scope': site, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
213 |
'prefix': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
214 |
'author': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
215 |
'title': 'Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
216 |
'short_name': 'Home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
217 |
'content': 'This is the Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
218 |
'modified_by': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
219 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
220 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
221 |
home_document = Document(**document_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
222 |
home_document.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
223 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
224 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
225 |
site.home = home_document |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
226 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
227 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
228 |
return |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
229 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
230 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
231 |
def clear(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
232 |
"""Removes all entities from the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
233 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
234 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
235 |
entities = itertools.chain(*[ |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
236 |
Notification.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
237 |
Mentor.all(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
238 |
OrgAdmin.all(), |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
239 |
Organization.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
240 |
OrgApplication.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
241 |
Timeline.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
242 |
Program.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
243 |
Host.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
244 |
Sponsor.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
245 |
User.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
246 |
Site.all(), |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
247 |
Document.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
248 |
]) |
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 |
for entity in entities: |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
251 |
entity.delete() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
252 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
253 |
return |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
254 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
255 |
def reseed(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
256 |
"""Clears and seeds the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
257 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
258 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
259 |
clear(*args, **kwargs) |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
260 |
seed(*args, **kwargs) |