Esempio n. 1
0
  def post(self, data, check, mutator):
    """Get handler for the code sample delete file."""
    assert isSet(data.url_project)

    try:
      id_value = int(data.request.POST['id'])
      code_sample = GSoCCodeSample.get_by_id(id_value, data.url_project)

      if not code_sample:
        raise exception.BadRequest(message='Requested code sample not found')

      upload_of_work = code_sample.upload_of_work

      def txn():
        code_sample.delete()
        if upload_of_work:
          # this is executed outside of transaction
          upload_of_work.delete()

        if data.url_project.countCodeSamples() <= 1:
          project = GSoCProject.get(data.url_project.key())
          project.code_samples_submitted = False
          project.put()

      db.run_in_transaction(txn)

      url = links.LINKER.userId(
          data.url_profile.key(), data.url_project.key().id(),
          url_names.GSOC_PROJECT_UPDATE)
      return http.HttpResponseRedirect(url)
    except KeyError:
      raise exception.BadRequest(message='id argument missing in POST data')
    except ValueError:
      raise exception.BadRequest(
          message='id argument in POST data is not a number')
Esempio n. 2
0
  def get(self, data, check, mutator):
    """Get handler for the code sample download file."""
    assert isSet(data.url_project)

    try:
      id_value = int(data.request.GET['id'])
      code_sample = GSoCCodeSample.get_by_id(id_value, data.url_project)
      if not code_sample or not code_sample.upload_of_work:
        raise exception.BadRequest(
            message='Requested project or code sample not found')
      else:
        return bs_helper.sendBlob(code_sample.upload_of_work)
    except KeyError:
      raise exception.BadRequest(message='id argument missing in GET data')
    except ValueError:
      raise exception.BadRequest(
          message='id argument in GET data is not a number')
Esempio n. 3
0
    def get(self, data, check, mutator):
        """Get handler for the code sample download file."""
        assert isSet(data.url_project)

        try:
            id_value = int(data.request.GET['id'])
            code_sample = GSoCCodeSample.get_by_id(id_value, data.url_project)
            if not code_sample or not code_sample.upload_of_work:
                raise exception.BadRequest(
                    message='Requested project or code sample not found')
            else:
                return bs_helper.sendBlob(code_sample.upload_of_work)
        except KeyError:
            raise exception.BadRequest(
                message='id argument missing in GET data')
        except ValueError:
            raise exception.BadRequest(
                message='id argument in GET data is not a number')
Esempio n. 4
0
    def post(self, data, check, mutator):
        """Get handler for the code sample delete file."""
        assert isSet(data.url_project)

        try:
            id_value = int(data.request.POST['id'])
            code_sample = GSoCCodeSample.get_by_id(id_value, data.url_project)

            if not code_sample:
                raise exception.BadRequest(
                    message='Requested code sample not found')

            upload_of_work = code_sample.upload_of_work

            def txn():
                code_sample.delete()
                if upload_of_work:
                    # this is executed outside of transaction
                    upload_of_work.delete()

                if data.url_project.countCodeSamples() <= 1:
                    project = GSoCProject.get(data.url_project.key())
                    project.code_samples_submitted = False
                    project.put()

            db.run_in_transaction(txn)

            url = links.LINKER.userId(data.url_profile.key(),
                                      data.url_project.key().id(),
                                      url_names.GSOC_PROJECT_UPDATE)
            return http.HttpResponseRedirect(url)
        except KeyError:
            raise exception.BadRequest(
                message='id argument missing in POST data')
        except ValueError:
            raise exception.BadRequest(
                message='id argument in POST data is not a number')