コード例 #1
0
def reject_proposals(request, *args, **kwargs):
  """Reject proposals for an org_logic
  """

  params = request.POST

  # Setup an artifical request deadline
  timelimit = int(params["timelimit"])
  timekeeper = Timekeeper(timelimit)

  # Query proposals
  org = org_logic.getFromKeyName(params["orgkey"])
  proposals = reject_proposals_query(org)

  # Reject proposals
  try:
    for remain, proposal in timekeeper.iterate(proposals):
      logging.info("reject %s %s %s", remain, org.key(), proposal.key())
      reject_proposal(proposal)
      reject_proposal_email(proposal)

  # Requeue this task for continuation
  except DeadlineExceededError:
    taskqueue.add(url=request.path, params=params)

  # Exit this task successfully
  return responses.terminateTask()
コード例 #2
0
def accept_proposals(request, *args, **kwargs):
  """Accept proposals for an organization
  """

  params = request.POST

  # Setup an artifical request deadline
  timelimit = int(params["timelimit"])
  timekeeper = Timekeeper(timelimit)

  # Query proposals based on status
  org = org_logic.getFromKeyName(params["orgkey"])
  proposals = student_proposal_logic.getProposalsToBeAcceptedForOrg(org)

  # Accept proposals
  try:
    for remain, proposal in timekeeper.iterate(proposals):
      logging.info("accept %s %s %s", remain, org.key(), proposal.key())
      accept_proposal(proposal)
      accept_proposal_email(proposal)

  # Requeue this task for continuation
  except DeadlineExceededError:
    taskqueue.add(url=request.path, params=params)
    return responses.terminateTask()

  # Reject remaining proposals
  taskqueue.add(url=params["nextpath"], params=params)
  return responses.terminateTask()
コード例 #3
0
def reject_proposals(request, *args, **kwargs):
    """Reject proposals for an org_logic
  """

    params = request.POST

    # Setup an artifical request deadline
    timelimit = int(params["timelimit"])
    timekeeper = Timekeeper(timelimit)

    # Query proposals
    org = org_logic.getFromKeyName(params["orgkey"])
    proposals = reject_proposals_query(org)

    # Reject proposals
    try:
        for remain, proposal in timekeeper.iterate(proposals):
            logging.info("reject %s %s %s", remain, org.key(), proposal.key())
            reject_proposal(proposal)
            reject_proposal_email(proposal)

    # Requeue this task for continuation
    except DeadlineExceededError:
        taskqueue.add(url=request.path, params=params)

    # Exit this task successfully
    return responses.terminateTask()
コード例 #4
0
def accept_proposals(request, *args, **kwargs):
    """Accept proposals for an organization
  """

    params = request.POST

    # Setup an artifical request deadline
    timelimit = int(params["timelimit"])
    timekeeper = Timekeeper(timelimit)

    # Query proposals based on status
    org = org_logic.getFromKeyName(params["orgkey"])
    proposals = student_proposal_logic.getProposalsToBeAcceptedForOrg(org)

    # Accept proposals
    try:
        for remain, proposal in timekeeper.iterate(proposals):
            logging.info("accept %s %s %s", remain, org.key(), proposal.key())
            accept_proposal(proposal)
            accept_proposal_email(proposal)

    # Requeue this task for continuation
    except DeadlineExceededError:
        taskqueue.add(url=request.path, params=params)
        return responses.terminateTask()

    # Reject remaining proposals
    taskqueue.add(url=params["nextpath"], params=params)
    return responses.terminateTask()
コード例 #5
0
def _runOrgRoleConversionUpdate(entities, from_role_logic, to_role_model):
  """AppEngine Task that converts a normal Organization Role into a
  GSoCOrganization Role.

  Args:
    entities: Role entities to convert
    from_role_logic: the Role Logic instance where to convert from
    to_role_model: the role Model class where to convert to
  """

  from soc.modules.gsoc.logic.models.organization import logic as \
      gsoc_org_logic
  from soc.modules.gsoc.logic.models.program import logic as gsoc_program_logic

  # get all the properties that are part of each Organization's Role
  role_model = from_role_logic.getModel()
  role_properties = role_model.properties().keys()

  # use this to store all the new Roles
  gsoc_roles = []

  for entity in entities:
    gsoc_properties = {}

    for role_property in role_properties:
      # copy over all the information from the Role entity
      gsoc_properties[role_property] = getattr(entity, role_property)

    # get the Program key belonging to the old Role
    program_key = entity.program.key().id_or_name()
    # get the new GSoCProgram and set it for the Role
    gsoc_program = gsoc_program_logic.getFromKeyName(program_key)
    gsoc_properties['program'] = gsoc_program

    # get the Organization key belonging to the old Role
    org_key = entity.scope.key().id_or_name()
    # get the new GSoCOrganization and set it as scope for the Role
    gsoc_org = gsoc_org_logic.getFromKeyName(org_key)
    gsoc_properties['scope'] = gsoc_org

    # create the new GSoC Role entity and prepare it to be stored
    gsoc_role_entity = to_role_model(key_name=entity.key().name(),
                                        **gsoc_properties)
    gsoc_roles.append(gsoc_role_entity)

  # store all the new GSoC Roles
  db.put(gsoc_roles)

  # task completed, return
  return
