equal
deleted
inserted
replaced
51 """Seeds the datastore with some default values. |
51 """Seeds the datastore with some default values. |
52 |
52 |
53 Understands the following GET args: |
53 Understands the following GET args: |
54 many_users: create 200 users instead of 15, out of which 100 have |
54 many_users: create 200 users instead of 15, out of which 100 have |
55 a e-mail address in the auth domain |
55 a e-mail address in the auth domain |
|
56 user_start: where to start adding new users at |
|
57 user_end: where to stop adding new users at |
|
58 user_goal: how many users to add in total |
|
59 user_step: how many users to add per request, defaults to 15 |
56 many_orgs: create 200 pre-accepted and 200 pre-denied org apps |
60 many_orgs: create 200 pre-accepted and 200 pre-denied org apps |
57 instead of just 1- pre-accepted ones, also create 200 |
61 instead of just 1- pre-accepted ones, also create 200 |
58 orgs instead of just 15. |
62 orgs instead of just 15. |
|
63 |
|
64 user is redirected to if user_end < user_goal, incrementing both |
|
65 user_start and user_end with user_step. |
59 """ |
66 """ |
60 |
67 |
61 get_args = request.GET |
68 get_args = request.GET |
62 |
69 |
63 |
70 |
85 current_user = User(**user_properties) |
92 current_user = User(**user_properties) |
86 current_user.put() |
93 current_user.put() |
87 |
94 |
88 |
95 |
89 many_users = get_args.get('many_users') |
96 many_users = get_args.get('many_users') |
|
97 user_goal = int(get_args.get('user_goal', '0')) |
|
98 user_start = int(get_args.get('user_start', '0')) |
|
99 user_end = int(get_args.get('user_end', '0')) |
|
100 user_step = int(get_args.get('user_step', '15')) |
90 |
101 |
91 for i in range(100 if many_users else 15): |
102 for i in range(100 if many_users else 15): |
92 user_properties = { |
103 user_properties = { |
93 'key_name': 'user_%d' % i, |
104 'key_name': 'user_%d' % i, |
94 'link_id': 'user_%d' % i, |
105 'link_id': 'user_%d' % i, |
106 'account': users.User(email='user_%d' % i), |
117 'account': users.User(email='user_%d' % i), |
107 'name': 'User %d' % i, |
118 'name': 'User %d' % i, |
108 } |
119 } |
109 entity = User(**user_properties) |
120 entity = User(**user_properties) |
110 entity.put() |
121 entity.put() |
|
122 |
|
123 |
|
124 for i in range(user_start, user_end) if (user_start and user_end) else []: |
|
125 user_properties = { |
|
126 'key_name': 'lots_user_%d' % i, |
|
127 'link_id': 'lots_user_%d' % i, |
|
128 'account': users.User(email='lots_user_%d@example.com' % i), |
|
129 'name': 'Lots User %d' % i, |
|
130 } |
|
131 entity = User(**user_properties) |
|
132 entity.put() |
|
133 |
|
134 |
|
135 if user_end < user_goal: |
|
136 url = '/seed_db?user_start=%d&user_end=%d&user_goal=%d' % ( |
|
137 user_start+user_step, user_end+user_step, user_goal) |
|
138 return http.HttpResponseRedirect(url) |
111 |
139 |
112 |
140 |
113 group_properties = { |
141 group_properties = { |
114 'key_name': 'google', |
142 'key_name': 'google', |
115 'link_id': 'google', |
143 'link_id': 'google', |