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