app/soc/models/seed_db.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 21 Feb 2009 11:14:44 +0000
changeset 1428 36a0ebe0c868
parent 1415 d34768bf62d8
child 1429 cfa0c3f2dc19
permissions -rw-r--r--
Added student_proposals to the sitemap. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    29
from google.appengine.ext import db
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
1355
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    31
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
    32
from soc.models.host import Host
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    33
from soc.models.mentor import Mentor
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
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
    35
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
    36
from soc.models.organization import Organization
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    37
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
    38
from soc.models.program import Program
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    39
from soc.models.site import Site
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    40
from soc.models.sponsor import Sponsor
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    41
from soc.models.timeline import Timeline
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    42
from soc.models.user import User
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
def seed(*args, **kwargs):
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
  """Seeds the datastore with some default values.
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
  """
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
1355
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    49
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    50
  site_properties = {
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    51
      'key_name': 'site',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    52
      'link_id': 'site',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    53
      }
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    54
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    55
  site = Site(**site_properties)
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    56
  site.put()
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    57
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
    58
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
  account = users.get_current_user()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    61
  if not account:
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    62
    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
    63
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    64
  user_properties = {
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
        'key_name': 'test',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
        'link_id': 'test',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
        'account': account,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
        'name': 'Test',
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
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    71
  current_user = User(**user_properties)
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
  current_user.put()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    74
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    75
  group_properties = {
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
       'key_name': 'google',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
       'link_id': 'google',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
       'name': 'Google Inc.',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
       'short_name': 'Google',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
       'founder': current_user,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    81
       'home_page': 'http://www.google.com',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
       'email': 'ospo@google.com',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
       'description': 'This is the profile for Google.',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
       'contact_street': 'Some Street',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
       'contact_city': 'Some City',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
       'contact_country': 'United States',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
       'contact_postalcode': '12345',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
       'phone': '1-555-BANANA',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
       'status': 'active',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
       }
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    92
  google = Sponsor(**group_properties)
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
  google.put()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    95
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    96
  role_properties = {
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    97
      'key_name': 'google/test',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    98
      'link_id': 'test',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
    99
      'scope': google,
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   100
      'scope_path': 'google',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   101
      'user': current_user,
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   102
      'given_name': 'Test',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   103
      'surname': 'Example',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   104
      'name_on_documents': 'Test Example',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   105
      'email': 'test@example.com',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   106
      'res_street': 'Some Street',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   107
      'res_city': 'Some City',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   108
      'res_state': 'Some State',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   109
      'res_country': 'United States',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   110
      'res_postalcode': '12345',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   111
      'phone': '1-555-BANANA',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   112
      'birth_date': db.DateProperty.now(),
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   113
      'agreed_to_tos': True,
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   114
      }
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   115
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   116
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   117
  google_host = Host(**role_properties)
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   118
  google_host.put()
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   119
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   120
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   121
  timeline_properties = {
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
        'key_name': 'google/gsoc2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
        'scope_path': 'google/gsoc2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
        }
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   126
  gsoc2009_timeline = Timeline(**timeline_properties)
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   127
  gsoc2009_timeline.put()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   130
  program_properties = {
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
      'key_name': 'google/gsoc2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
      'link_id': 'gsoc2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
      'scope_path': 'google',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
      'scope': google,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   135
      'name': 'Google Summer of Code 2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
      'short_name': 'GSoC 2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
      'group_label': 'GSOC',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   138
      '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
   139
      'apps_tasks_limit': 42,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
      'slots': 42,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   141
      'workflow': 'gsoc',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
      'timeline': gsoc2009_timeline,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
      'status': 'visible',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
      }
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   145
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   146
  gsoc2009 = Program(**program_properties)
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
  gsoc2009.put()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   148
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   149
1363
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   150
  timeline_properties = {
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   151
        'key_name': 'google/ghop2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   152
        'scope_path': 'google/ghop2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   153
        }
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   154
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   155
  ghop2009_timeline = Timeline(**timeline_properties)
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   156
  ghop2009_timeline.put()
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   157
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   158
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   159
  program_properties.update({
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   160
      'key_name': 'google/ghop2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   161
      'link_id': 'ghop2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   162
      '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
   163
      'short_name': 'GHOP 2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   164
      'group_label': 'GHOP',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   165
      '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
   166
      'workflow': 'ghop',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   167
      'timeline': ghop2009_timeline,
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   168
      })
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   169
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   170
  ghop2009 = Program(**program_properties)
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   171
  ghop2009.put()
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   172
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   173
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   174
  org_app_properties = {
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   175
    'scope_path': 'google/gsoc2009',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   176
    'scope': gsoc2009,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   177
    'applicant': current_user,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   178
    'home_page': 'http://www.google.com',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   179
    'email': 'org@example.com',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   180
    'description': 'This is an awesome org!',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   181
    'why_applying': 'Because we can',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   182
    'member_criteria': 'They need to be awesome',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   183
    'status': 'pre-accepted',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   184
    'license_name': 'WTFPL',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   185
    '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
   186
    '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
   187
    'member_disappears': 'See above',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   188
    'encourage_contribs': 'We offer them cookies.',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   189
    'continued_contribs': 'We promise them a cake.',
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   190
    'agreed_to_admin_agreement': True,
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   191
    }
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   192
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   193
  for i in range(15):
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
   194
    org_app_properties['key_name'] = 'google/gsoc2009/wannabe_%d' % i
1362
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   195
    org_app_properties['link_id'] = 'wannabe_%d' % i
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   196
    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
   197
    entity = OrgApplication(**org_app_properties)
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   198
    entity.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
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   201
  group_properties.update({
1363
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   202
    'key_name': 'google/ghop2009/melange',
1335
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   203
    'link_id': 'melange',
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   204
    'name': 'Melange Development Team',
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   205
    'short_name': 'Melange',
1363
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   206
    'scope_path': 'google/ghop2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   207
    'scope': ghop2009,
1335
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   208
    'home_page': 'http://code.google.com/p/soc',
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   209
    'description': 'Melange, share the love!',
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   210
    'license_name': 'Apache License',
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   211
    '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
   212
    })
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   213
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   214
  melange = Organization(**group_properties)
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   215
  melange.put()
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   216
1335
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   217
1363
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   218
  group_properties.update({
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   219
    'scope_path': 'google/gsoc2009',
5667c29be1a3 Add GHOP as program and put 'Melange' under it
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1362
diff changeset
   220
    'scope': gsoc2009,
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
1362
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   223
  for i in range(15):
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   224
    group_properties.update({
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   225
        'key_name': 'google/gsoc2009/org_%d' % i,
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   226
        'link_id': 'org_%d' % i,
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   227
        'name': 'Organization %d' % i,
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   228
        'short_name': 'Org %d' % i,
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   229
        'description': 'Organization %d!' % i,
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   230
        })
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   231
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   232
    entity = Organization(**group_properties)
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   233
    entity.put()
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   234
31b2cb6b75d8 Seed in some orgs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1355
diff changeset
   235
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   236
  role_properties.update({
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   237
      'key_name': 'google/gsoc2009/melange/test',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   238
      'link_id': 'test',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   239
      'scope_path': 'google/gsoc2009/melange',
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   240
      'scope': melange,
1390
34e00afd0eac Fixed a missing property in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1368
diff changeset
   241
      'program': gsoc2009,
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   242
      })
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   243
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   244
  melange_admin = OrgAdmin(**role_properties)
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   245
  melange_admin.put()
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   246
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   247
  melange_mentor = Mentor(**role_properties)
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   248
  melange_mentor.put()
1335
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   249
1355
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   250
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   251
  document_properties = {
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   252
      'key_name': 'site/site/home',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   253
      'link_id': 'home',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   254
      'scope_path': 'site',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   255
      'scope': site,
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   256
      'prefix': 'site',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   257
      'author': current_user,
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   258
      'title': 'Home Page',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   259
      'short_name': 'Home',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   260
      'content': 'This is the Home Page',
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   261
      'modified_by': current_user,
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   262
      }
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   263
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   264
  home_document = Document(**document_properties)
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   265
  home_document.put()
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   266
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   267
1415
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   268
  document_properties = {
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   269
      '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
   270
      'link_id': 'notes',
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   271
      'scope_path': 'test',
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   272
      'scope': current_user,
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   273
      'prefix': 'user',
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   274
      'author': current_user,
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   275
      'title': 'My Notes',
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   276
      'short_name': 'Notes',
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   277
      '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
   278
      'modified_by': current_user,
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   279
      }
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   280
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   281
  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
   282
  notes_document.put()
d34768bf62d8 Added a document in the test user's user space
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1390
diff changeset
   283
1355
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   284
  site.home = home_document
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   285
  site.put()
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   286
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   287
  return
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   288
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   289
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   290
def clear(*args, **kwargs):
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   291
  """Removes all entities from the datastore.
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   292
  """
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   293
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   294
  entities = itertools.chain(*[
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   295
      Notification.all(),
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   296
      Mentor.all(),
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   297
      OrgAdmin.all(),
1335
a8c5b1e200bd Added melange as org.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1332
diff changeset
   298
      Organization.all(),
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   299
      OrgApplication.all(),
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   300
      Timeline.all(),
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   301
      Program.all(),
1348
8e3bd495729f Seed more roles and factor out common properties
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1335
diff changeset
   302
      Host.all(),
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   303
      Sponsor.all(),
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   304
      User.all(),
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   305
      Site.all(),
1355
7a00bcfa0371 Add a Home document to the seeded entities
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1348
diff changeset
   306
      Document.all(),
1332
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   307
      ])
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   308
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   309
  for entity in entities:
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   310
    entity.delete()
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   311
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   312
  return
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   313
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   314
def reseed(*args, **kwargs):
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   315
  """Clears and seeds the datastore.
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   316
  """
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   317
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   318
  clear(*args, **kwargs)
6655b1e89adb Add a script to (re)seed the datastore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   319
  seed(*args, **kwargs)