def process(org_app):
  ctx = context.get()
  params = ctx.mapreduce_spec.mapper.params

  program_type = params['program_type']
  program_key_str = params['program_key']

  # now the script is used only for GCI
  if program_type != 'gci':
    return

  program = GCIProgram.get_by_key_name(program_key_str)

  survey_query = OrgAppSurvey.all(keys_only=True).filter('program', program)
  survey_key = survey_query.get()

  # We can skip the survey records not belonging to the given program.
  if org_app.survey.key() != survey_key:
    return

  # TODO(daniel): create a MapReduce/Task RequestData
  data = MapreduceRequestData(program, Site.get_by_key_name('site'))

  absolute_url = links.ABSOLUTE_LINKER.program(
      program, gci_url_names.CREATE_GCI_ORG_PROFILE)

  if org_app.status == 'pre-accepted':
    org_app_logic.setStatus(data, org_app, 'accepted', absolute_url)
    yield operation.counters.Increment("proposals_accepted")
  elif org_app.status == 'pre-rejected':
    org_app_logic.setStatus(data, org_app, 'rejected', absolute_url)
    yield operation.counters.Increment("proposals_rejected")
  else:
    yield operation.counters.Increment("proposals_ignored")
Exemple #2
0
def getForProgram(program):
  """Return the org_app survey for a given program.

  Args:
    program: program entity for which the survey should be searched
  """
  # retrieve a OrgAppSurvey
  q = OrgAppSurvey.all()
  q.filter('program', program)
  survey = q.get()

  return survey
Exemple #3
0
  def orgAppFromKwargs(self, raise_not_found=True):
    """Sets the organization application in RequestData object.

    Args:
      raise_not_found: iff False do not send 404 response.
    """
    assert self.data.program

    q = OrgAppSurvey.all()
    q.filter('program', self.data.program)
    self.data.org_app = q.get()

    if raise_not_found and not self.data.org_app:
      raise NotFound(DEF_NO_ORG_APP % self.data.program.name)
  def testEditPage(self):
    """Tests organization applications edit page.
    """

    self.data.createHost()
    response = self.get(self.url)
    self.assertTemplatesUsed(response)

    response = self.post(self.url, self.post_params)
    self.assertResponseRedirect(response, '%s?validated' % self.url)

    query = OrgAppSurvey.all().filter('program = ', self.gci)
    self.assertEqual(query.count(), 1,
                     ('There must be one and only one OrgAppSurvey '
                      'instance for the program.'))

    survey = query.get()
    self.assertEqual(survey.title, self.post_params['title'])
    self.assertEqual(survey.modified_by.key(), self.data.user.key())
    def testEditPage(self):
        """Tests organization applications edit page.
    """

        self.data.createHost()
        response = self.get(self.url)
        self.assertTemplatesUsed(response)

        response = self.post(self.url, self.post_params)
        self.assertResponseRedirect(response, '%s?validated' % self.url)

        query = OrgAppSurvey.all().filter('program = ', self.gci)
        self.assertEqual(query.count(), 1,
                         ('There must be one and only one OrgAppSurvey '
                          'instance for the program.'))

        survey = query.get()
        self.assertEqual(survey.title, self.post_params['title'])
        self.assertEqual(survey.modified_by.key(), self.data.user.key())