Beispiel #1
0
  def _processEntity(self, entity):
    parent = entity.student
    properties = {
        'abstract': entity.abstract,
        'additional_info': entity.additional_info,
        'additional_mentors': entity.additional_mentors,
        'failed_evaluations': entity.failed_evaluations,
        'feed_url': entity.feed_url,
        'mentor': entity.mentor,
        'org': entity.scope,
        'passed_evaluations': entity.passed_evaluations,
        'program': entity.program,
        'public_info': entity.public_info,
        'status': entity.status,
        'title': entity.title,
        }

    # check if the proposal has already been processed
    query = db.Query(GSoCProject)
    query.ancestor(parent)
    query.filter('org = ', entity.scope)
    if query.get():
      return

    # create a new GSoCProposal entity
    project = GSoCProject(parent=parent, **properties)
    project.put()
    def _processEntity(self, entity):
        parent = entity.student
        properties = {
            'abstract': entity.abstract,
            'additional_info': entity.additional_info,
            'additional_mentors': entity.additional_mentors,
            'failed_evaluations': entity.failed_evaluations,
            'feed_url': entity.feed_url,
            'mentor': entity.mentor,
            'org': entity.scope,
            'passed_evaluations': entity.passed_evaluations,
            'program': entity.program,
            'public_info': entity.public_info,
            'status': entity.status,
            'title': entity.title,
        }

        # check if the proposal has already been processed
        query = db.Query(GSoCProject)
        query.ancestor(parent)
        query.filter('org = ', entity.scope)
        if query.get():
            return

        # create a new GSoCProposal entity
        project = GSoCProject(parent=parent, **properties)
        project.put()
Beispiel #3
0
  def context(self):
    assert isSet(self.data.program)
    assert isSet(self.data.url_profile)
    assert isSet(self.data.url_user)

    user = self.data.url_user
    profile = self.data.url_profile
    program = self.data.program
    r = self.redirect.profile()

    links = []

    for project in GSoCProject.all().ancestor(profile):
      r.project(project.key().id())
      links.append(r.urlOf('gsoc_project_details', full=True))

    r = self.redirect.profile()

    return {
        'page_name': '%s Profile - %s' % (program.short_name, profile.name()),
        'program_name': program.name,
        'form_top_msg': LoggedInMsg(self.data, apply_link=False),
        'user': profile_show.UserReadOnlyTemplate(user),
        'profile': GSoCProfileReadOnlyTemplate(profile),
        'links': links,
        'css_prefix': GSoCProfileReadOnlyTemplate.Meta.css_prefix,
        'submit_tax_link': r.urlOf('gsoc_tax_form_admin'),
        'submit_enrollment_link': r.urlOf('gsoc_enrollment_form_admin'),
        }
Beispiel #4
0
        def txn():
            code_sample.put()

            project = GSoCProject.get(project_key)
            if not project.code_samples_submitted:
                project.code_samples_submitted = True
                project.put()
Beispiel #5
0
  def testFeaturedProjectButton(self):
    self.timeline.studentsAnnounced()

    student = GSoCProfileHelper(self.gsoc, self.dev_test)
    student.createOtherUser('*****@*****.**')
    student.createStudent()

    self.data.createOrgAdmin(self.org)

    mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor.createOtherUser('*****@*****.**')
    mentor_entity = mentor.createMentor(self.org)

    project = self.createProject({'parent': self.data.profile,
                                 'mentor': mentor_entity})

    suffix = "%s/%s/%d" % (
        self.gsoc.key().name(),
        self.data.user.key().name(),
        project.key().id())

    url = '/gsoc/project/featured/' + suffix
    postdata = {'value': 'unchecked'}
    response = self.post(url, postdata)

    self.assertResponseOK(response)

    project = GSoCProject.all().get()
    self.assertEqual(project.is_featured, True)
Beispiel #6
0
  def testTakeEvalForStudentProjectWithAnotherOrg(self):
    url, eval, _ = self.getStudentEvalRecordProperties()
    other_org = self.createOrg()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(other_org)

    self.data.createStudentWithProject(other_org, mentor)
    # test student evaluation show GET for a for a student who
    # has another project in a different organization
    response = self.get(url)
    self.assertResponseForbidden(response)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
Beispiel #7
0
  def testTakeEvalForStudent(self):
    eval = self.evaluation.createStudentEvaluation()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    self.data.createStudentWithProject(self.org, mentor)

    project = GSoCProject.all().get()

    base_url = '/gsoc/eval/student'
    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    url = '%s/%s' % (base_url, suffix)

    # test student evaluation show GET for a for a student who
    # has another project in a different organization
    response = self.get(url)
    self.assertEvaluationTakeTemplateUsed(response)

    self.assertContains(response, '%s' % (eval.title))
    self.assertContains(response, 'Project: %s' % (project.title))

    self.assertEqual(response.context['page_name'],
                     '%s' % (eval.title))
    form = response.context['forms'][0]

    self.assertFormFromSchema(form, eval.schema)

    postdata = {
        'frm-t1309871149671-item': 'one line text message',
        'frm-t1309871322655-item': ['Option 2', 'Option 3'],
        'frm-t1309871157535-item': """A quick brown fox jumped over a lazy dog.
        A quick brown fox jumped over a lazy dog. A quick brown fox jumped 
        over a lazy dog. A quick brown fox jumped over a lazy dog.""",
        }
    response = self.post(url, postdata)
    self.assertResponseOK(response)
    self.assertFormError(
        response, 'form', 'frm-t1310822212610-item',
        'This field is required.')

    postdata = {
        'frm-t1309871149671-item': 'one line text message',
        'frm-t1309871322655-item': ['Option 2', 'Option 3'],
        'frm-t1309871157535-item': """A quick brown fox jumped over a lazy dog.
        A quick brown fox jumped over a lazy dog. A quick brown fox jumped 
        over a lazy dog. A quick brown fox jumped over a lazy dog.""",
        'frm-t1310822212610-item': "Wa Wa",
        }
    response = self.post(url, postdata)
    self.assertResponseRedirect(response, '%s?validated' % (url,))

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
  def testRejectProposals(self):
    """Tests reject task for an organization.
    """
    self.testAcceptProposals()
    post_data = {'org_key': self.org.key().name(),
                 'program_key': self.gsoc.key().name()}
    response = self.post(self.REJECT_URL, post_data)
    self.assertEqual(response.status_code, httplib.OK)

    #assert post status of proposals
    self.assertEqual(self.student1_proposals[0].status, 'accepted')
    self.assertEqual(self.student1_proposals[1].status, 'rejected')
    self.assertEqual(self.student2_proposals[0].status, 'rejected')
    self.assertEqual(self.student2_proposals[1].status, 'rejected')
    self.assertEqual(self.student2_proposals[2].status, 'rejected')

    #assert student2 got a reject email
    self.assertEmailSent(to=self.student2.profile.email,
                         subject='Thank you for applying to %s'
                         % self.gsoc.name)
    #assert student2 got no accept email
    self.assertEmailNotSent(to=self.student2.profile.email,
                            subject='Congratulations!')
    #assert student1 got a reject email (already got an accept mail)
    self.assertEmailSent(to=self.student1.profile.email,
                        subject='Thank you for applying to %s'
                        % self.gsoc.name)

    #assert no projects are created for rejected student
    projects = GSoCProject.all().ancestor(self.student2.profile)
    self.assertEqual(projects.count(), 0)
Beispiel #9
0
  def testShowEvalForStudent(self):
    eval = self.evaluation.createStudentEvaluation()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    self.data.createStudentWithProject(self.org, mentor)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    url = '/gsoc/eval/student/show/%s' % (suffix,)

    # test student evaluation show GET for a for a student who
    # has another project in a different organization
    response = self.get(url)
    self.assertEvaluationShowTemplateUsed(response)

    self.ffPastEval(eval)
    response = self.get(url)
    self.assertEvaluationShowTemplateUsed(response)
Beispiel #10
0
  def testShowEvaluationForMentor(self):
    # test student evaluation show GET for a mentor of the same organization
    url, eval, mentor = self.getStudentEvalRecordProperties(show=True)
    response = self.get(url)
    self.assertResponseForbidden(response)

    project = GSoCProject.all().get()

    project_mentors = project.mentors
    project.mentors.append(mentor.key())
    project.put()
    # test student evaluation show GET for the mentor of the project
    response = self.get(url)
    self.assertResponseForbidden(response)

    self.ffPastEval(eval)
    project.mentors = project_mentors
    project.put()

    response = self.get(url)
    self.assertResponseForbidden(response)

    project.mentors.append(mentor.key())
    project.put()

    response = self.get(url)
    self.assertResponseForbidden(response)
