26 import itertools |
26 import itertools |
27 |
27 |
28 from google.appengine.api import users |
28 from google.appengine.api import users |
29 from google.appengine.ext import db |
29 from google.appengine.ext import db |
30 |
30 |
31 from soc.models.site import Site |
31 from soc.models.document import Document |
32 from soc.models.user import User |
|
33 from soc.models.sponsor import Sponsor |
|
34 from soc.models.host import Host |
32 from soc.models.host import Host |
35 from soc.models.program import Program |
|
36 from soc.models.timeline import Timeline |
|
37 from soc.models.org_app import OrgApplication |
|
38 from soc.models.organization import Organization |
|
39 from soc.models.org_admin import OrgAdmin |
|
40 from soc.models.mentor import Mentor |
33 from soc.models.mentor import Mentor |
41 from soc.models.notification import Notification |
34 from soc.models.notification import Notification |
|
35 from soc.models.org_admin import OrgAdmin |
|
36 from soc.models.organization import Organization |
|
37 from soc.models.org_app import OrgApplication |
|
38 from soc.models.program import Program |
|
39 from soc.models.site import Site |
|
40 from soc.models.sponsor import Sponsor |
|
41 from soc.models.timeline import Timeline |
|
42 from soc.models.user import User |
42 |
43 |
43 |
44 |
44 def seed(*args, **kwargs): |
45 def seed(*args, **kwargs): |
45 """Seeds the datastore with some default values. |
46 """Seeds the datastore with some default values. |
46 """ |
47 """ |
|
48 |
|
49 |
|
50 site_properties = { |
|
51 'key_name': 'site', |
|
52 'link_id': 'site', |
|
53 } |
|
54 |
|
55 site = Site(**site_properties) |
|
56 site.put() |
|
57 |
47 |
58 |
48 account = users.get_current_user() |
59 account = users.get_current_user() |
49 |
60 |
50 if not account: |
61 if not account: |
51 account = users.User(email='test@example.com') |
62 account = users.User(email='test@example.com') |
52 |
63 |
53 user_properties = { |
64 user_properties = { |
54 'key_name': 'test', |
65 'key_name': 'test', |
55 'link_id': 'test', |
66 'link_id': 'test', |
56 'account': account, |
67 'account': account, |
57 'agreed_to_tos': True, |
|
58 'name': 'Test', |
68 'name': 'Test', |
59 } |
69 } |
60 |
70 |
61 current_user = User(**user_properties) |
71 current_user = User(**user_properties) |
62 current_user.put() |
72 current_user.put() |
192 melange_admin.put() |
202 melange_admin.put() |
193 |
203 |
194 melange_mentor = Mentor(**role_properties) |
204 melange_mentor = Mentor(**role_properties) |
195 melange_mentor.put() |
205 melange_mentor.put() |
196 |
206 |
|
207 |
|
208 document_properties = { |
|
209 'key_name': 'site/site/home', |
|
210 'link_id': 'home', |
|
211 'scope_path': 'site', |
|
212 'scope': site, |
|
213 'prefix': 'site', |
|
214 'author': current_user, |
|
215 'title': 'Home Page', |
|
216 'short_name': 'Home', |
|
217 'content': 'This is the Home Page', |
|
218 'modified_by': current_user, |
|
219 } |
|
220 |
|
221 home_document = Document(**document_properties) |
|
222 home_document.put() |
|
223 |
|
224 |
|
225 site.home = home_document |
|
226 site.put() |
|
227 |
197 return |
228 return |
198 |
229 |
199 |
230 |
200 def clear(*args, **kwargs): |
231 def clear(*args, **kwargs): |
201 """Removes all entities from the datastore. |
232 """Removes all entities from the datastore. |