author | Sverre Rabbelier <srabbelier@gmail.com> |
Mon, 16 Mar 2009 23:52:22 +0000 | |
changeset 1901 | 5a98e8a8efb5 |
parent 1900 | a2966f072219 |
child 1902 | be3dbaa17114 |
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 |
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
29 |
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
|
30 |
from google.appengine.ext import db |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
32 |
from django import http |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
33 |
|
1623
8b70d6bb3f8f
Renamed rankerroot to ranker_root and made some changes due to comments.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1609
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
from soc.models.host import Host |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
40 |
from soc.models.mentor import Mentor |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
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
|
42 |
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
|
43 |
from soc.models.organization import Organization |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
44 |
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
|
45 |
from soc.models.program import Program |
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
46 |
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
|
47 |
from soc.models.site import Site |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
48 |
from soc.models.sponsor import Sponsor |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
49 |
from soc.models.timeline import Timeline |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
50 |
from soc.models.user import User |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
53 |
class Error(Exception): |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
54 |
pass |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
55 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
56 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
57 |
def ensureUser(): |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
58 |
"""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
|
59 |
""" |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
60 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
61 |
account = accounts.getCurrentAccount() |
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 |
if not account: |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
64 |
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
|
65 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
66 |
user_properties = { |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
67 |
'key_name': 'test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
68 |
'link_id': 'test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
69 |
'account': account, |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
70 |
'name': 'Test', |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
71 |
} |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
72 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
73 |
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
|
74 |
current_user.put() |
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
75 |
|
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
76 |
return account, current_user |
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 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
79 |
def seed(request, *args, **kwargs): |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
"""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
|
81 |
|
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
|
719ab05b00ff
Make it possible to add an arbitrary amount of users
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1791
diff
changeset
|
94 |
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
|
95 |
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
|
96 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
98 |
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
|
99 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
100 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
101 |
site_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
102 |
'key_name': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
103 |
'link_id': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
104 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
105 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
106 |
site = Site(**site_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
107 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
108 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
109 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
110 |
account, current_user = ensureUser() |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
112 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
113 |
for i in range(15): |
1602
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
114 |
user_properties = { |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
115 |
'key_name': 'user_%d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
116 |
'link_id': 'user_%d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
117 |
'account': users.User(email='user_%d@example.com' % i), |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
118 |
'name': 'User %d' % i, |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
119 |
} |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
120 |
entity = User(**user_properties) |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
121 |
entity.put() |
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
122 |
|
723739837649
Seed some users as well
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1562
diff
changeset
|
123 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
124 |
group_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
125 |
'key_name': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
126 |
'link_id': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
'name': 'Google Inc.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
'short_name': 'Google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
'founder': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
130 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
131 |
'email': 'ospo@google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
'description': 'This is the profile for Google.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
'contact_street': 'Some Street', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
'contact_city': 'Some City', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
135 |
'contact_country': 'United States', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
'contact_postalcode': '12345', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
'phone': '1-555-BANANA', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
'status': 'active', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
140 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
141 |
google = Sponsor(**group_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
google.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
143 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
144 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
145 |
role_properties = { |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
146 |
'key_name': 'google/test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
147 |
'link_id': 'test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
148 |
'scope': google, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
149 |
'scope_path': 'google', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
150 |
'user': current_user, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
151 |
'given_name': 'Test', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
152 |
'surname': 'Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
153 |
'name_on_documents': 'Test Example', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
154 |
'email': 'test@example.com', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
155 |
'res_street': 'Some Street', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
156 |
'res_city': 'Some City', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
157 |
'res_state': 'Some State', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
158 |
'res_country': 'United States', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
159 |
'res_postalcode': '12345', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
160 |
'phone': '1-555-BANANA', |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
161 |
'birth_date': db.DateProperty.now(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
162 |
'agreed_to_tos': True, |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
163 |
} |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
164 |
|
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 |
google_host = Host(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
167 |
google_host.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
168 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
169 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
170 |
timeline_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
171 |
'key_name': 'google/gsoc2009', |
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
172 |
'link_id': 'gsoc2009', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
173 |
'scope_path': 'google', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
174 |
'scope': google, |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
175 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
176 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
177 |
gsoc2009_timeline = Timeline(**timeline_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
178 |
gsoc2009_timeline.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
179 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
180 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
181 |
program_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
182 |
'key_name': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
183 |
'link_id': 'gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
184 |
'scope_path': 'google', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
185 |
'scope': google, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
186 |
'name': 'Google Summer of Code 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
187 |
'short_name': 'GSoC 2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
188 |
'group_label': 'GSOC', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
'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
|
190 |
'apps_tasks_limit': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
191 |
'slots': 42, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
192 |
'workflow': 'gsoc', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
193 |
'timeline': gsoc2009_timeline, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
194 |
'status': 'visible', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
195 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
196 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
197 |
gsoc2009 = Program(**program_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
198 |
gsoc2009.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
199 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
200 |
|
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
201 |
timeline_properties = { |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
202 |
'key_name': 'google/ghop2009', |
1475
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
203 |
'link_id': 'ghop2009', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
204 |
'scope_path': 'google', |
22b63ab59b27
Make timeline a Linkable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1453
diff
changeset
|
205 |
'scope': google, |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
206 |
} |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
207 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
208 |
ghop2009_timeline = Timeline(**timeline_properties) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
209 |
ghop2009_timeline.put() |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
210 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
211 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
212 |
program_properties.update({ |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
213 |
'key_name': 'google/ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
214 |
'link_id': 'ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
215 |
'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
|
216 |
'short_name': 'GHOP 2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
217 |
'group_label': 'GHOP', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
218 |
'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
|
219 |
'workflow': 'ghop', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
220 |
'timeline': ghop2009_timeline, |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
221 |
}) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
222 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
223 |
ghop2009 = Program(**program_properties) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
224 |
ghop2009.put() |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
225 |
|
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
226 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
227 |
org_app_properties = { |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
228 |
'scope_path': 'google/gsoc2009', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
229 |
'scope': gsoc2009, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
230 |
'applicant': current_user, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
231 |
'home_page': 'http://www.google.com', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
232 |
'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
|
233 |
'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
|
234 |
'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
|
235 |
'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
|
236 |
'description': 'This is an awesome org!', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
237 |
'why_applying': 'Because we can', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
238 |
'member_criteria': 'They need to be awesome', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
239 |
'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
|
240 |
'license_name': 'Apache License, 2.0', |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
241 |
'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
|
242 |
'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
|
243 |
'member_disappears': 'See above', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
244 |
'encourage_contribs': 'We offer them cookies.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
245 |
'continued_contribs': 'We promise them a cake.', |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
246 |
'agreed_to_admin_agreement': True, |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
247 |
} |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
248 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
249 |
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
|
250 |
org_app_properties['key_name'] = 'google/gsoc2009/wannabe_%d' % i |
1362 | 251 |
org_app_properties['link_id'] = 'wannabe_%d' % i |
252 |
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
|
253 |
entity = OrgApplication(**org_app_properties) |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
254 |
entity.put() |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
255 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
256 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
257 |
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
|
258 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
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
|
263 |
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
|
264 |
entity.put() |
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
265 |
|
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
266 |
|
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
267 |
group_properties.update({ |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
268 |
'key_name': 'google/ghop2009/melange', |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
269 |
'link_id': 'melange', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
270 |
'name': 'Melange Development Team', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
271 |
'short_name': 'Melange', |
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
272 |
'scope_path': 'google/ghop2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
273 |
'scope': ghop2009, |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
274 |
'home_page': 'http://code.google.com/p/soc', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
275 |
'description': 'Melange, share the love!', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
276 |
'license_name': 'Apache License', |
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
277 |
'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
|
278 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
279 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
280 |
melange = Organization(**group_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
281 |
melange.put() |
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
282 |
# 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
|
283 |
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
|
284 |
student_proposal.DEF_SCORE, 100) |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
285 |
|
1791
26fa036d68a0
Make it possible to add more users and orgs with GET args
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1789
diff
changeset
|
286 |
|
1363
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
287 |
group_properties.update({ |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
288 |
'scope_path': 'google/gsoc2009', |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
289 |
'scope': gsoc2009, |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
290 |
}) |
5667c29be1a3
Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1362
diff
changeset
|
291 |
|
1900
a2966f072219
Factor out ensureUser and add Error class in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1799
diff
changeset
|
292 |
for i in range(15): |
1362 | 293 |
group_properties.update({ |
294 |
'key_name': 'google/gsoc2009/org_%d' % i, |
|
295 |
'link_id': 'org_%d' % i, |
|
296 |
'name': 'Organization %d' % i, |
|
297 |
'short_name': 'Org %d' % i, |
|
298 |
'description': 'Organization %d!' % i, |
|
299 |
}) |
|
300 |
||
301 |
entity = Organization(**group_properties) |
|
302 |
entity.put() |
|
1609
cd285bc524f1
Create a new Ranker for each organization that is created.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1602
diff
changeset
|
303 |
# 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
|
304 |
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
|
305 |
student_proposal.DEF_SCORE, 100) |
1362 | 306 |
|
307 |
||
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
308 |
role_properties.update({ |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
309 |
'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
|
310 |
'link_id': 'test', |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
311 |
'scope_path': 'google/ghop2009/melange', |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
312 |
'scope': melange, |
1434
441a2b39f88b
Fixed a bug in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1429
diff
changeset
|
313 |
'program': ghop2009, |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
314 |
}) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
315 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
316 |
melange_admin = OrgAdmin(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
317 |
melange_admin.put() |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
318 |
|
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
319 |
melange_mentor = Mentor(**role_properties) |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
320 |
melange_mentor.put() |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
321 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
322 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
323 |
document_properties = { |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
324 |
'key_name': 'site/site/home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
325 |
'link_id': 'home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
326 |
'scope_path': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
327 |
'scope': site, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
328 |
'prefix': 'site', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
329 |
'author': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
330 |
'title': 'Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
331 |
'short_name': 'Home', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
332 |
'content': 'This is the Home Page', |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
333 |
'modified_by': current_user, |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
334 |
} |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
335 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
336 |
home_document = Document(**document_properties) |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
337 |
home_document.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
338 |
|
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
339 |
|
1415
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
340 |
document_properties = { |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
341 |
'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
|
342 |
'link_id': 'notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
343 |
'scope_path': 'test', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
344 |
'scope': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
345 |
'prefix': 'user', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
346 |
'author': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
347 |
'title': 'My Notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
348 |
'short_name': 'Notes', |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
349 |
'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
|
350 |
'modified_by': current_user, |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
351 |
} |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
352 |
|
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
353 |
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
|
354 |
notes_document.put() |
d34768bf62d8
Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1390
diff
changeset
|
355 |
|
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
356 |
site.home = home_document |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
357 |
site.put() |
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
358 |
|
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
359 |
memcache.flush_all() |
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
360 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
361 |
return http.HttpResponse('Done') |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
362 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
363 |
|
1901
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
364 |
def seed_many(request, *args, **kwargs): |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
365 |
"""Seeds many instances of the specified type. |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
366 |
""" |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
367 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
368 |
get_args = request.GET |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
369 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
370 |
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
|
371 |
return http.HttpResponse('Missing get args.') |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
372 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
373 |
seed_types = { |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
374 |
} |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
375 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
376 |
goal = int(get_args['goal']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
377 |
start = int(get_args['start']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
378 |
end = int(get_args['end']) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
379 |
step = int(get_args.get('step', '15')) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
380 |
seed_type = get_args['seed_type'] |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
381 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
382 |
if not seed_type in seed_types: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
383 |
return http.HttpResponse('Unknown seed_type: "%s".' % seed_type) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
384 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
385 |
action, model = seed_types[seed_type] |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
386 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
387 |
for i in range(start, end): |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
388 |
try: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
389 |
props = action(request, i) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
390 |
except Error, error: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
391 |
return http.HttpResponse(error.message) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
392 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
393 |
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
|
394 |
entity = model(**properties) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
395 |
entity.put() |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
396 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
397 |
if end < goal: |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
398 |
info = { |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
399 |
'start': start + step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
400 |
'end': end + step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
401 |
'goal': goal, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
402 |
'step': step, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
403 |
'seed_type': seed_type, |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
404 |
} |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
405 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
406 |
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
|
407 |
url = '/seed_many?' + '&'.join(args) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
408 |
return http.HttpResponseRedirect(url) |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
409 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
410 |
return http.HttpResponse('Done.') |
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
411 |
|
5a98e8a8efb5
Added a seed_many url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1900
diff
changeset
|
412 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
413 |
def clear(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
414 |
"""Removes all entities from the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
415 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
416 |
|
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
417 |
# 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
|
418 |
# our own convenience to delete all rankers |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
419 |
class ranker(db.Model): |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
420 |
pass |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
421 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
422 |
entities = itertools.chain(*[ |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
423 |
Notification.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
424 |
Mentor.all(), |
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
425 |
OrgAdmin.all(), |
1794
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
426 |
ranker.all(), |
6ffd25bedef9
Also clear RankerRoot and ranker from datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1793
diff
changeset
|
427 |
RankerRoot.all(), |
1335
a8c5b1e200bd
Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1332
diff
changeset
|
428 |
Organization.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
429 |
OrgApplication.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
430 |
Timeline.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
431 |
Program.all(), |
1348
8e3bd495729f
Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1335
diff
changeset
|
432 |
Host.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
433 |
Sponsor.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
434 |
User.all(), |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
435 |
Site.all(), |
1355
7a00bcfa0371
Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1348
diff
changeset
|
436 |
Document.all(), |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
437 |
]) |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
438 |
|
1799
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
439 |
try: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
440 |
for entity in entities: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
441 |
entity.delete() |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
442 |
except db.Timeout: |
53d15b129a3b
Redirect to current page if the current request times out
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1798
diff
changeset
|
443 |
return http.HttpResponseRedirect('#') |
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
444 |
|
1453
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
445 |
memcache.flush_all() |
378c844bf52c
Flush cache after seeding or clearing the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1434
diff
changeset
|
446 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
447 |
return http.HttpResponse('Done') |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
448 |
|
1332
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
449 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
450 |
def reseed(*args, **kwargs): |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
451 |
"""Clears and seeds the datastore. |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
452 |
""" |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
453 |
|
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
454 |
clear(*args, **kwargs) |
6655b1e89adb
Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
455 |
seed(*args, **kwargs) |
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
456 |
|
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1623
diff
changeset
|
457 |
return http.HttpResponse('Done') |