Beispiel #11
0
    def txn():
      code_sample.put()

      project = GSoCProject.get(project_key)
      if not project.code_samples_submitted:
        project.code_samples_submitted = True
        project.put()
    def testFeaturedProjectButton(self):
        self.timeline.studentsAnnounced()

        student = GSoCProfileHelper(self.gsoc, self.dev_test)
        student.createOtherUser('*****@*****.**')
        student.createStudent()

        self.data.createOrgAdmin(self.org)

        mentor = GSoCProfileHelper(self.gsoc, self.dev_test)
        mentor.createOtherUser('*****@*****.**')
        mentor_entity = mentor.createMentor(self.org)

        project = self.createProject({
            'parent': self.data.profile,
            'mentor': mentor_entity
        })

        suffix = "%s/%s/%d" % (self.gsoc.key().name(),
                               self.data.user.key().name(), project.key().id())

        url = '/gsoc/project/featured/' + suffix
        postdata = {'value': 'unchecked'}
        response = self.post(url, postdata)

        self.assertResponseOK(response)

        project = GSoCProject.all().get()
        self.assertEqual(project.is_featured, True)
 def createStudent(self):
     """Creates a Student with a project.
 """
     profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
     profile_helper.createOtherUser('*****@*****.**')
     self.student = profile_helper.createStudentWithProject(
         self.org, self.mentor)
     self.project = GSoCProject.all().ancestor(self.student).get()
Beispiel #14
0
 def createStudent(self):
   """Creates a Student with a project.
   """
   profile_helper = GSoCProfileHelper(self.gsoc, self.dev_test)
   profile_helper.createOtherUser('*****@*****.**')
   self.student = profile_helper.createStudentWithProject(self.org,
                                                          self.mentor)
   self.project = GSoCProject.all().ancestor(self.student).get()
Beispiel #15
0
            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()
Beispiel #16
0
 def queryForProject():
   query = GSoCProject.all()
   query.filter('is_featured', True)
   query.filter('program', program)
   if current_timeline == 'coding_period':
     project_status = 'accepted'
   else:
     project_status = 'completed'
   query.filter('status', project_status)
   return query
Beispiel #17
0
      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()
Beispiel #18
0
  def updateRecordsForSurveyGroup(self, request, *args, **kwargs):
    """Updates or creates GradingRecords for the given GradingSurveyGroup.

    Expects the following to be present in the POST dict:
      group_key: Specifies the GradingSurveyGroup key name.
      cursor: optional to specify where the query should continue from.

    Args:
      request: Django Request object
    """
    post_dict = request.POST

    group_key = post_dict.get('group_key')

    if not group_key:
      # invalid task data, log and return OK
      return error_handler.logErrorAndReturnOK(
          'Invalid updateRecordForSurveyGroup data: %s' % post_dict)

    # get the GradingSurveyGroup for the given key
    survey_group = GSoCGradingSurveyGroup.get_by_id(int(group_key))

    if not survey_group:
      # invalid GradingSurveyGroup specified, log and return OK
      return error_handler.logErrorAndReturnOK(
          'Invalid GradingSurveyGroup specified: %s' % group_key)

    q = GSoCProject.all()
    q.filter('program', survey_group.program)
    q.filter('status', 'accepted')

    if 'cursor' in post_dict:
      q.with_cursor(post_dict['cursor'])

    # get the first batch_size number of StudentProjects
    projects = q.fetch(self.DEF_BATCH_SIZE)

    if not projects:
      # task completed, update timestamp for last update complete
      survey_group.last_update_complete = datetime.datetime.now()
      survey_group.put()
      return http.HttpResponse()

    # update/create and batch put the new GradingRecords
    grading_record.updateOrCreateRecordsFor(survey_group, projects)

    # pass along these params as POST to the new task
    task_params = {'group_key': group_key,
                   'cursor': q.cursor()}

    new_task = taskqueue.Task(params=task_params, url=request.path)
    new_task.add()

    # task completed, return OK
    return http.HttpResponse('OK')
Beispiel #19
0
  def testTakeEvaluationForOrgAdmin(self):
    url, eval, _ = self.getStudentEvalRecordProperties()

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'

    show_url = '%s/show/%s' % (base_url, suffix)
    self.data.createOrgAdmin(self.org)
    response = self.get(url)
    self.assertResponseRedirect(response, show_url)
  def testUpdateProject(self):
    """Test updating a Project with a GradingRecord's result.
    """
    post_data = {
        'group_key': self.survey_group.key().id_or_name(),
        }

    response = self.post(self.UPDATE_PROJECTS_URL, post_data)

    self.assertEqual(response.status_code, httplib.OK)
    self.assertTasksInQueue(n=1, url=self.UPDATE_PROJECTS_URL)

    project = GSoCProject.all().get()
    self.assertFalse(project is None)
    self.assertEqual(project.passed_evaluations, [self.grading_record.key()])
    self.assertEqual(1, project.parent().student_info.passed_evaluations)
    def testUpdateProject(self):
        """Test updating a Project with a GradingRecord's result.
    """
        post_data = {
            'group_key': self.survey_group.key().id_or_name(),
        }

        response = self.post(self.UPDATE_PROJECTS_URL, post_data)

        self.assertEqual(response.status_code, httplib.OK)
        self.assertTasksInQueue(n=1, url=self.UPDATE_PROJECTS_URL)

        project = GSoCProject.all().get()
        self.assertFalse(project is None)
        self.assertEqual(project.passed_evaluations,
                         [self.grading_record.key()])
        self.assertEqual(1, project.parent().student_info.passed_evaluations)
Beispiel #22
0
def clear(*args, **kwargs):
  """Removes all entities from the datastore.
  """

  # TODO(dbentley): If there are more than 1000 instances of any model,
  # this method will not clear all instances.  Instead, it should continually
  # call .all(), delete all those, and loop until .all() is empty.
  entities = itertools.chain(*[
      Survey.all(),
      SurveyRecord.all(),
      GCIOrganization.all(),
      GSoCTimeline.all(),
      GCITimeline.all(),
      GSoCProgram.all(),
      GSoCProject.all(),
      GSoCProposal.all(),
      GCIProgram.all(),
      GCIScore.all(),
      GSoCStudentInfo.all(),
      GCIStudentInfo.all(),
      GCITask.all(),
      Sponsor.all(),
      Site.all(),
      Document.all(),
      # The below models are all subclasses of ndb.Model and therefore must
      # use .query() to return all instances instead of .all().
      soc_org_model.SOCOrganization.query(),
      profile_model.Profile.query(),
      soc_profile.SOCStudentData.query(),
      user.User.query(),
      address.Address.query(),
      contact.Contact.query()
      ])

  try:
    for entity in entities:
      if isinstance(entity, ndb.Model):
        entity.key.delete()
      else:
        entity.delete()
  except db.Timeout:
    return http.HttpResponseRedirect('#')
  memcache.flush_all()

  return http.HttpResponse('Done')
Beispiel #23
0
def clear(*args, **kwargs):
    """Removes all entities from the datastore.
  """

    # TODO(dbentley): If there are more than 1000 instances of any model,
    # this method will not clear all instances.  Instead, it should continually
    # call .all(), delete all those, and loop until .all() is empty.
    entities = itertools.chain(*[
        Survey.all(),
        SurveyRecord.all(),
        GCIOrganization.all(),
        GSoCTimeline.all(),
        GCITimeline.all(),
        GSoCProgram.all(),
        GSoCProject.all(),
        GSoCProposal.all(),
        GCIProgram.all(),
        GCIScore.all(),
        GSoCStudentInfo.all(),
        GCIStudentInfo.all(),
        GCITask.all(),
        Sponsor.all(),
        Site.all(),
        Document.all(),
        # The below models are all subclasses of ndb.Model and therefore must
        # use .query() to return all instances instead of .all().
        soc_org_model.SOCOrganization.query(),
        profile_model.Profile.query(),
        soc_profile.SOCStudentData.query(),
        user.User.query(),
        address.Address.query(),
        contact.Contact.query()
    ])

    try:
        for entity in entities:
            if isinstance(entity, ndb.Model):
                entity.key.delete()
            else:
                entity.delete()
    except db.Timeout:
        return http.HttpResponseRedirect('#')
    memcache.flush_all()

    return http.HttpResponse('Done')
Beispiel #24
0
  def testTakeEvaluationForMentor(self):
    url, eval, _ = self.getStudentEvalRecordProperties()

    mentor = self.data.createMentor(self.org)

    # test student evaluation take GET for a mentor of the same organization
    response = self.get(url)
    self.assertResponseForbidden(response)

    response = self.client.post(url)
    self.assertResponseForbidden(response)

    project = GSoCProject.all().get()
    project.mentors.append(mentor.key())
    project.put()
    # test student evaluation take GET for the mentor of the project
    response = self.get(url)
    self.assertResponseForbidden(response)
Beispiel #25
0
  def withdrawProject(link_id, id):
    proposal = getGSoC2011Proposal(link_id, id)
    proposal_key = proposal.key()
    profile = proposal.parent()
    profile_key = profile.key()
    project = GSoCProject.all().ancestor(profile).get()
    project_key = project.key()

    def withdraw_project_txn():
      proposal = db.get(proposal_key)
      project = db.get(project_key)
      profile = db.get(profile_key)

      proposal.status = 'withdrawn'
      project.status = 'withdrawn'
      profile.number_of_projects = 0
      db.put([proposal, project, profile])

    db.run_in_transaction(withdraw_project_txn)
