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")
Beispiel #2
0
    def post(self, data, check, mutator):
        """Edits records from commands received by the list code."""
        post_dict = data.request.POST

        data.redirect.program()

        if (post_dict.get('process',
                          '') == org_app.PROCESS_ORG_APPS_FORM_BUTTON_VALUE):
            mapreduce_control.start_map(
                'ProcessOrgApp', {
                    'program_type': 'gsoc',
                    'program_key': data.program.key().name()
                })
            return data.redirect.to('gsoc_list_org_app_records',
                                    validated=True)

        if post_dict.get('button_id', None) != 'save':
            raise exception.BadRequest(message='No valid POST data found')

        post_data = post_dict.get('data')

        if not post_data:
            raise exception.BadRequest(message='Missing data')

        parsed = json.loads(post_data)

        url = 'TODO(daniel): remove this part as it is not used anymore'

        for oaid, properties in parsed.iteritems():
            record = OrgAppRecord.get_by_id(long(oaid))

            if not record:
                logging.warning('%s is an invalid OrgAppRecord ID', oaid)
                continue

            if record.survey.key() != data.org_app.key():
                logging.warning(
                    '%s is not a record for the Org App in the URL',
                    record.key())
                continue

            new_status = properties['status']
            org_app_logic.setStatus(data, record, new_status, url)

        return http.HttpResponse()
Beispiel #3
0
  def post(self, data, check, mutator):
    """Edits records from commands received by the list code."""
    post_dict = data.request.POST

    data.redirect.program()

    if (post_dict.get('process', '') ==
        org_app.PROCESS_ORG_APPS_FORM_BUTTON_VALUE):
      mapreduce_control.start_map('ProcessOrgApp', {
          'program_type': 'gci',
          'program_key': data.program.key().name()
          })
      return data.redirect.to(
          url_names.GCI_LIST_ORG_APP_RECORDS, validated=True)

    if post_dict.get('button_id', None) != 'save':
      raise exception.BadRequest(message='No valid POST data found')

    post_data = post_dict.get('data')
    if not post_data:
      raise exception.BadRequest(message='Missing data')

    parsed = json.loads(post_data)
    data.redirect.program()
    url = data.redirect.urlOf('create_gci_org_profile', full=True)

    for oaid, properties in parsed.iteritems():
      record = OrgAppRecord.get_by_id(long(oaid))

      if not record:
        logging.warning('%s is an invalid OrgAppRecord ID', oaid)
        continue

      if record.survey.key() != data.org_app.key():
        logging.warning(
            '%s is not a record for the Org App in the URL', record.key())
        continue

      new_status = properties['status']
      org_app_logic.setStatus(data, record, new_status, url)

    return http.HttpResponse()