| # Copyright 2008 the Melange authors. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| """Seeds or clears the datastore. |
| """ |
| |
| import os |
| |
| import itertools |
| import datetime |
| import random |
| |
| from google.appengine.api import users |
| from google.appengine.api import memcache |
| from google.appengine.ext import db |
| from google.appengine.ext import ndb |
| |
| from django import http |
| |
| from melange.models import education |
| from melange.models import address |
| from melange.models import contact |
| from melange.models import profile as profile_model |
| from melange.models import user |
| from melange.models import organization as organization_model |
| |
| from soc.logic import accounts |
| from soc.models.document import Document |
| |
| from soc.models import program as program_model |
| from soc.models import org_app_survey as org_app_survey_model |
| from soc.models.site import Site |
| from soc.models.sponsor import Sponsor |
| |
| from soc.models.survey import Survey |
| from soc.models.survey_record import SurveyRecord |
| |
| from soc.modules.gci.models.program import GCIProgram |
| from soc.modules.gci.models.score import GCIScore |
| from soc.modules.gci.models.timeline import GCITimeline |
| from soc.modules.gci.models.task import DifficultyLevel |
| from soc.modules.gci.models.task import GCITask |
| |
| from soc.modules.gsoc.models.program import GSoCProgram |
| from soc.modules.gsoc.models.timeline import GSoCTimeline |
| |
| from summerofcode.models import organization as soc_org_model |
| from summerofcode.models import profile as soc_profile |
| from summerofcode.models import project as project_model |
| from summerofcode.models import proposal as soc_proposal_model |
| |
| |
| LOREM_IPSUM = """ |
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec |
| ultrices mollis tortor, eget fringilla massa gravida vel. Nulla vitae |
| eleifend neque, at tincidunt massa. Pellentesque a auctor metus, non |
| malesuada ligula. Fusce scelerisque ac lectus ornare |
| luctus. Suspendisse euismod arcu quis quam hendrerit eleifend. Nam |
| tempus ornare imperdiet. Aliquam ex elit, pulvinar sit amet nulla nec, |
| feugiat molestie magna. Aliquam erat volutpat. Nulla non convallis |
| est. Pellentesque laoreet tellus ligula, ut fermentum nunc faucibus |
| id. Mauris tempus nec elit at sodales. Nam pretium felis justo, |
| sollicitudin suscipit orci gravida eget. Maecenas ut pharetra turpis, |
| eget euismod massa. Pellentesque leo orci, eleifend in tempor quis, |
| cursus sit amet tellus. Fusce sit amet massa vel tellus consectetur |
| feugiat sed luctus quam. |
| """ |
| |
| DOCUMENT_COUNTER = itertools.count(0) |
| |
| def seed(request, *args, **kwargs): |
| """Seeds the datastore with some default values. |
| """ |
| |
| site_properties = { |
| 'key_name': 'site', |
| 'latest_gsoc': 'google/gsoc2015', |
| 'latest_gci': 'google/gci2014', |
| } |
| site = Site(**site_properties) |
| site.put() |
| |
| account = accounts.getCurrentAccount() |
| |
| if not account: |
| # TODO(drewgottlieb): Figure out how to get dev server's user_id hash for a |
| # given email address. I obtained this hash by copying |
| # the user_id the dev server generates when I log in as |
| # this email. |
| account = users.User( |
| email='test@example.com', _user_id='185804764220139124118') |
| |
| user_properties = { |
| 'id': 'test', |
| 'account_id': account.user_id(), |
| 'account': account, |
| } |
| current_user = user.User(**user_properties) |
| current_user.put() |
| |
| group_properties = { |
| 'key_name': 'google', |
| 'link_id': 'google', |
| 'name': 'Google Inc.', |
| 'short_name': 'Google', |
| 'home_page': 'http://www.google.com', |
| 'email': 'ospo@google.com', |
| 'description': 'This is the profile for Google.', |
| 'contact_street': 'Some Street', |
| 'contact_city': 'Some City', |
| 'contact_country': 'United States', |
| 'contact_postalcode': '12345', |
| 'phone': '15551110000', |
| 'status': 'active', |
| } |
| google = Sponsor(**group_properties) |
| google.put() |
| |
| now = datetime.datetime.now() |
| before = now - datetime.timedelta(365) |
| after = now + datetime.timedelta(365) |
| past_before = before - datetime.timedelta(2 * 365) |
| past_after = after - datetime.timedelta(2 * 365) |
| |
| def make_document(program, title): |
| """Creates a new Document. |
| |
| This is defined inside seed() so that it can make use of variables |
| in that scope without having to explicitly pass them all in. |
| |
| """ |
| |
| index = DOCUMENT_COUNTER.next() |
| |
| document_properties = { |
| 'key_name': '%s/%s/d%d' % (program.prefix, program.key().name(), index), |
| 'link_id': 'document%d' % index, |
| 'scope': program, |
| 'prefix': program.prefix, |
| 'author': current_user.key.to_old_key(), |
| 'title': title, |
| 'content': title + ' --- ' + LOREM_IPSUM * 10, |
| 'modified_by': current_user.key.to_old_key(), |
| } |
| document = Document(**document_properties) |
| document.put() |
| return document |
| |
| |
| timeline_properties = { |
| 'key_name': 'google/gsoc2015', |
| 'link_id': 'gsoc2015', |
| 'scope': google, |
| 'program_start': before, |
| 'program_end': after, |
| 'accepted_organization_announced_deadline': before, |
| 'accepted_students_announced_deadline' : after, |
| 'student_signup_start': before, |
| 'student_signup_end': after, |
| 'application_review_deadline': after, |
| 'student_application_matched_deadline': after, |
| 'accepted_students_announced_deadline': after, |
| 'form_submission_start': before, |
| 'coding_start': after, |
| 'coding_end': after, |
| } |
| gsoc2015_timeline = GSoCTimeline(**timeline_properties) |
| gsoc2015_timeline.put() |
| |
| program_properties = { |
| 'key_name': 'google/gsoc2015', |
| 'link_id': 'gsoc2015', |
| 'program_id': 'gsoc2015', |
| 'sponsor': google, |
| 'scope': google, |
| 'name': 'Google Summer of Code 2015', |
| 'short_name': 'GSoC 2015', |
| 'description': 'This is the program for GSoC 2015.', |
| 'apps_tasks_limit': 42, |
| 'slots': 42, |
| 'timeline': gsoc2015_timeline, |
| 'status': program_model.STATUS_VISIBLE, |
| } |
| gsoc2015 = GSoCProgram(**program_properties) |
| gsoc2015.student_agreement = make_document( |
| gsoc2015, 'GSOC Student Agreement') |
| gsoc2015.mentor_agreement = make_document( |
| gsoc2015, 'GSOC Mentor Agreement') |
| gsoc2015.org_admin_agreement = make_document( |
| gsoc2015, 'GSOC Org Admin Agreement') |
| gsoc2015.student_forms_upload_header_document = make_document( |
| gsoc2015, 'GSOC Student Forms Upload Header') |
| gsoc2015.put() |
| |
| timeline_properties.update({ |
| 'key_name': 'google/gsoc2010', |
| 'link_id': 'gsoc2010', |
| 'program_start': past_before, |
| 'program_end': past_after, |
| 'accepted_organization_announced_deadline': past_before, |
| 'accepted_students_announced_deadline' : past_after, |
| 'student_signup_start': past_before, |
| 'student_signup_end': past_after, |
| 'application_review_deadline': past_after, |
| 'student_application_matched_deadline': past_after, |
| 'accepted_students_announced_deadline': past_after, |
| 'form_submission_start': past_before, |
| 'coding_start': past_after, |
| 'coding_end': past_after, |
| }) |
| gsoc2010_timeline = GSoCTimeline(**timeline_properties) |
| gsoc2010_timeline.put() |
| |
| program_properties.update({ |
| 'key_name': 'google/gsoc2010', |
| 'link_id': 'gsoc2010', |
| 'program_id': 'gsoc2010', |
| 'name': 'Google Summer of Code 2010', |
| 'description': 'This is the program for GSoC 2010.', |
| 'short_name': 'GSoC 2010', |
| 'timeline': gsoc2010_timeline, |
| }) |
| gsoc2010 = GSoCProgram(**program_properties) |
| gsoc2010.put() |
| |
| # TODO(drew): Replace gsoc2015.prefix with whatever its replacement becomes |
| # once prefix is removed from program and no longer used in the query for |
| # OrgAppSurvey in soc.views.helper.RequestData._getProgramWideFields(). |
| org_app_survey_properties = { |
| 'key_name' : '%s/%s/orgapp' % (gsoc2015.prefix, gsoc2015.key().name()), |
| 'program' : gsoc2015, |
| 'title' : 'Org App Survey', |
| 'content' : 'Here is some content.', |
| 'modified_by' : current_user.key.to_old_key(), |
| 'survey_start' : before, |
| 'survey_end' : after |
| } |
| org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put() |
| |
| org_app_survey_properties['key_name'] = ('%s/%s/orgapp' % ( |
| gsoc2010.prefix, gsoc2010.key().name())) |
| org_app_survey_properties['program'] = gsoc2010 |
| org_app_survey_properties['survey_start'] = past_before |
| org_app_survey_properties['survey_end'] = past_after |
| org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put() |
| |
| timeline_properties = { |
| 'key_name': 'google/gci2014', |
| 'link_id': 'gci2014', |
| 'scope': google, |
| 'program_start': before, |
| 'program_end': after, |
| 'accepted_organization_announced_deadline': before, |
| 'student_signup_start': before, |
| 'student_signup_end': after, |
| 'tasks_publicly_visible': before, |
| 'task_claim_deadline': after, |
| 'stop_all_work_deadline': after, |
| } |
| gci2014_timeline = GCITimeline(**timeline_properties) |
| gci2014_timeline.put() |
| |
| program_properties.update({ |
| 'key_name': 'google/gci2014', |
| 'link_id': 'gci2014', |
| 'program_id': 'gci2014', |
| 'name': 'Google Code In Contest 2014', |
| 'short_name': 'GCI 2014', |
| 'description': 'This is the program for GCI 2014.', |
| 'timeline': gci2014_timeline, |
| 'student_min_age': 13, |
| 'student_max_age': 17, |
| 'student_min_age_as_of': ( |
| timeline_properties['student_signup_start'].date()), |
| 'task_types': ['Code', 'Documentation/Training', 'Outreach/Research', |
| 'Quality Assurance', 'User Interface'], |
| }) |
| gci2014 = GCIProgram(**program_properties) |
| gci2014.student_agreement = make_document( |
| gci2014, 'GCI Student Agreement') |
| gci2014.mentor_agreement = make_document( |
| gci2014, 'GCI Mentor Agreement') |
| gci2014.org_admin_agreement = make_document( |
| gci2014, 'GCI Org Admin Agreement') |
| gci2014.student_forms_upload_header_document = make_document( |
| gci2014, 'GCI Student Forms Upload Header') |
| gci2014.put() |
| |
| site.active_program = gci2014 |
| site.put() |
| |
| current_user.host_for = [ |
| ndb.Key.from_old_key(gsoc2010.key()), |
| ndb.Key.from_old_key(gsoc2015.key()), |
| ndb.Key.from_old_key(gci2014.key())] |
| current_user.put() |
| |
| contact_web_page = contact.Contact(web_page='http://www.example.org') |
| |
| org_properties = { |
| 'id': 'google/gci2014/melange', |
| 'name': 'Melange Development Team', |
| 'org_id': 'melange', |
| 'program': ndb.Key.from_old_key(gci2014.key()), |
| 'contact': contact_web_page, |
| 'description': 'Melange, share the love!', |
| 'license': random.choice(organization_model.licenses.LICENSES), |
| 'logo_url': request.build_absolute_uri( |
| '/soc/content/%s/images/soc/logo/melange-m-transparent.png' % |
| os.environ.get('CURRENT_VERSION_ID', '').split('.')[0]), |
| 'status': organization_model.Status.ACCEPTED, |
| } |
| melange = organization_model.Organization(**org_properties) |
| melange.put() |
| |
| address_properties = address.Address( |
| name='Shipping Recipient Name', |
| street='1 Test St.', |
| city='Some City', |
| country='United States', |
| postal_code='12345') |
| address_properties.put() |
| |
| contact_info = contact.Contact(email='test@example.com') |
| contact_info.put() |
| |
| gsoc_delta = datetime.timedelta(days=(365 * 18)) |
| |
| profile_properties = { |
| 'id': gsoc2015.key().name() + '/' + current_user.key.id(), |
| 'parent': current_user.key, |
| 'public_name': 'Test Admin', |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| 'first_name': 'Test', |
| 'last_name': 'Example', |
| 'contact' : contact_info, |
| 'residential_address' : address_properties, |
| 'shipping_address' : address_properties, |
| 'birth_date' : datetime.date.today() - gsoc_delta, |
| 'program_knowledge' : 'Friend referral', |
| } |
| profile = profile_model.Profile(**profile_properties) |
| |
| ndb_orgs = [] |
| for i in range(15): |
| org_properties = { |
| 'name': 'Organization %d' % i, |
| 'org_id': 'org_%d' % i, |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| 'contact': contact_web_page, |
| 'description': 'Organization %d!' % i, |
| 'license': random.choice(organization_model.licenses.LICENSES), |
| 'logo_url': request.build_absolute_uri( |
| '/soc/content/%s/images/soc/logo/melange-m-transparent.png' % |
| os.environ.get('CURRENT_VERSION_ID', '').split('.')[0]), |
| } |
| if i < 5: |
| org_properties['status'] = organization_model.Status.ACCEPTED |
| org = soc_org_model.SOCOrganization( |
| id='google/gsoc2015/org_%d' % i, **org_properties) |
| org.put() |
| ndb_orgs.append(org) |
| |
| # Admin (and thus mentor) for the first org |
| if i == 0: |
| profile.admin_for.append(org.key) |
| profile.mentor_for.append(org.key) |
| profile.put() |
| |
| # Mentor for the second org |
| if i == 1: |
| profile.mentor_for.append(org.key) |
| profile.put() |
| |
| profile_properties.update({ |
| 'id': gci2014.key().name() + '/' + current_user.key.id(), |
| 'parent': current_user.key, |
| 'program': ndb.Key.from_old_key(gci2014.key()), |
| 'admin_for': [melange.key], |
| 'mentor_for': [melange.key], |
| }) |
| melange_admin = profile_model.Profile(**profile_properties) |
| # TODO: add GCI orgs |
| melange_admin.put() |
| |
| task_properties = { |
| 'status': 'Open', |
| 'modified_by': melange_admin.key.to_old_key(), |
| 'subscribers': [melange_admin.key.to_old_key()], |
| 'title': 'Awesomeness', |
| 'created_by': melange_admin.key.to_old_key(), |
| 'created_on': now, |
| 'program': gci2014, |
| 'time_to_complete': 7, |
| 'modified_on': now, |
| 'org': melange.key.to_old_key(), |
| 'description': '<p>AWESOME</p>', |
| 'difficulty_level': DifficultyLevel.MEDIUM, |
| 'types': ['Code'] |
| } |
| gci_task = GCITask(**task_properties) |
| gci_task.put() |
| |
| student_id = 'student' |
| # TODO(drewgottlieb): Figure out how to get dev server's user_id hash for a |
| # given email address. I obtained this hash by copying |
| # the user_id the dev server generates when I log in as |
| # this email. |
| account = users.User( |
| email=('%s@example.com' % student_id), _user_id='115021216387231191261') |
| |
| user_properties = { |
| 'id': student_id, |
| 'account_id': account.user_id(), |
| 'account': account, |
| } |
| student_user = user.User(**user_properties) |
| student_user.put() |
| |
| gci_delta = datetime.timedelta(days=(365 * 14)) |
| |
| contact_properties = contact.Contact( |
| email='student@example.com', |
| web_page='http://www.homepage.com/', |
| blog='http://www.blog.com/', |
| phone='1650253000') |
| contact_properties.put() |
| |
| graduation_year = datetime.date.today() + datetime.timedelta(days=365) |
| |
| student_data = soc_profile.SOCStudentData( |
| education=education.Education( |
| school_id="123", |
| school_country="United States", |
| expected_graduation=int(graduation_year.strftime('%Y')), |
| major='Some Major', |
| degree=education.Degree.UNDERGRADUATE) |
| ) |
| student_data.put() |
| |
| student_properties = { |
| 'id': gsoc2015.key().name() + "/" + student_id, |
| 'parent': student_user.key, |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| 'public_name': 'Student', |
| 'first_name': 'Student', |
| 'last_name': 'Student', |
| 'contact' : contact_properties, |
| 'residential_address' : address_properties, |
| 'shipping_address' : address_properties, |
| 'birth_date': datetime.date.today() - gci_delta, |
| 'tee_size': profile_model.TeeSize.L, |
| 'tee_style': profile_model.TeeStyle.MALE, |
| 'gender' : profile_model.Gender.MALE, |
| 'program_knowledge': 'Friend referral.', |
| 'student_data' : student_data, |
| 'accepted_tos' : [ndb.Key.from_old_key(gsoc2015.student_agreement.key())], |
| } |
| melange_student = profile_model.Profile(**student_properties) |
| melange_student.put() |
| |
| student_id = 'student2' |
| # TODO(drewgottlieb): Figure out how to get dev server's user_id hash for a |
| # given email address. I obtained this hash by copying |
| # the user_id the dev server generates when I log in as |
| # this email. |
| account = users.User( |
| email=('%s@example.com' % student_id), _user_id='100377022012711418814') |
| |
| user_properties = { |
| 'id': student_id, |
| 'account_id': account.user_id(), |
| 'account': account, |
| } |
| student_user2 = user.User(**user_properties) |
| student_user2.put() |
| |
| student_properties.update({ |
| 'id': gsoc2015.key().name() + "/" + student_id, |
| 'parent': student_user2.key, |
| 'first_name' : 'GSOC Student 2', |
| 'last_name' : 'Example' |
| }) |
| melange_student2 = profile_model.Profile(**student_properties) |
| melange_student2.put() |
| |
| pending_proposal_properties = { |
| 'parent': melange_student.key, |
| 'title': 'Test proposal', |
| 'abstract': 'This is an abstract abstract.', |
| 'content': 'This content should make you content.', |
| 'additional_info': 'http://zombo.com', |
| 'mentors': [], |
| 'possible_mentors': [profile.key], |
| 'scores': [soc_proposal_model.Score( |
| author=profile.key, value=2)], |
| 'organization': ndb_orgs[1].key, |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| } |
| pending_melange_proposal = soc_proposal_model.Proposal( |
| **pending_proposal_properties) |
| pending_melange_proposal.put() |
| |
| accepted_proposal_properties = { |
| 'parent': melange_student.key, |
| 'title': 'Accepted test proposal', |
| 'abstract': 'This is an accepted abstract abstract.', |
| 'content': 'This content should make you feel accepting.', |
| 'additional_info': 'http://zombo.com', |
| 'mentors': [profile.key], |
| 'possible_mentors': [profile.key], |
| 'status': soc_proposal_model.Status.ACCEPTED, |
| 'scores': [soc_proposal_model.Score( |
| author=profile.key, value=4)], |
| 'organization': ndb_orgs[1].key, |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| } |
| accepted_melange_proposal = soc_proposal_model.Proposal( |
| **accepted_proposal_properties) |
| accepted_melange_proposal.put() |
| |
| ndb_orgs[1].slot_allocation = 1 |
| ndb_orgs[1].put() |
| |
| project_properties = { |
| 'parent': melange_student.key, |
| 'proposal': accepted_melange_proposal.key, |
| 'title': 'Accepted test project', |
| 'abstract': 'This is an abstract project\'s abstract.', |
| 'status': project_model.Status.ACCEPTED, |
| 'organization': ndb_orgs[1].key, |
| 'mentors': [profile.key], |
| 'additional_info': 'http://zombo.com', |
| 'program': ndb.Key.from_old_key(gsoc2015.key()), |
| 'content': 'This is content of the project', |
| } |
| melange_project = project_model.Project(**project_properties) |
| melange_project.put() |
| |
| student_data.number_of_projects = 1 |
| student_data.number_of_proposals = 2 |
| student_data.project_for_orgs = [ndb_orgs[1].key] |
| |
| melange_student.put() |
| melange_student2.put() |
| |
| student_id = 'student' |
| student_properties.update({ |
| 'id': gci2014.key().name() + '/' + student_id, |
| 'first_name' : 'GCI Student', |
| 'last_name' : 'Example', |
| 'parent': student_user.key, |
| 'program': ndb.Key.from_old_key(gci2014.key()), |
| 'accepted_tos' : [ndb.Key.from_old_key(gci2014.student_agreement.key())], |
| 'age': 15, |
| }) |
| del student_properties['birth_date'] |
| |
| gci_student = profile_model.Profile(**student_properties) |
| gci_student.put() |
| |
| score_properties = { |
| 'parent': gci_student.key.to_old_key(), |
| 'program': gci2014, |
| 'points': 5, |
| 'tasks': [gci_task.key()] |
| } |
| score = GCIScore(**score_properties) |
| score.put() |
| |
| document_properties = { |
| 'key_name': 'site/site/home', |
| 'link_id': 'home', |
| 'scope': site, |
| 'prefix': 'site', |
| 'author': current_user.key.to_old_key(), |
| 'title': 'Home Page', |
| 'content': 'This is the Home Page', |
| 'modified_by': current_user.key.to_old_key(), |
| } |
| home_document = Document(**document_properties) |
| home_document.put() |
| |
| document_properties = { |
| 'key_name': 'user/test/notes', |
| 'link_id': 'notes', |
| 'scope': current_user.key.to_old_key(), |
| 'prefix': 'user', |
| 'author': current_user.key.to_old_key(), |
| 'title': 'My Notes', |
| 'content': 'These are my notes', |
| 'modified_by': current_user.key.to_old_key(), |
| } |
| notes_document = Document(**document_properties) |
| notes_document.put() |
| |
| site.home = home_document |
| site.put() |
| |
| org_app_survey_properties = { |
| 'key_name' : '%s/%s/orgapp' % (gci2014.prefix, gci2014.key().name()), |
| 'program' : gci2014, |
| 'title' : 'GCI Org App Survey', |
| 'content' : 'Here is some content.', |
| 'modified_by' : current_user.key.to_old_key(), |
| 'survey_start' : before, |
| 'survey_end' : after |
| } |
| org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put() |
| |
| # Seed 15 Organizations for GCI. Accept 11 of them. (Total 12 |
| # accepted including the melange org above.) |
| for i in range(15): |
| org_properties = { |
| 'name': 'GCI Organization %d' % i, |
| 'org_id': 'orggci_%d' % i, |
| 'program': ndb.Key.from_old_key(gci2014.key()), |
| 'contact': contact_web_page, |
| 'description': 'GCI Organization %d!' % i, |
| 'license': random.choice(organization_model.licenses.LICENSES), |
| 'logo_url': request.build_absolute_uri( |
| '/soc/content/%s/images/soc/logo/melange-m-transparent.png' % |
| os.environ.get('CURRENT_VERSION_ID', '').split('.')[0]), |
| } |
| if i < 11: |
| org_properties['status'] = organization_model.Status.ACCEPTED |
| org = organization_model.Organization( |
| id='google/gci2014/org_%d' % i, **org_properties) |
| org.put() |
| |
| memcache.flush_all() |
| |
| return http.HttpResponse('seed_db Done') |
| |
| def clear(*args, **kwargs): |
| """Removes all entities from the datastore. |
| """ |
| |
| # TODO(dbentley): If there are more than 1000 instances of any model, |
| # this method will not clear all instances. Instead, it should continually |
| # call .all(), delete all those, and loop until .all() is empty. |
| entities = itertools.chain(*[ |
| Survey.all(), |
| SurveyRecord.all(), |
| GSoCTimeline.all(), |
| GCITimeline.all(), |
| GSoCProgram.all(), |
| GCIProgram.all(), |
| GCIScore.all(), |
| GCITask.all(), |
| Sponsor.all(), |
| Site.all(), |
| Document.all(), |
| # The below models are all subclasses of ndb.Model and therefore must |
| # use .query() to return all instances instead of .all(). |
| soc_org_model.SOCOrganization.query(), |
| organization_model.Organization.query(), |
| profile_model.Profile.query(), |
| soc_profile.SOCStudentData.query(), |
| user.User.query(), |
| address.Address.query(), |
| contact.Contact.query() |
| ]) |
| |
| try: |
| for entity in entities: |
| if isinstance(entity, ndb.Model): |
| entity.key.delete() |
| else: |
| entity.delete() |
| except db.Timeout: |
| return http.HttpResponseRedirect('#') |
| memcache.flush_all() |
| |
| return http.HttpResponse('clear_db Done') |
| |
| |
| def reseed(*args, **kwargs): |
| """Clears and seeds the datastore. |
| """ |
| |
| clear(*args, **kwargs) |
| seed(*args, **kwargs) |
| |
| return http.HttpResponse('reseed_db Done') |