Beispiel #26
0
  def withdrawProject(link_id, id):
    proposal = getGSoC2012Proposal(link_id, id)
    proposal_key = proposal.key()
    profile = proposal.parent()
    profile_key = profile.key()
    project = GSoCProject.all().ancestor(profile).get()
    project_key = project.key()

    def withdraw_project_txn():
      proposal = db.get(proposal_key)
      project = db.get(project_key)
      profile = db.get(profile_key)

      proposal.status = 'withdrawn'
      project.status = 'withdrawn'
      profile.number_of_projects = 0
      db.put([proposal, project, profile])

    db.run_in_transaction(withdraw_project_txn)
Beispiel #27
0
  def testAcceptProposals(self):
    """Tests accept task for an organization.
    """
    #assert current status of proposal to be accepted
    self.assertEqual(self.student1_proposals[0].status, 'pending')

    post_data = {'org_key': self.org.key().name(),
                 'program_key': self.gsoc.key().name()}
    response = self.post(self.ACCEPT_URL, post_data)

    #assert accepted student got proper emails
    self.assertEqual(response.status_code, httplib.OK)
    self.assertEmailSent(to=self.student1.profile.email,
                         subject='Congratulations!')
    self.assertEmailNotSent(to=self.student2.profile.email)

    #assert post status of proposal to be accepted
    self.assertEqual(self.student1_proposals[0].status, 'accepted')

    #assert a project created and associated with accepted student
    projects = GSoCProject.all().ancestor(self.student1.profile)
    self.assertEqual(projects.count(), 1)
    project = projects.get()
    self.assertEqual(project.status, 'accepted')

    #assert reject task is queued
    self.assertTasksInQueue(n=1, url=self.REJECT_URL)

    #assert parameters to task
    for task in self.get_tasks():
      if task['url'] == self.REJECT_URL:
        expected_params = {'org_key':
                           urllib.quote_plus(self.org.key().name()),
                           'program_key':
                           urllib.quote_plus(self.gsoc.key().name())}

        #ignore xsrf token
        self.assertNotEqual(task['params'].get('xsrf_token'), None)
        task_params = task['params'].copy()
        del task_params['xsrf_token']

        self.assertEqual(expected_params, task_params)
Beispiel #28
0
def process(student_info):
  logging.debug("Converting student_info '%r'" % student_info.key())
  proposals = GSoCProposal.all().ancestor(student_info.parent_key()).fetch(1000)
  projects = GSoCProject.all().ancestor(student_info.parent_key()).fetch(1000)

  proposals = [i for i in proposals if i.status != 'withdrawn']
  projects = [i for i in projects if i.status != 'withdrawn']

  nr_proposals = len(proposals)
  nr_projects = len(projects)

  orgs = [GSoCProject.org.get_value_for_datastore(i) for i in projects]

  student_info.number_of_proposals = nr_proposals
  student_info.number_of_projects = nr_projects
  student_info.project_for_orgs = orgs

  yield operation.db.Put(student_info)
  yield operation.counters.Increment("student_infos_converted")
  yield operation.counters.Increment("proposals_counted", delta=nr_proposals)
  yield operation.counters.Increment("projects_counted", delta=nr_projects)
Beispiel #29
0
  def testTakeEvalForStudentWithNoProject(self):
    self.data.createStudent()

    # test student evaluation show GET for a for a student who
    # does not have a project in the program
    url, eval, _ = self.getStudentEvalRecordProperties()
    response = self.get(url)
    self.assertResponseForbidden(response)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
Beispiel #30
0
  def _processEntity(self, entity):
    profile = entity.parent()
    project = GSoCProject.all().ancestor(profile).get()

    properties = {
        'school_name': entity.school_name,
        'school_country': entity.school_country,
        'school_home_page': entity.school_home_page,
        'school_type': entity.school_type,
        'major': entity.major,
        'degree': entity.degree,
        'expected_graduation': entity.expected_graduation,
        'number_of_proposals': GSoCProposal.all().ancestor(profile).count(),
        'number_of_projects': 1 if project is not None else 0,
        'project_for_orgs': [project.org.key()] if project else []  
        }

    studentInfo = GSoCStudentInfo(key_name = profile.key().name(), 
        parent=profile, **properties)
    profile.student_info = studentInfo

    db.run_in_transaction(db.put, [profile, studentInfo])
Beispiel #31
0
  def testTakeEvalForAnotherStudentWithProject(self):
    url, eval, mentor = self.getStudentEvalRecordProperties()

    self.data.createStudentWithProject(self.org, mentor)
    # test student evaluation show GET for a for a student who
    # has another project in the same org and whose mentor is
    # same as the student whose survey is being accessed
    response = self.get(url)
    self.assertResponseForbidden(response)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'

    self.ffPastEval(eval)
    response = self.get(url)
    show_url = '%s/show/%s' % (base_url, suffix)
    self.assertResponseRedirect(response, show_url)
def process(student_info):
    logging.debug("Converting student_info '%r'", student_info.key())
    proposals = GSoCProposal.all().ancestor(
        student_info.parent_key()).fetch(1000)
    projects = GSoCProject.all().ancestor(
        student_info.parent_key()).fetch(1000)

    proposals = [i for i in proposals if i.status != 'withdrawn']
    projects = [i for i in projects if i.status != 'withdrawn']

    nr_proposals = len(proposals)
    nr_projects = len(projects)

    orgs = [GSoCProject.org.get_value_for_datastore(i) for i in projects]

    student_info.number_of_proposals = nr_proposals
    student_info.number_of_projects = nr_projects
    student_info.project_for_orgs = orgs

    yield operation.db.Put(student_info)
    yield operation.counters.Increment("student_infos_converted")
    yield operation.counters.Increment("proposals_counted", delta=nr_proposals)
    yield operation.counters.Increment("projects_counted", delta=nr_projects)
Beispiel #33
0
  def projectFromKwargs(self):
    """Sets the project entity in RequestData object.
    """
    self.profileFromKwargs()
    assert access_checker.isSet(self.data.url_profile)

    # can safely call int, since regexp guarnatees a number
    project_id = int(self.data.kwargs['id'])

    if not project_id:
      raise NotFound(ugettext('Proposal id must be a positive number'))

    self.data.project = GSoCProject.get_by_id(
        project_id, parent=self.data.url_profile)

    if not self.data.project:
      raise NotFound(DEF_NO_PROJECT)

    parent_key = self.data.project.parent_key()
    if self.data.profile and parent_key == self.data.profile.key():
      self.data.project_owner = self.data.profile
    else:
      self.data.project_owner = self.data.project.parent()
Beispiel #34
0
  def getStudentEvalRecordProperties(self, show=False):
    eval = self.evaluation.createStudentEvaluation()

    mentor_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    mentor_profile.createOtherUser('*****@*****.**')
    mentor = mentor_profile.createMentor(self.org)

    student_profile = GSoCProfileHelper(self.gsoc, self.dev_test)
    student_profile.createOtherUser('*****@*****.**')
    student_profile.createStudentWithProject(self.org, mentor)

    project = GSoCProject.all().get()

    suffix = "%s/%s/%s/%s" % (
        self.gsoc.key().name(), eval.link_id,
        project.parent().link_id, project.key().id())

    base_url = '/gsoc/eval/student'
    if show:
      url = '%s/show/%s' % (base_url, suffix)
    else:
      url = '%s/%s' % (base_url, suffix)

    return (url, eval, mentor)
Beispiel #35
0
 def getGSoC2011Project(link_id, id):
   profile = getGSoC2011Profile(link_id)
   return GSoCProject.get_by_id(id, profile)
