| # Copyright 2014 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. |
| |
| """Seeder functions for survey model.""" |
| |
| from google.appengine.ext import db |
| |
| from soc.models import org_app_survey as app_survey_model |
| |
| from seeder import user as user_seeder |
| from seeder import utils as seeder_utils |
| |
| |
| TEST_TITLE = 'Application Survey for %s' |
| |
| def seedApplicationSurvey(program_key, **kwargs): |
| """Seeds a new organization application survey for the specified program. |
| |
| Args: |
| program_key: Program key to create a survey for. |
| kwargs: Optional values for other properties of the seeded entity. |
| |
| Returns: |
| Newly seeded survey entity. |
| """ |
| user = user_seeder.seedUser() |
| program = db.get(program_key) |
| |
| properties = { |
| 'key_name': '%s/%s/orgapp' % (program.prefix, program_key.name()), |
| 'scope': program_key, |
| 'program': program_key, |
| 'modified_by': user.key.to_old_key(), |
| 'created_by': user.key.to_old_key(), |
| 'author': user.key.to_old_key(), |
| 'schema': ('[["item"],{"item":{"field_type":"input_text",' |
| '"required":false, "label":"test"}}]'), |
| 'survey_start': seeder_utils.pastDateTime(), |
| 'survey_end': seeder_utils.futureDateTime(), |
| 'title': TEST_TITLE % program.name |
| } |
| properties.update(kwargs) |
| applicationSurvey = app_survey_model.OrgAppSurvey(**properties) |
| applicationSurvey.put() |
| |
| return applicationSurvey |