|
1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2008 the Melange authors. |
|
4 # |
|
5 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 # you may not use this file except in compliance with the License. |
|
7 # You may obtain a copy of the License at |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
11 # Unless required by applicable law or agreed to in writing, software |
|
12 # distributed under the License is distributed on an "AS IS" BASIS, |
|
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 # See the License for the specific language governing permissions and |
|
15 # limitations under the License. |
|
16 |
|
17 """Seeds or clears the datastore. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 ] |
|
23 |
|
24 |
1 import itertools |
25 import itertools |
2 |
26 |
3 from google.appengine.ext.db import users |
27 from google.appengine.ext.db import users |
4 |
28 |
5 from soc.models.site import Site |
29 from soc.models.site import Site |
6 from soc.models.user import User |
30 from soc.models.user import User |
7 from soc.models.sponsor import Sponsor |
31 from soc.models.sponsor import Sponsor |
8 from soc.models.program import Program |
32 from soc.models.program import Program |
9 from soc.models.timeline import Timeline |
33 from soc.models.timeline import Timeline |
10 from soc.models.org_app import OrgApplication |
34 from soc.models.org_app import OrgApplication |
|
35 from soc.models.organization import Organization |
11 from soc.models.notification import Notification |
36 from soc.models.notification import Notification |
12 |
37 |
13 |
38 |
14 def seed(*args, **kwargs): |
39 def seed(*args, **kwargs): |
15 """Seeds the datastore with some default values. |
40 """Seeds the datastore with some default values. |
101 properties['link_id'] = 'org_%d' % i |
126 properties['link_id'] = 'org_%d' % i |
102 properties['name'] = 'Organization %d' % i |
127 properties['name'] = 'Organization %d' % i |
103 entity = OrgApplication(**properties) |
128 entity = OrgApplication(**properties) |
104 entity.put() |
129 entity.put() |
105 |
130 |
|
131 properties = { |
|
132 'key_name': 'google/gsoc2009/melange', |
|
133 'link_id': 'melange', |
|
134 'name': 'Melange Development Team', |
|
135 'short_name': 'Melange', |
|
136 'scope_path': 'google/gsoc2009', |
|
137 'scope': gsoc2009, |
|
138 'founder': current_user, |
|
139 'contact_street': 'Some Street', |
|
140 'contact_city': 'Some City', |
|
141 'contact_country': 'United States', |
|
142 'contact_postalcode': '12345', |
|
143 'phone': '1-555-BANANA', |
|
144 'home_page': 'http://code.google.com/p/soc', |
|
145 'email': 'ospo@google.com', |
|
146 'description': 'Melange, share the love!', |
|
147 'status': 'active', |
|
148 'license_name': 'Apache License', |
|
149 'ideas': 'http://code.google.com/p/soc/issues', |
|
150 } |
|
151 |
|
152 melange = Organization(**properties) |
|
153 melange.put() |
|
154 |
106 return |
155 return |
107 |
156 |
108 |
157 |
109 def clear(*args, **kwargs): |
158 def clear(*args, **kwargs): |
110 """Removes all entities from the datastore. |
159 """Removes all entities from the datastore. |
111 """ |
160 """ |
112 |
161 |
113 entities = itertools.chain(*[ |
162 entities = itertools.chain(*[ |
114 Notification.all(), |
163 Notification.all(), |
|
164 Organization.all(), |
115 OrgApplication.all(), |
165 OrgApplication.all(), |
116 Timeline.all(), |
166 Timeline.all(), |
117 Program.all(), |
167 Program.all(), |
118 Sponsor.all(), |
168 Sponsor.all(), |
119 User.all(), |
169 User.all(), |