Beispiel #36
0
def convertGSoCProfileDBEntityGroup(profile_key):
    """Converts DB based part of entity group associated with the specified
  profile.

  Args:
    profile_key: db.Key of the profile to process
  """
    # map that associate old keys with new ones which are created during
    # the conversion
    conversion_map = {}
    to_delete = []
    do_put = True

    proposals = GSoCProposal.all().ancestor(profile_key).fetch(1000)
    for proposal in proposals:
        # update GSoCProposal.parent
        new_proposal = _convertParent(proposal)

        # update GSoCProposal.possible_mentors
        new_proposal.possible_mentors = _convertListProperty(
            GSoCProposal.possible_mentors, new_proposal)

        # update GSoCProposal.mentor
        new_proposal.mentor = _convertReferenceProperty(
            GSoCProposal.mentor, new_proposal)
        to_delete.append(proposal)
        if do_put:
            new_proposal.put()
            conversion_map[proposal.key()] = new_proposal.key()

        comments = GSoCComment.all().ancestor(proposal).fetch(1000)
        for comment in comments:
            # update GSoCComment.parent
            new_comment = _convertParent(comment, parent=new_proposal.key())

            # update GSoCComment.author
            new_comment.author = _convertReferenceProperty(
                GSoCComment.author, new_comment)
            if do_put:
                new_comment.put()
            to_delete.append(comment)

        scores = GSoCScore.all().ancestor(proposal).fetch(1000)
        for score in scores:
            # update GSoCScore.parent
            new_score = _convertParent(score, parent=new_proposal.key())

            # update GSoCScore.author
            new_score.author = _convertReferenceProperty(
                GSoCScore.author, new_score)
            if do_put:
                new_score.put()
            to_delete.append(score)

    projects = GSoCProject.all().ancestor(profile_key).fetch(1000)
    for project in projects:
        # update GSoCProject.parent
        new_project = _convertParent(project)

        # update GSoCProject.mentors
        new_project.mentors = _convertListProperty(GSoCProject.mentors,
                                                   new_project)

        # update GSoCProject.proposal
        proposal_key = GSoCProject.proposal.get_value_for_datastore(project)
        if proposal_key:
            new_project.proposal = conversion_map.get(
                GSoCProject.proposal.get_value_for_datastore(project))

        if do_put:
            new_project.put()
            conversion_map[project.key()] = new_project.key()
        to_delete.append(project)

        grading_records = GSoCGradingRecord.all().ancestor(project.key())
        for grading_record in grading_records:
            # update GSoCGradingProjectSurveyRecord.project
            # this is another entity group, but XG transaction does the thing
            grading_project_survey_record_key = (
                GSoCGradingRecord.mentor_record.get_value_for_datastore(
                    grading_record))
            if grading_project_survey_record_key:
                grading_project_survey_record = GSoCGradingProjectSurveyRecord.get(
                    grading_project_survey_record_key)
                if grading_project_survey_record:
                    grading_project_survey_record.project = new_project.key()
                    if do_put:
                        grading_project_survey_record.put()

            # update GSoCProjectSurveyRecord.project
            # this is another entity group, but XG transaction does the thing
            project_survey_record_key = (
                GSoCGradingRecord.student_record.get_value_for_datastore(
                    grading_record))
            if project_survey_record_key:
                project_survey_record = GSoCProjectSurveyRecord.get(
                    project_survey_record_key)
                if project_survey_record:
                    project_survey_record.project = new_project.key()
                    if do_put:
                        project_survey_record.put()

            # update GSoCGradingRecord.parent
            new_grading_record = _convertParent(grading_record,
                                                parent=new_project.key())
            if do_put:
                new_grading_record.put()

        code_samples = GSoCCodeSample.all().ancestor(project.key())
        for code_sample in code_samples:
            # update GSoCCodeSample.parent
            new_code_sample = _convertParent(code_sample,
                                             parent=new_project.key())
            if do_put:
                new_code_sample.put()
            to_delete.append(code_sample)

    db.delete(to_delete)
Beispiel #37
0
 def getGSoC2012Project(link_id, id):
   profile = getGSoC2012Profile(link_id)
   return GSoCProject.get_by_id(id, profile)
