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