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