Beispiel #38
0
def seed(request, *args, **kwargs):
  """Seeds the datastore with some default values.
  """

  site_properties = {
      'key_name': 'site',
      'latest_gsoc': 'google/gsoc2014',
      'latest_gci': 'google/gci2013',
      }
  site = Site(**site_properties)
  site.put()

  account = accounts.getCurrentAccount()

  if not account:
    account = users.User(email='*****@*****.**')

  user_properties = {
      'id': 'test',
      'account_id': account.user_id(),
      'account': account,
      }
  current_user = user.User(**user_properties)
  current_user.put()

  group_properties = {
       'key_name': 'google',
       'link_id': 'google',
       'name': 'Google Inc.',
       'short_name': 'Google',
       'home_page': 'http://www.google.com',
       'email': '*****@*****.**',
       'description': 'This is the profile for Google.',
       'contact_street': 'Some Street',
       'contact_city': 'Some City',
       'contact_country': 'United States',
       'contact_postalcode': '12345',
       'phone': '15551110000',
       'status': 'active',
       }
  google = Sponsor(**group_properties)
  google.put()

  now = datetime.datetime.now()
  before = now - datetime.timedelta(365)
  after = now + datetime.timedelta(365)
  past_before = before - datetime.timedelta(2 * 365)
  past_after = after - datetime.timedelta(2 * 365)

  timeline_properties = {
      'key_name': 'google/gsoc2014',
      'link_id': 'gsoc2014',
      'scope': google,
      'program_start': before,
      'program_end': after,
      'accepted_organization_announced_deadline': before,
      'accepted_students_announced_deadline' : after,
      'student_signup_start': before,
      'student_signup_end': after,
      'application_review_deadline': after,
      'student_application_matched_deadline': after,
      'accepted_students_announced_deadline': after,
      'form_submission_start': before,
  }
  gsoc2014_timeline = GSoCTimeline(**timeline_properties)
  gsoc2014_timeline.put()

  program_properties = {
      'key_name': 'google/gsoc2014',
      'link_id': 'gsoc2014',
      'program_id': 'gsoc2014',
      'sponsor': google,
      'scope': google,
      'name': 'Google Summer of Code 2014',
      'short_name': 'GSoC 2014',
      'description': 'This is the program for GSoC 2014.',
      'apps_tasks_limit': 42,
      'slots': 42,
      'timeline': gsoc2014_timeline,
      'status': program_model.STATUS_VISIBLE,
      }
  gsoc2014 = GSoCProgram(**program_properties)
  gsoc2014.put()

  timeline_properties.update({
      'key_name': 'google/gsoc2010',
      'link_id': 'gsoc2010',
      'program_start': past_before,
      'program_end': past_after,
      'accepted_organization_announced_deadline': past_before,
      'accepted_students_announced_deadline' : past_after,
      'student_signup_start': past_before,
      'student_signup_end': past_after,
      'application_review_deadline': past_after,
      'student_application_matched_deadline': past_after,
      'accepted_students_announced_deadline': past_after,
      'form_submission_start': past_before,
  })
  gsoc2010_timeline = GSoCTimeline(**timeline_properties)
  gsoc2010_timeline.put()

  program_properties.update({
      'key_name': 'google/gsoc2010',
      'link_id': 'gsoc2010',
      'program_id': 'gsoc2010',
      'name': 'Google Summer of Code 2010',
      'description': 'This is the program for GSoC 2010.',
      'short_name': 'GSoC 2010',
      'timeline': gsoc2010_timeline,
  })
  gsoc2010 = GSoCProgram(**program_properties)
  gsoc2010.put()

  # TODO(drew): Replace gsoc2014.prefix with whatever its replacement becomes
  # once prefix is removed from program and no longer used in the query for
  # OrgAppSurvey in soc.views.helper.RequestData._getProgramWideFields().
  org_app_survey_properties = {
    'key_name' : '%s/%s/orgapp' % (gsoc2014.prefix, gsoc2014.key().name()),
    'program' : gsoc2014,
    'title' : 'Org App Survey',
    'content' : 'Here is some content.',
    'modified_by' : current_user.key.to_old_key(),
    'survey_start' : before,
    'survey_end' : after
  }
  org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put()

  org_app_survey_properties['key_name'] = ('%s/%s/orgapp' % (
      gsoc2010.prefix, gsoc2010.key().name()))
  org_app_survey_properties['program'] = gsoc2010
  org_app_survey_properties['survey_start'] = past_before
  org_app_survey_properties['survey_end'] = past_after
  org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put()

  timeline_properties = {
        'key_name': 'google/gci2013',
        'link_id': 'gci2013',
        'scope': google,
        'program_start': before,
        'program_end': after,
        'accepted_organization_announced_deadline': before,
        'student_signup_start': before,
        'student_signup_end': after,
        'tasks_publicly_visible': before,
        'task_claim_deadline': after,
        'stop_all_work_deadline': after,
  }
  gci2013_timeline = GCITimeline(**timeline_properties)
  gci2013_timeline.put()

  program_properties.update({
      'key_name': 'google/gci2013',
      'link_id': 'gci2013',
      'program_id': 'gci2013',
      'name': 'Google Code In Contest 2013',
      'short_name': 'GCI 2009',
      'description': 'This is the program for GCI 2013.',
      'timeline': gci2013_timeline,
      })
  gci2013 = GCIProgram(**program_properties)
  gci2013.put()

  site.active_program = gci2013
  site.put()

  current_user.host_for = [
      ndb.Key.from_old_key(gsoc2010.key()),
      ndb.Key.from_old_key(gsoc2014.key()),
      ndb.Key.from_old_key(gci2013.key())]
  current_user.put()

  group_properties.update({
    'key_name': 'google/gci2013/melange',
    'link_id': 'melange',
    'name': 'Melange Development Team',
    'short_name': 'Melange',
    'scope': gci2013,
    'program': gci2013,
    'sponsor': google,
    'home_page': 'http://code.google.com/p/soc',
    'description': 'Melange, share the love!',
    'license_name': 'Apache License',
    'ideas': 'http://code.google.com/p/soc/issues',
    })
  melange = GCIOrganization(**group_properties)
  melange.put()

  group_properties.update({
    'scope': gsoc2014,
    'program': gsoc2014,
    })

  address_properties = address.Address(
      street='1 Test St.',
      city='Some City',
      country='United States',
      postal_code='12345')
  address_properties.put()

  contact_info = contact.Contact(email='*****@*****.**')
  contact_info.put()

  gsoc_delta = datetime.timedelta(days=(365 * 18))

  profile_properties = {
      'id': gsoc2014.key().name() + '/' + current_user.key.id(),
      'parent': current_user.key,
      'public_name': 'test',
      'program': ndb.Key.from_old_key(gsoc2014.key()),
      'first_name': 'Test',
      'last_name': 'Example',
      'contact' : contact_info,
      'residential_address' : address_properties,
      'shipping_address' : address_properties,
      'birth_date' : datetime.date.today() - gsoc_delta,
      'program_knowledge' : 'Friend referral',
      }
  profile = profile_model.Profile(**profile_properties)

  ndb_orgs = []
  for i in range(15):
    group_properties.update({
        'key_name': 'google/gsoc2014/org_%d' % i,
        'link_id': 'org_%d' % i,
        'name': 'Organization %d' % i,
        'short_name': 'Org %d' % i,
        'description': 'Organization %d!' % i,
        })

    org_properties = {
        'name': 'Organization %d' % i,
        'org_id': 'org_%d' % i,
        'program': ndb.Key.from_old_key(gsoc2014.key()),
        'description': 'Organization %d!' % i,
        }
    org = soc_org_model.SOCOrganization(
        id='google/gsoc2014/org_%d' % i, **org_properties)
    org.put()
    ndb_orgs.append(org)

    # Admin (and thus mentor) for the first org
    if i == 0:
      profile.admin_for.append(org.key)
      profile.mentor_for.append(org.key)
      profile.put()

    # Mentor for the second org
    if i == 1:
      profile.mentor_for.append(org.key)
      profile.put()

  profile_properties.update({
      'id': gci2013.key().name() + '/' + current_user.key.id(),
      'parent': current_user.key,
      'program': ndb.Key.from_old_key(gci2013.key()),
      'admin_for': [ndb.Key.from_old_key(melange.key())],
      'mentor_for': [ndb.Key.from_old_key(melange.key())],
      })
  melange_admin = profile_model.Profile(**profile_properties)
  # TODO: add GCI orgs
  melange_admin.put()

  task_properties = {
      'status': 'Open',
      'modified_by': melange_admin.key.to_old_key(),
      'subscribers': [melange_admin.key.to_old_key()],
      'title': 'Awesomeness',
      'created_by': melange_admin.key.to_old_key(),
      'created_on': now,
      'program': gci2013,
      'time_to_complete': 1337,
      'modified_on': now,
      'org': melange.key(),
      'description': '<p>AWESOME</p>',
      'difficulty_level': DifficultyLevel.MEDIUM,
      'types': ['Code']
  }
  gci_task = GCITask(**task_properties)
  gci_task.put()

  user_properties = {
      'id': 'student',
      'account_id': '12345',
      'account': users.User(email='*****@*****.**'),
      }
  student_user = user.User(**user_properties)
  student_user.put()

  gci_delta = datetime.timedelta(days=(365 * 14))

  contact_properties = contact.Contact(
      email='*****@*****.**',
      web_page='http://www.homepage.com/',
      blog='http://www.blog.com/',
      phone='1650253000')
  contact_properties.put()

  graduation_year = datetime.date.today() + datetime.timedelta(days=365)

  student_data = soc_profile.SOCStudentData(
      education=education.Education(
          school_id="123",
          school_country="United States",
          expected_graduation=int(graduation_year.strftime('%Y')),
          major='Some Major',
          degree=education.Degree.UNDERGRADUATE)
      )
  student_data.put()

  student_id = 'student'
  student_properties = {
      'id': gsoc2014.key().name() + "/" + student_id,
      'parent': student_user.key,
      'program': ndb.Key.from_old_key(gsoc2014.key()),
      'public_name': 'Student',
      'first_name': 'Student',
      'last_name': 'Student',
      'contact' : contact_properties,
      'residential_address' : address_properties,
      'shipping_address' : address_properties,
      'birth_date': datetime.date.today() - gci_delta,
      'tee_size': profile_model.TeeSize.L,
      'tee_style': profile_model.TeeStyle.MALE,
      'gender' : profile_model.Gender.MALE,
      'program_knowledge': 'Friend referral.',
      'student_data' : student_data,
      }
  melange_student = profile_model.Profile(**student_properties)
  melange_student.put()

  student_id = 'student2'
  user_properties = {
      'id': student_id,
      'account_id': 'student2',
      'account': users.User(email='*****@*****.**'),
      }
  student_user2 = user.User(**user_properties)
  student_user2.put()

  student_properties.update({
      'id': gsoc2014.key().name() + "/" + student_id,
      'parent': student_user2.key,
      'first_name' : 'Student 2',
      'last_name' : 'Example'
  })
  melange_student2 = profile_model.Profile(**student_properties)
  melange_student2.put()

  proposal_properties = {
      'parent': melange_student.key.to_old_key(),
      'program': gsoc2014,
      'title': 'test proposal',
      'abstract': 'test abstract',
      'content': 'test content',
      'mentor': profile.key.to_old_key(),
      'status': 'accepted',
      'has_mentor': True,
      'org': ndb_orgs[0].key.to_old_key(),
      'possible_mentors': [profile.key.to_old_key()]
      }
  melange_proposal = GSoCProposal(**proposal_properties)
  melange_proposal.put()

  project_properties = {
      'title': 'test project',
      'abstract': 'test abstract',
      'status': 'accepted',
      'parent': melange_student.key.to_old_key(),
      'mentors': [profile.key.to_old_key()],
      'program':  gsoc2014,
      'org': ndb_orgs[0].key.to_old_key(),
      'proposal' : melange_proposal.key(),
       }
  melange_project = GSoCProject(**project_properties)
  melange_project.put()
  ndb_orgs[1].slot_allocation = 1
  ndb_orgs[1].put()

  student_data.number_of_projects = 1
  student_data.number_of_proposals = 1
  student_data.project_for_orgs = [ndb_orgs[1].key]

  melange_student.put()
  melange_student2.put()

  project_properties.update({
      'student': melange_student2,
      'title': 'test project2'
      })
  melange_project2 = GSoCProject(**project_properties)
  melange_project2.put()
  ndb_orgs[1].slot_allocation += 1
  ndb_orgs[1].put()

  student_id = 'student'
  student_properties.update({
      'id': gci2013.key().name() + '/' + student_id,
      'parent': student_user.key,
      'program': ndb.Key.from_old_key(gci2013.key()),
  })
  gci_student = profile_model.Profile(**student_properties)
  gci_student.put()

  score_properties = {
      'parent': gci_student.key.to_old_key(),
      'program': gci2013,
      'points': 5,
      'tasks': [gci_task.key()]
      }
  score = GCIScore(**score_properties)
  score.put()

  document_properties = {
      'key_name': 'site/site/home',
      'link_id': 'home',
      'scope': site,
      'prefix': 'site',
      'author': current_user.key.to_old_key(),
      'title': 'Home Page',
      'content': 'This is the Home Page',
      'modified_by': current_user.key.to_old_key(),
      }
  home_document = Document(**document_properties)
  home_document.put()

  document_properties = {
      'key_name': 'user/test/notes',
      'link_id': 'notes',
      'scope': current_user.key.to_old_key(),
      'prefix': 'user',
      'author': current_user.key.to_old_key(),
      'title': 'My Notes',
      'content': 'These are my notes',
      'modified_by': current_user.key.to_old_key(),
      }
  notes_document = Document(**document_properties)
  notes_document.put()

  site.home = home_document
  site.put()

  memcache.flush_all()

  return http.HttpResponse('Done')
Beispiel #39
0
def convertGSoCProfileDBEntityGroup(profile_key):
  """Converts DB based part of entity group associated with the specified
  profile.

  Args:
    profile_key: db.Key of the profile to process
  """
  # map that associate old keys with new ones which are created during
  # the conversion
  conversion_map = {}
  to_delete = []
  do_put = True

  proposals = GSoCProposal.all().ancestor(profile_key).fetch(1000)
  for proposal in proposals:
    # update GSoCProposal.parent
    new_proposal = _convertParent(proposal)

    # update GSoCProposal.possible_mentors
    new_proposal.possible_mentors = _convertListProperty(
        GSoCProposal.possible_mentors, new_proposal)

    # update GSoCProposal.mentor
    new_proposal.mentor = _convertReferenceProperty(
        GSoCProposal.mentor, new_proposal)
    to_delete.append(proposal)
    if do_put:
      new_proposal.put()
      conversion_map[proposal.key()] = new_proposal.key()

    comments = GSoCComment.all().ancestor(proposal).fetch(1000)
    for comment in comments:
      # update GSoCComment.parent
      new_comment = _convertParent(comment, parent=new_proposal.key())

      # update GSoCComment.author
      new_comment.author = _convertReferenceProperty(
          GSoCComment.author, new_comment)
      if do_put:
        new_comment.put()
      to_delete.append(comment)

    scores = GSoCScore.all().ancestor(proposal).fetch(1000)
    for score in scores:
      # update GSoCScore.parent
      new_score = _convertParent(score, parent=new_proposal.key())

      # update GSoCScore.author
      new_score.author = _convertReferenceProperty(GSoCScore.author, new_score)
      if do_put:
        new_score.put()
      to_delete.append(score)

  projects = GSoCProject.all().ancestor(profile_key).fetch(1000)
  for project in projects:
    # update GSoCProject.parent
    new_project = _convertParent(project)

    # update GSoCProject.mentors
    new_project.mentors = _convertListProperty(GSoCProject.mentors, new_project)

    # update GSoCProject.proposal
    proposal_key = GSoCProject.proposal.get_value_for_datastore(project)
    if proposal_key:
      new_project.proposal = conversion_map.get(
          GSoCProject.proposal.get_value_for_datastore(project))

    if do_put:
      new_project.put()
      conversion_map[project.key()] = new_project.key()
    to_delete.append(project)

    grading_records = GSoCGradingRecord.all().ancestor(project.key())
    for grading_record in grading_records:
      # update GSoCGradingProjectSurveyRecord.project
      # this is another entity group, but XG transaction does the thing
      grading_project_survey_record_key = (
          GSoCGradingRecord.mentor_record.get_value_for_datastore(
              grading_record))
      if grading_project_survey_record_key:
        grading_project_survey_record = GSoCGradingProjectSurveyRecord.get(
            grading_project_survey_record_key)
        if grading_project_survey_record:
          grading_project_survey_record.project = new_project.key()
          if do_put:
            grading_project_survey_record.put()

      # update GSoCProjectSurveyRecord.project
      # this is another entity group, but XG transaction does the thing
      project_survey_record_key = (
          GSoCGradingRecord.student_record.get_value_for_datastore(
              grading_record))
      if project_survey_record_key:
        project_survey_record = GSoCProjectSurveyRecord.get(
            project_survey_record_key)
        if project_survey_record:
          project_survey_record.project = new_project.key()
          if do_put:
            project_survey_record.put()

      # update GSoCGradingRecord.parent
      new_grading_record = _convertParent(
          grading_record, parent=new_project.key())
      if do_put:
        new_grading_record.put()

    code_samples = GSoCCodeSample.all().ancestor(project.key())
    for code_sample in code_samples:
      # update GSoCCodeSample.parent
      new_code_sample = _convertParent(code_sample, parent=new_project.key())
      if do_put:
        new_code_sample.put()
      to_delete.append(code_sample)

  db.delete(to_delete)