コード例 #6
0
def _runOrgRoleConversionUpdate(entities, from_role_logic, to_role_model):
  """AppEngine Task that converts a normal Organization Role into a
  GSoCOrganization Role.

  Args:
    entities: Role entities to convert
    from_role_logic: the Role Logic instance where to convert from
    to_role_model: the role Model class where to convert to
  """

  from soc.modules.gsoc.logic.models.organization import logic as \
      gsoc_org_logic
  from soc.modules.gsoc.logic.models.program import logic as gsoc_program_logic

  # get all the properties that are part of each Organization's Role
  role_model = from_role_logic.getModel()
  role_properties = role_model.properties().keys()

  # use this to store all the new Roles
  gsoc_roles = []

  for entity in entities:
    gsoc_properties = {}

    for role_property in role_properties:
      # copy over all the information from the Role entity
      gsoc_properties[role_property] = getattr(entity, role_property)

    # get the Program key belonging to the old Role
    program_key = entity.program.key().id_or_name()
    # get the new GSoCProgram and set it for the Role
    gsoc_program = gsoc_program_logic.getFromKeyName(program_key)
    gsoc_properties['program'] = gsoc_program

    # get the Organization key belonging to the old Role
    org_key = entity.scope.key().id_or_name()
    # get the new GSoCOrganization and set it as scope for the Role
    gsoc_org = gsoc_org_logic.getFromKeyName(org_key)
    gsoc_properties['scope'] = gsoc_org

    # create the new GSoC Role entity and prepare it to be stored
    gsoc_role_entity = to_role_model(key_name=entity.key().name(),
                                        **gsoc_properties)
    gsoc_roles.append(gsoc_role_entity)

  # store all the new GSoC Roles
  db.put(gsoc_roles)

  # task completed, return
  return
コード例 #7
0
def convert_proposals(request, *args, **kwargs):
  """Convert proposals for all organizations.

  POST Args:
    programkey: the key of the program whose proposals should be converted
    orgkey: the organization key to start at
  """

  # Setup an artifical request deadline
  timelimit = 20000
  timekeeper = Timekeeper(timelimit)

  # Copy for modification below
  params = dicts.merge(request.POST, request.GET)

  if "programkey" not in params:
    logging.error("missing programkey in params: '%s'" % params)
    return responses.terminateTask()

  program = program_logic.getFromKeyName(params["programkey"])

  if not program:
    logging.error("invalid programkey in params: '%s'" % params)
    return responses.terminateTask()

  fields = {
      "scope": program,
      "status": "active",
  }

  # Continue from the next organization
  if "orgkey" in params:
    org = org_logic.getFromKeyName(params["orgkey"])

    if not org:
      logging.error("invalid orgkey in params: '%s'" % params)
      return responses.terminateTask()

    fields["__key__ >="] = org

  # Add a task for each organization
  org = None
  try:
    orgs = org_logic.getQueryForFields(filter=fields)

    for remain, org in timekeeper.iterate(orgs):
      logging.info("convert %s %s", remain, org.key())

      # Compound accept/reject taskflow
      taskqueue.add(
        url = "/tasks/accept_proposals/accept",
        params = {
          "orgkey": org.key().id_or_name(),
          "timelimit": timelimit,
          "nextpath": "/tasks/accept_proposals/reject"
        })

  # Requeue this task for continuation
  except DeadlineExceededError:
    if org:
      params["orgkey"] = org.key().id_or_name()

    taskqueue.add(url=request.path, params=params)

  # Exit this task successfully
  return responses.terminateTask()
コード例 #8
0
def convert_proposals(request, *args, **kwargs):
    """Convert proposals for all organizations.

  POST Args:
    programkey: the key of the program whose proposals should be converted
    orgkey: the organization key to start at
  """

    # Setup an artifical request deadline
    timelimit = 20000
    timekeeper = Timekeeper(timelimit)

    # Copy for modification below
    params = dicts.merge(request.POST, request.GET)

    if "programkey" not in params:
        logging.error("missing programkey in params: '%s'" % params)
        return responses.terminateTask()

    program = program_logic.getFromKeyName(params["programkey"])

    if not program:
        logging.error("invalid programkey in params: '%s'" % params)
        return responses.terminateTask()

    fields = {
        "scope": program,
        "status": "active",
    }

    # Continue from the next organization
    if "orgkey" in params:
        org = org_logic.getFromKeyName(params["orgkey"])

        if not org:
            logging.error("invalid orgkey in params: '%s'" % params)
            return responses.terminateTask()

        fields["__key__ >="] = org

    # Add a task for each organization
    org = None
    try:
        orgs = org_logic.getQueryForFields(filter=fields)

        for remain, org in timekeeper.iterate(orgs):
            logging.info("convert %s %s", remain, org.key())

            # Compound accept/reject taskflow
            taskqueue.add(url="/tasks/accept_proposals/accept",
                          params={
                              "orgkey": org.key().id_or_name(),
                              "timelimit": timelimit,
                              "nextpath": "/tasks/accept_proposals/reject"
                          })

    # Requeue this task for continuation
    except DeadlineExceededError:
        if org:
            params["orgkey"] = org.key().id_or_name()

        taskqueue.add(url=request.path, params=params)

    # Exit this task successfully
    return responses.terminateTask()