Beispiel #40
0
def seed(request, *args, **kwargs):
    """Seeds the datastore with some default values.
  """

    site_properties = {
        'key_name': 'site',
        'latest_gsoc': 'google/gsoc2014',
        'latest_gci': 'google/gci2013',
    }
    site = Site(**site_properties)
    site.put()

    account = accounts.getCurrentAccount()

    if not account:
        account = users.User(email='*****@*****.**')

    user_properties = {
        'id': 'test',
        'account_id': account.user_id(),
        'account': account,
    }
    current_user = user.User(**user_properties)
    current_user.put()

    group_properties = {
        'key_name': 'google',
        'link_id': 'google',
        'name': 'Google Inc.',
        'short_name': 'Google',
        'home_page': 'http://www.google.com',
        'email': '*****@*****.**',
        'description': 'This is the profile for Google.',
        'contact_street': 'Some Street',
        'contact_city': 'Some City',
        'contact_country': 'United States',
        'contact_postalcode': '12345',
        'phone': '15551110000',
        'status': 'active',
    }
    google = Sponsor(**group_properties)
    google.put()

    now = datetime.datetime.now()
    before = now - datetime.timedelta(365)
    after = now + datetime.timedelta(365)
    past_before = before - datetime.timedelta(2 * 365)
    past_after = after - datetime.timedelta(2 * 365)

    timeline_properties = {
        'key_name': 'google/gsoc2014',
        'link_id': 'gsoc2014',
        'scope': google,
        'program_start': before,
        'program_end': after,
        'accepted_organization_announced_deadline': before,
        'accepted_students_announced_deadline': after,
        'student_signup_start': before,
        'student_signup_end': after,
        'application_review_deadline': after,
        'student_application_matched_deadline': after,
        'accepted_students_announced_deadline': after,
        'form_submission_start': before,
    }
    gsoc2014_timeline = GSoCTimeline(**timeline_properties)
    gsoc2014_timeline.put()

    program_properties = {
        'key_name': 'google/gsoc2014',
        'link_id': 'gsoc2014',
        'program_id': 'gsoc2014',
        'sponsor': google,
        'scope': google,
        'name': 'Google Summer of Code 2014',
        'short_name': 'GSoC 2014',
        'description': 'This is the program for GSoC 2014.',
        'apps_tasks_limit': 42,
        'slots': 42,
        'timeline': gsoc2014_timeline,
        'status': program_model.STATUS_VISIBLE,
    }
    gsoc2014 = GSoCProgram(**program_properties)
    gsoc2014.put()

    timeline_properties.update({
        'key_name': 'google/gsoc2010',
        'link_id': 'gsoc2010',
        'program_start': past_before,
        'program_end': past_after,
        'accepted_organization_announced_deadline': past_before,
        'accepted_students_announced_deadline': past_after,
        'student_signup_start': past_before,
        'student_signup_end': past_after,
        'application_review_deadline': past_after,
        'student_application_matched_deadline': past_after,
        'accepted_students_announced_deadline': past_after,
        'form_submission_start': past_before,
    })
    gsoc2010_timeline = GSoCTimeline(**timeline_properties)
    gsoc2010_timeline.put()

    program_properties.update({
        'key_name': 'google/gsoc2010',
        'link_id': 'gsoc2010',
        'program_id': 'gsoc2010',
        'name': 'Google Summer of Code 2010',
        'description': 'This is the program for GSoC 2010.',
        'short_name': 'GSoC 2010',
        'timeline': gsoc2010_timeline,
    })
    gsoc2010 = GSoCProgram(**program_properties)
    gsoc2010.put()

    # TODO(drew): Replace gsoc2014.prefix with whatever its replacement becomes
    # once prefix is removed from program and no longer used in the query for
    # OrgAppSurvey in soc.views.helper.RequestData._getProgramWideFields().
    org_app_survey_properties = {
        'key_name': '%s/%s/orgapp' % (gsoc2014.prefix, gsoc2014.key().name()),
        'program': gsoc2014,
        'title': 'Org App Survey',
        'content': 'Here is some content.',
        'modified_by': current_user.key.to_old_key(),
        'survey_start': before,
        'survey_end': after
    }
    org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put()

    org_app_survey_properties['key_name'] = (
        '%s/%s/orgapp' % (gsoc2010.prefix, gsoc2010.key().name()))
    org_app_survey_properties['program'] = gsoc2010
    org_app_survey_properties['survey_start'] = past_before
    org_app_survey_properties['survey_end'] = past_after
    org_app_survey_model.OrgAppSurvey(**org_app_survey_properties).put()

    timeline_properties = {
        'key_name': 'google/gci2013',
        'link_id': 'gci2013',
        'scope': google,
        'program_start': before,
        'program_end': after,
        'accepted_organization_announced_deadline': before,
        'student_signup_start': before,
        'student_signup_end': after,
        'tasks_publicly_visible': before,
        'task_claim_deadline': after,
        'stop_all_work_deadline': after,
    }
    gci2013_timeline = GCITimeline(**timeline_properties)
    gci2013_timeline.put()

    program_properties.update({
        'key_name': 'google/gci2013',
        'link_id': 'gci2013',
        'program_id': 'gci2013',
        'name': 'Google Code In Contest 2013',
        'short_name': 'GCI 2009',
        'description': 'This is the program for GCI 2013.',
        'timeline': gci2013_timeline,
    })
    gci2013 = GCIProgram(**program_properties)
    gci2013.put()

    site.active_program = gci2013
    site.put()

    current_user.host_for = [
        ndb.Key.from_old_key(gsoc2010.key()),
        ndb.Key.from_old_key(gsoc2014.key()),
        ndb.Key.from_old_key(gci2013.key())
    ]
    current_user.put()

    group_properties.update({
        'key_name': 'google/gci2013/melange',
        'link_id': 'melange',
        'name': 'Melange Development Team',
        'short_name': 'Melange',
        'scope': gci2013,
        'program': gci2013,
        'sponsor': google,
        'home_page': 'http://code.google.com/p/soc',
        'description': 'Melange, share the love!',
        'license_name': 'Apache License',
        'ideas': 'http://code.google.com/p/soc/issues',
    })
    melange = GCIOrganization(**group_properties)
    melange.put()

    group_properties.update({
        'scope': gsoc2014,
        'program': gsoc2014,
    })

    address_properties = address.Address(street='1 Test St.',
                                         city='Some City',
                                         country='United States',
                                         postal_code='12345')
    address_properties.put()

    contact_info = contact.Contact(email='*****@*****.**')
    contact_info.put()

    gsoc_delta = datetime.timedelta(days=(365 * 18))

    profile_properties = {
        'id': gsoc2014.key().name() + '/' + current_user.key.id(),
        'parent': current_user.key,
        'public_name': 'test',
        'program': ndb.Key.from_old_key(gsoc2014.key()),
        'first_name': 'Test',
        'last_name': 'Example',
        'contact': contact_info,
        'residential_address': address_properties,
        'shipping_address': address_properties,
        'birth_date': datetime.date.today() - gsoc_delta,
        'program_knowledge': 'Friend referral',
    }
    profile = profile_model.Profile(**profile_properties)

    ndb_orgs = []
    for i in range(15):
        group_properties.update({
            'key_name': 'google/gsoc2014/org_%d' % i,
            'link_id': 'org_%d' % i,
            'name': 'Organization %d' % i,
            'short_name': 'Org %d' % i,
            'description': 'Organization %d!' % i,
        })

        org_properties = {
            'name': 'Organization %d' % i,
            'org_id': 'org_%d' % i,
            'program': ndb.Key.from_old_key(gsoc2014.key()),
            'description': 'Organization %d!' % i,
        }
        org = soc_org_model.SOCOrganization(id='google/gsoc2014/org_%d' % i,
                                            **org_properties)
        org.put()
        ndb_orgs.append(org)

        # Admin (and thus mentor) for the first org
        if i == 0:
            profile.admin_for.append(org.key)
            profile.mentor_for.append(org.key)
            profile.put()

        # Mentor for the second org
        if i == 1:
            profile.mentor_for.append(org.key)
            profile.put()

    profile_properties.update({
        'id':
        gci2013.key().name() + '/' + current_user.key.id(),
        'parent':
        current_user.key,
        'program':
        ndb.Key.from_old_key(gci2013.key()),
        'admin_for': [ndb.Key.from_old_key(melange.key())],
        'mentor_for': [ndb.Key.from_old_key(melange.key())],
    })
    melange_admin = profile_model.Profile(**profile_properties)
    # TODO: add GCI orgs
    melange_admin.put()

    task_properties = {
        'status': 'Open',
        'modified_by': melange_admin.key.to_old_key(),
        'subscribers': [melange_admin.key.to_old_key()],
        'title': 'Awesomeness',
        'created_by': melange_admin.key.to_old_key(),
        'created_on': now,
        'program': gci2013,
        'time_to_complete': 1337,
        'modified_on': now,
        'org': melange.key(),
        'description': '<p>AWESOME</p>',
        'difficulty_level': DifficultyLevel.MEDIUM,
        'types': ['Code']
    }
    gci_task = GCITask(**task_properties)
    gci_task.put()

    user_properties = {
        'id': 'student',
        'account_id': '12345',
        'account': users.User(email='*****@*****.**'),
    }
    student_user = user.User(**user_properties)
    student_user.put()

    gci_delta = datetime.timedelta(days=(365 * 14))

    contact_properties = contact.Contact(email='*****@*****.**',
                                         web_page='http://www.homepage.com/',
                                         blog='http://www.blog.com/',
                                         phone='1650253000')
    contact_properties.put()

    graduation_year = datetime.date.today() + datetime.timedelta(days=365)

    student_data = soc_profile.SOCStudentData(education=education.Education(
        school_id="123",
        school_country="United States",
        expected_graduation=int(graduation_year.strftime('%Y')),
        major='Some Major',
        degree=education.Degree.UNDERGRADUATE))
    student_data.put()

    student_id = 'student'
    student_properties = {
        'id': gsoc2014.key().name() + "/" + student_id,
        'parent': student_user.key,
        'program': ndb.Key.from_old_key(gsoc2014.key()),
        'public_name': 'Student',
        'first_name': 'Student',
        'last_name': 'Student',
        'contact': contact_properties,
        'residential_address': address_properties,
        'shipping_address': address_properties,
        'birth_date': datetime.date.today() - gci_delta,
        'tee_size': profile_model.TeeSize.L,
        'tee_style': profile_model.TeeStyle.MALE,
        'gender': profile_model.Gender.MALE,
        'program_knowledge': 'Friend referral.',
        'student_data': student_data,
    }
    melange_student = profile_model.Profile(**student_properties)
    melange_student.put()

    student_id = 'student2'
    user_properties = {
        'id': student_id,
        'account_id': 'student2',
        'account': users.User(email='*****@*****.**'),
    }
    student_user2 = user.User(**user_properties)
    student_user2.put()

    student_properties.update({
        'id': gsoc2014.key().name() + "/" + student_id,
        'parent': student_user2.key,
        'first_name': 'Student 2',
        'last_name': 'Example'
    })
    melange_student2 = profile_model.Profile(**student_properties)
    melange_student2.put()

    proposal_properties = {
        'parent': melange_student.key.to_old_key(),
        'program': gsoc2014,
        'title': 'test proposal',
        'abstract': 'test abstract',
        'content': 'test content',
        'mentor': profile.key.to_old_key(),
        'status': 'accepted',
        'has_mentor': True,
        'org': ndb_orgs[0].key.to_old_key(),
        'possible_mentors': [profile.key.to_old_key()]
    }
    melange_proposal = GSoCProposal(**proposal_properties)
    melange_proposal.put()

    project_properties = {
        'title': 'test project',
        'abstract': 'test abstract',
        'status': 'accepted',
        'parent': melange_student.key.to_old_key(),
        'mentors': [profile.key.to_old_key()],
        'program': gsoc2014,
        'org': ndb_orgs[0].key.to_old_key(),
        'proposal': melange_proposal.key(),
    }
    melange_project = GSoCProject(**project_properties)
    melange_project.put()
    ndb_orgs[1].slot_allocation = 1
    ndb_orgs[1].put()

    student_data.number_of_projects = 1
    student_data.number_of_proposals = 1
    student_data.project_for_orgs = [ndb_orgs[1].key]

    melange_student.put()
    melange_student2.put()

    project_properties.update({
        'student': melange_student2,
        'title': 'test project2'
    })
    melange_project2 = GSoCProject(**project_properties)
    melange_project2.put()
    ndb_orgs[1].slot_allocation += 1
    ndb_orgs[1].put()

    student_id = 'student'
    student_properties.update({
        'id': gci2013.key().name() + '/' + student_id,
        'parent': student_user.key,
        'program': ndb.Key.from_old_key(gci2013.key()),
    })
    gci_student = profile_model.Profile(**student_properties)
    gci_student.put()

    score_properties = {
        'parent': gci_student.key.to_old_key(),
        'program': gci2013,
        'points': 5,
        'tasks': [gci_task.key()]
    }
    score = GCIScore(**score_properties)
    score.put()

    document_properties = {
        'key_name': 'site/site/home',
        'link_id': 'home',
        'scope': site,
        'prefix': 'site',
        'author': current_user.key.to_old_key(),
        'title': 'Home Page',
        'content': 'This is the Home Page',
        'modified_by': current_user.key.to_old_key(),
    }
    home_document = Document(**document_properties)
    home_document.put()

    document_properties = {
        'key_name': 'user/test/notes',
        'link_id': 'notes',
        'scope': current_user.key.to_old_key(),
        'prefix': 'user',
        'author': current_user.key.to_old_key(),
        'title': 'My Notes',
        'content': 'These are my notes',
        'modified_by': current_user.key.to_old_key(),
    }
    notes_document = Document(**document_properties)
    notes_document.put()

    site.home = home_document
    site.put()

    memcache.flush_all()

    return http.HttpResponse('Done')
Beispiel #41
0
    def spawnRemindersForProjectSurvey(self, request, *args, **kwargs):
        """Spawns tasks for each GSoCProject in the given Program.

    Expects the following to be present in the POST dict:
      program_key: Specifies the program key name for which to loop over all
                   the GSoCProject entities
      survey_key: specifies the key name for the ProjectSurvey to send
                  reminders for
      survey_type: a string which is project or grading depending on
                   the type of Survey.
      cursor: optional query cursor to indicate how far along we are.

    Args:
      request: Django Request object
    """
        post_dict = request.POST

        # retrieve the program_key and survey_key from POST data
        program_key = post_dict.get('program_key')
        survey_key = post_dict.get('survey_key')
        survey_type = post_dict.get('survey_type')

        if not (program_key and survey_key and survey_type):
            # invalid task data, log and return OK
            return error_handler.logErrorAndReturnOK(
                'Invalid spawnRemindersForProjectSurvey data: %s' % post_dict)

        program_entity = GSoCProgram.get_by_key_name(program_key)

        if not program_entity:
            # invalid program specified, log and return OK
            return error_handler.logErrorAndReturnOK(
                'Invalid program specified: %s' % program_key)

        q = GSoCProject.all()
        q.filter('status', 'accepted')
        q.filter('program', program_entity)

        if 'cursor' in post_dict:
            q.with_cursor(post_dict['cursor'])

        projects = q.fetch(self.BATCH_SIZE)

        if not projects:
            # we are done, return OK
            return http.HttpResponse()

        for project in projects:
            task_params = {
                'survey_key': survey_key,
                'survey_type': survey_type,
                'project_key': str(project.key())
            }
            task_url = '/tasks/gsoc/surveys/send_reminder/send'

            new_task = taskqueue.Task(params=task_params, url=task_url)
            new_task.add('mail')

        # pass along these params as POST to the new task
        task_params = {
            'program_key': program_key,
            'survey_key': survey_key,
            'survey_type': survey_type,
            'cursor': q.cursor()
        }
        task_url = request.path
        new_task = taskqueue.Task(params=task_params, url=task_url)
        new_task.add()

        # return OK
        return http.HttpResponse()
Beispiel #42
0
  def testAcceptProposals(self):
    """Tests accept task for an organization.
    """
    from soc.modules.gsoc.models.program import GSoCProgramMessages
    properties = {
        'parent': self.gsoc,
    }
    self.seed(GSoCProgramMessages, properties)

    #assert current status of proposal to be accepted
    self.assertEqual(self.student1_proposals[0].status, 'pending')

    post_data = {'org_key': self.org.key().name(),
                 'program_key': self.gsoc.key().name()}
    response = self.post(self.ACCEPT_URL, post_data)

    #assert accepted student got proper emails
    self.assertEqual(response.status_code, httplib.OK)
    self.assertEmailSent(to=self.student1.profile.email,
                         subject='Congratulations!')
    self.assertEmailNotSent(to=self.student2.profile.email)

    #assert post status of proposal to be accepted
    self.assertEqual(self.student1_proposals[0].status, 'accepted')

    #assert a project created and associated with accepted student
    projects = GSoCProject.all().ancestor(self.student1.profile)
    self.assertEqual(projects.count(), 1)
    project = projects.get()
    self.assertEqual(project.status, 'accepted')

    #assert reject task is queued
    self.assertTasksInQueue(n=1, url=self.REJECT_URL)

    #assert parameters to task
    for task in self.get_tasks():
      if task['url'] == self.REJECT_URL:
        expected_params = {'org_key':
                           urllib.quote_plus(self.org.key().name()),
                           'program_key':
                           urllib.quote_plus(self.gsoc.key().name())}

        #ignore xsrf token
        self.assertNotEqual(task['params'].get('xsrf_token'), None)
        task_params = task['params'].copy()
        del task_params['xsrf_token']

        self.assertEqual(expected_params, task_params)


    # test reject proposals

    post_data = {'org_key': self.org.key().name(),
                 'program_key': self.gsoc.key().name()}
    response = self.post(self.REJECT_URL, post_data)
    self.assertEqual(response.status_code, httplib.OK)

    #assert post status of proposals
    self.assertEqual(self.student1_proposals[0].status, 'accepted')
    self.assertEqual(self.student1_proposals[1].status, 'rejected')
    self.assertEqual(self.student2_proposals[0].status, 'rejected')
    self.assertEqual(self.student2_proposals[1].status, 'rejected')
    self.assertEqual(self.student2_proposals[2].status, 'rejected')

    #assert student2 got a reject email
    self.assertEmailSent(to=self.student2.profile.email,
                         subject='Thank you for applying to %s'
                         % self.gsoc.name)
    #assert student2 got no accept email
    self.assertEmailNotSent(to=self.student2.profile.email,
                            subject='Congratulations!')
    #assert student1 got a reject email (already got an accept mail)
    self.assertEmailSent(to=self.student1.profile.email,
                        subject='Thank you for applying to %s'
                        % self.gsoc.name)

    #assert no projects are created for rejected student
    projects = GSoCProject.all().ancestor(self.student2.profile)
    self.assertEqual(projects.count(), 0)
Beispiel #43
0
    def sendSurveyReminderForProject(self, request, *args, **kwargs):
        """Sends a reminder mail for a given GSoCProject and Survey.

    A reminder is only send if no record is on file for the given Survey and
    GSoCProject.

    Expects the following to be present in the POST dict:
      survey_key: specifies the key name for the ProjectSurvey to send
                  reminders for
      survey_type: either project or grading depending on the type of Survey
      project_key: encoded Key which specifies the project to send a reminder
                   for

    Args:
      request: Django Request object
    """
        post_dict = request.POST

        project_key = post_dict.get('project_key')
        survey_key = post_dict.get('survey_key')
        survey_type = post_dict.get('survey_type')

        if not (project_key and survey_key and survey_type):
            # invalid task data, log and return OK
            return error_handler.logErrorAndReturnOK(
                'Invalid sendSurveyReminderForProject data: %s' % post_dict)

        # set model depending on survey type specified in POST
        if survey_type == 'project':
            survey_model = ProjectSurvey
            record_model = GSoCProjectSurveyRecord
        elif survey_type == 'grading':
            survey_model = GradingProjectSurvey
            record_model = GSoCGradingProjectSurveyRecord
        else:
            return error_handler.logErrorAndReturnOK(
                '%s is an invalid survey_type' % survey_type)

        # retrieve the project and survey
        project_key = db.Key(project_key)
        project = GSoCProject.get(project_key)
        if not project:
            # no existing project found, log and return OK
            return error_handler.logErrorAndReturnOK(
                'Invalid project specified %s:' % project_key)

        survey = survey_model.get_by_key_name(survey_key)
        if not survey:
            # no existing survey found, log and return OK
            return error_handler.logErrorAndReturnOK(
                'Invalid survey specified %s:' % survey_key)

        # try to retrieve an existing record
        q = record_model.all()
        q.filter('project', project)
        q.filter('survey', survey)
        record = q.get()

        if not record:
            # send reminder email because we found no record
            student = ndb.Key.from_old_key(project.parent_key()).get()
            site_entity = site.singleton()

            if survey_type == 'project':
                url_name = 'gsoc_take_student_evaluation'

                to_name = student.public_name
                to_address = student.contact.email
                mail_template = 'modules/gsoc/reminder/student_eval_reminder.html'
            elif survey_type == 'grading':
                url_name = 'gsoc_take_mentor_evaluation'

                mentors = ndb.get_multi(
                    map(ndb.Key.from_old_key, project.mentors))
                to_address = [mentor.contact.email for mentor in mentors]
                to_name = 'mentor(s) for project "%s"' % (project.title)
                mail_template = (
                    'modules/gsoc/reminder/mentor_eval_reminder.html')

            program = project.program
            hostname = site.getHostname()
            url_kwargs = {
                'sponsor': program_logic.getSponsorKey(program).name(),
                'program': program.link_id,
                'survey': survey.link_id,
                'user': student.profile_id,
                'id': str(project.key().id()),
            }
            url_path_and_query = reverse(url_name, kwargs=url_kwargs)
            survey_url = '%s://%s%s' % ('http', hostname, url_path_and_query)

            # set the context for the mail template
            mail_context = {
                'student_name': student.public_name,
                'project_title': project.title,
                'survey_url': survey_url,
                'survey_end': survey.survey_end,
                'to_name': to_name,
                'site_name': site_entity.site_name,
                'sender_name': "The %s Team" % site_entity.site_name,
            }

            # set the sender
            _, sender_address = mail_dispatcher.getDefaultMailSender()
            mail_context['sender'] = sender_address
            # set the receiver and subject
            mail_context['to'] = to_address
            mail_context['subject'] = ('Evaluation "%s" Reminder' %
                                       survey.title)

            # find all org admins for the project's organization
            org_key = ndb.Key.from_old_key(
                GSoCProject.org.get_value_for_datastore(project))
            org_admins = profile_logic.getOrgAdmins(org_key)

            # collect email addresses for all found org admins
            org_admin_addresses = []

            for org_admin in org_admins:
                org_admin_addresses.append(org_admin.contact.email)

            if org_admin_addresses:
                mail_context['cc'] = org_admin_addresses

            # send out the email
            mail_dispatcher.sendMailFromTemplate(mail_template, mail_context)

        # return OK
        return http.HttpResponse()
Beispiel #44
0
 def getTotalProjects(ent):
   q = GSoCProject.all()
   q.filter('program', self.data.program)
   q.filter('org', ent)
   return q.count()
Beispiel #45
0
  def spawnRemindersForProjectSurvey(self, request, *args, **kwargs):
    """Spawns tasks for each GSoCProject in the given Program.

    Expects the following to be present in the POST dict:
      program_key: Specifies the program key name for which to loop over all
                   the GSoCProject entities
      survey_key: specifies the key name for the ProjectSurvey to send
                  reminders for
      survey_type: a string which is project or grading depending on
                   the type of Survey.
      cursor: optional query cursor to indicate how far along we are.

    Args:
      request: Django Request object
    """
    post_dict = request.POST

    # retrieve the program_key and survey_key from POST data
    program_key = post_dict.get('program_key')
    survey_key = post_dict.get('survey_key')
    survey_type = post_dict.get('survey_type')

    if not (program_key and survey_key and survey_type):
      # invalid task data, log and return OK
      return error_handler.logErrorAndReturnOK(
          'Invalid spawnRemindersForProjectSurvey data: %s' % post_dict)

    program_entity = GSoCProgram.get_by_key_name(program_key)

    if not program_entity:
      # invalid program specified, log and return OK
      return error_handler.logErrorAndReturnOK(
          'Invalid program specified: %s' % program_key)

    q = GSoCProject.all()
    q.filter('status', 'accepted')
    q.filter('program', program_entity)

    if 'cursor' in post_dict:
      q.with_cursor(post_dict['cursor'])

    projects = q.fetch(self.BATCH_SIZE)

    if not projects:
      # we are done, return OK
      return http.HttpResponse()

    for project in projects:
      task_params = {
          'survey_key': survey_key,
          'survey_type': survey_type,
          'project_key': str(project.key())
          }
      task_url = '/tasks/gsoc/surveys/send_reminder/send'

      new_task = taskqueue.Task(params=task_params, url=task_url)
      new_task.add('mail')

    # pass along these params as POST to the new task
    task_params = {
        'program_key': program_key,
        'survey_key': survey_key,
        'survey_type': survey_type,
        'cursor': q.cursor()
        }
    task_url = request.path
    new_task = taskqueue.Task(params=task_params, url=task_url)
    new_task.add()

    # return OK
    return http.HttpResponse()