예제 #1
0
    def testRequestMentor(self):
        admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        admin.createOtherUser('*****@*****.**')
        admin.createOrgAdmin(self.org)
        admin.notificationSettings(new_requests=True)

        other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_admin.createOtherUser('*****@*****.**')
        other_admin.createOrgAdmin(self.org)
        other_admin.notificationSettings()

        # test GET
        self.data.createProfile()
        url = '/gsoc/request/' + self.org.key().name()
        response = self.get(url)
        self.assertRequestTemplatesUsed(response)

        # test POST
        override = {
            'status': 'pending',
            'role': 'mentor',
            'type': 'Request',
            'user': self.data.user,
            'org': self.org
        }
        response, properties = self.modelPost(url, GSoCRequest, override)

        request = GSoCRequest.all().get()
        self.assertPropertiesEqual(properties, request)

        self.assertEmailSent(to=admin.profile.email, n=1)
        self.assertEmailNotSent(to=other_admin.profile.email)

        # test withdrawing a request
        url = '/gsoc/request/%s/%s/%s' % (self.gsoc.key().name(),
                                          request.parent_key().name(),
                                          request.key().id())

        postdata = {'action': 'Withdraw'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual('withdrawn', request.status)

        # test that you can resubmit
        postdata = {'action': 'Resubmit'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual('pending', request.status)
예제 #2
0
파일: request.py 프로젝트: adviti/melange
    def checkAccess(self):
        self.check.isProfileActive()

        request_id = int(self.data.kwargs["id"])
        self.data.invite = self.data.request_entity = GSoCRequest.get_by_id(request_id)
        self.check.isRequestPresent(request_id)

        self.data.organization = self.data.request_entity.org
        self.data.invited_user = self.data.requester = self.data.request_entity.user

        if self.data.POST:
            self.data.action = self.data.POST["action"]

            if self.data.action == self.ACTIONS["accept"]:
                self.check.canRespondToRequest()
            elif self.data.action == self.ACTIONS["reject"]:
                self.check.canRespondToRequest()
            elif self.data.action == self.ACTIONS["resubmit"]:
                self.check.canResubmitRequest()
            # withdraw action
        else:
            self.check.canViewRequest()

        self.mutator.canRespondForUser()

        key_name = "/".join([self.data.program.key().name(), self.data.requester.link_id])
        self.data.requester_profile = GSoCProfile.get_by_key_name(key_name, parent=self.data.requester)
예제 #3
0
  def testRequestMentor(self):
    admin = GSoCProfileHelper(self.gsoc, self.dev_test)
    admin.createOtherUser('*****@*****.**')
    admin.createOrgAdmin(self.org)
    admin.notificationSettings(new_requests=True)

    other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_admin.createOtherUser('*****@*****.**')
    other_admin.createOrgAdmin(self.org)
    other_admin.notificationSettings()

    # test GET
    self.data.createProfile()
    url = '/gsoc/request/' + self.org.key().name()
    response = self.get(url)
    self.assertRequestTemplatesUsed(response)

    # test POST
    override = {'status': 'pending', 'role': 'mentor', 'type': 'Request',
                'user': self.data.user, 'org': self.org}
    response, properties = self.modelPost(url, GSoCRequest, override)

    request = GSoCRequest.all().get()
    self.assertPropertiesEqual(properties, request)

    self.assertEmailSent(to=admin.profile.email, n=1)
    self.assertEmailNotSent(to=other_admin.profile.email)

    # test withdrawing a request
    url = '/gsoc/request/%s/%s/%s' % (
        self.gsoc.key().name(),
        request.parent_key().name(),
        request.key().id())

    postdata = {'action': 'Withdraw'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    request = GSoCRequest.all().get()
    self.assertEqual('withdrawn', request.status)

    # test that you can resubmit
    postdata = {'action': 'Resubmit'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    request = GSoCRequest.all().get()
    self.assertEqual('pending', request.status)
예제 #4
0
    def testRequestMentor(self):
        admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        admin.createOtherUser("*****@*****.**")
        admin.createOrgAdmin(self.org)
        admin.notificationSettings(new_requests=True)

        other_admin = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_admin.createOtherUser("*****@*****.**")
        other_admin.createOrgAdmin(self.org)
        other_admin.notificationSettings()

        # test GET
        self.data.createProfile()
        url = "/gsoc/request/" + self.org.key().name()
        response = self.get(url)
        self.assertRequestTemplatesUsed(response)

        # test POST
        override = {"status": "pending", "role": "mentor", "type": "Request", "user": self.data.user, "org": self.org}
        response, properties = self.modelPost(url, GSoCRequest, override)

        request = GSoCRequest.all().get()
        self.assertPropertiesEqual(properties, request)

        self.assertEmailSent(to=admin.profile.email, n=1)
        self.assertEmailNotSent(to=other_admin.profile.email)

        # test withdrawing a request
        url = "/gsoc/request/%s/%s" % (self.gsoc.key().name(), request.key().id())

        postdata = {"action": "Withdraw"}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual("withdrawn", request.status)

        # test that you can resubmit
        postdata = {"action": "Resubmit"}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual("pending", request.status)
예제 #5
0
    def checkPostAccept():
      self.assertResponseRedirect(response)
      request = GSoCRequest.all().get()
      self.assertEqual('accepted', request.status)

      profile = db.get(other_data.profile.key())
      self.assertEqual(1, profile.mentor_for.count(self.org.key()))
      self.assertTrue(profile.is_mentor)
      self.assertFalse(profile.is_student)
      self.assertFalse(profile.is_org_admin)
      self.assertFalse(profile.org_admin_for)
예제 #6
0
        def checkPostAccept():
            self.assertResponseRedirect(response)
            request = GSoCRequest.all().get()
            self.assertEqual('accepted', request.status)

            profile = db.get(other_data.profile.key())
            self.assertEqual(1, profile.mentor_for.count(self.org.key()))
            self.assertTrue(profile.is_mentor)
            self.assertFalse(profile.is_student)
            self.assertFalse(profile.is_org_admin)
            self.assertFalse(profile.org_admin_for)
예제 #7
0
  def testAcceptRequest(self):
    self.data.createOrgAdmin(self.org)
    other_data, request = self.createRequest()
    other_data.notificationSettings(request_handled=True)
    url = '/gsoc/request/%s/%s/%s' % (
        self.gsoc.key().name(),
        request.parent_key().name(),
        request.key().id())
    response = self.get(url)
    self.assertGSoCTemplatesUsed(response)
    self.assertTemplateUsed(response, 'v2/soc/request/base.html')

    postdata = {'action': 'Reject'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    request = GSoCRequest.all().get()
    self.assertEqual('rejected', request.status)

    self.assertEmailSent(to=other_data.profile.email, n=1)

    # test that you can change after the fact
    postdata = {'action': 'Accept'}
    response = self.post(url, postdata)

    def checkPostAccept():
      self.assertResponseRedirect(response)
      request = GSoCRequest.all().get()
      self.assertEqual('accepted', request.status)

      profile = db.get(other_data.profile.key())
      self.assertEqual(1, profile.mentor_for.count(self.org.key()))
      self.assertTrue(profile.is_mentor)
      self.assertFalse(profile.is_student)
      self.assertFalse(profile.is_org_admin)
      self.assertFalse(profile.org_admin_for)

    checkPostAccept()

    self.assertEmailSent(to=other_data.profile.email, n=2)

    request.status = 'pending'
    request.put()
    other_data.notificationSettings()

    response = self.post(url, postdata)

    checkPostAccept()
    self.assertEmailSent(to=other_data.profile.email, n=2)
예제 #8
0
    def testAcceptRequest(self):
        self.data.createOrgAdmin(self.org)
        other_data, request = self.createRequest()
        other_data.notificationSettings(request_handled=True)
        url = '/gsoc/request/%s/%s/%s' % (self.gsoc.key().name(),
                                          request.parent_key().name(),
                                          request.key().id())
        response = self.get(url)
        self.assertGSoCTemplatesUsed(response)
        self.assertTemplateUsed(response, 'v2/soc/request/base.html')

        postdata = {'action': 'Reject'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        request = GSoCRequest.all().get()
        self.assertEqual('rejected', request.status)

        self.assertEmailSent(to=other_data.profile.email, n=1)

        # test that you can change after the fact
        postdata = {'action': 'Accept'}
        response = self.post(url, postdata)

        def checkPostAccept():
            self.assertResponseRedirect(response)
            request = GSoCRequest.all().get()
            self.assertEqual('accepted', request.status)

            profile = db.get(other_data.profile.key())
            self.assertEqual(1, profile.mentor_for.count(self.org.key()))
            self.assertTrue(profile.is_mentor)
            self.assertFalse(profile.is_student)
            self.assertFalse(profile.is_org_admin)
            self.assertFalse(profile.org_admin_for)

        checkPostAccept()

        self.assertEmailSent(to=other_data.profile.email, n=2)

        request.status = 'pending'
        request.put()
        other_data.notificationSettings()

        response = self.post(url, postdata)

        checkPostAccept()
        self.assertEmailSent(to=other_data.profile.email, n=2)
예제 #9
0
  def testViewInvite(self):
    self.data.createProfile()
    invitation = self.createInvitation()
    url = '/gsoc/invitation/%s/%s/%s' % (
	self.gsoc.key().name(),
	invitation.parent_key().name(),
	invitation.key().id())
    response = self.get(url)
    self.assertGSoCTemplatesUsed(response)
    self.assertTemplateUsed(response, 'v2/soc/request/base.html')

    postdata = {'action': 'Reject'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invitation = GSoCRequest.all().get()
    self.assertEqual('rejected', invitation.status)

    # test that you can change after the fact
    postdata = {'action': 'Accept'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)

    profile = db.get(self.data.profile.key())
    self.assertEqual(1, profile.mentor_for.count(self.org.key()))
    self.assertTrue(profile.is_mentor)
    self.assertFalse(profile.is_student)
    self.assertFalse(profile.is_org_admin)
    self.assertFalse(profile.org_admin_for)

    # test admin invite
    invitation.status = 'pending'
    invitation.role = 'org_admin'
    invitation.put()

    response = self.post(url, postdata)
    self.assertResponseRedirect(response)

    profile = db.get(self.data.profile.key())
    self.assertEqual(1, profile.mentor_for.count(self.org.key()))
    self.assertEqual(1, profile.org_admin_for.count(self.org.key()))
    self.assertFalse(profile.is_student)
    self.assertTrue(profile.is_mentor)
    self.assertTrue(profile.is_org_admin)
예제 #10
0
    def testViewInvite(self):
        self.data.createProfile()
        invitation = self.createInvitation()
        url = '/gsoc/invitation/%s/%s/%s' % (self.gsoc.key().name(),
                                             invitation.parent_key().name(),
                                             invitation.key().id())
        response = self.get(url)
        self.assertGSoCTemplatesUsed(response)
        self.assertTemplateUsed(response, 'v2/soc/request/base.html')

        postdata = {'action': 'Reject'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        invitation = GSoCRequest.all().get()
        self.assertEqual('rejected', invitation.status)

        # test that you can change after the fact
        postdata = {'action': 'Accept'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)

        profile = db.get(self.data.profile.key())
        self.assertEqual(1, profile.mentor_for.count(self.org.key()))
        self.assertTrue(profile.is_mentor)
        self.assertFalse(profile.is_student)
        self.assertFalse(profile.is_org_admin)
        self.assertFalse(profile.org_admin_for)

        # test admin invite
        invitation.status = 'pending'
        invitation.role = 'org_admin'
        invitation.put()

        response = self.post(url, postdata)
        self.assertResponseRedirect(response)

        profile = db.get(self.data.profile.key())
        self.assertEqual(1, profile.mentor_for.count(self.org.key()))
        self.assertEqual(1, profile.org_admin_for.count(self.org.key()))
        self.assertFalse(profile.is_student)
        self.assertTrue(profile.is_mentor)
        self.assertTrue(profile.is_org_admin)
예제 #11
0
  def testInviteOrgAdmin(self):
    # test GET
    self.data.createOrgAdmin(self.org)
    url = '/gsoc/invite/org_admin/' + self.org.key().name()
    response = self.get(url)
    self.assertInviteTemplatesUsed(response)

    # create other user to send invite to
    other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data.createOtherUser('*****@*****.**')
    other_data.createProfile()
    other_data.notificationSettings(new_invites=True)
    other_user = other_data.user

    # test POST
    override = {
        'link_id': other_user.link_id, 'status': 'pending',
        'role': 'org_admin', 'user': other_user, 'org': self.org,
        'type': 'Invitation',
        'parent': other_user,
    }
    response, properties = self.modelPost(url, GSoCRequest, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

    invitation = GSoCRequest.all().get()
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)

    other_data2 = GSoCProfileHelper(self.gsoc, self.dev_test)
    other_data2.createOtherUser('*****@*****.**')
    other_data2.createProfile()
    other_data2.notificationSettings()

    invitation.delete()
    override['link_id'] = '[email protected], [email protected]'
    other_data.notificationSettings()
    response, properties = self.modelPost(url, GSoCRequest, override)
    self.assertEmailSent(to=other_data.profile.email, n=1)

    invitations = GSoCRequest.all().fetch(2)
    self.assertEqual(2, len(invitations))
    invitation = invitations[0]
    properties.pop('link_id')
    self.assertPropertiesEqual(properties, invitation)
    properties['user'] = other_data2.user
    properties['parent'] = other_data2.user
    self.assertPropertiesEqual(properties, invitations[1])

    # test withdraw/resubmit invite
    url = '/gsoc/invitation/%s/%s/%s' % (
	self.gsoc.key().name(),
	invitation.parent_key().name(),
	invitation.key().id())

    other_data.notificationSettings(invite_handled=True)

    postdata = {'action': 'Withdraw'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invite = GSoCRequest.all().get()
    self.assertEqual('withdrawn', invite.status)
    self.assertEmailSent(to=other_data.profile.email, n=2)

    # test that you can resubmit
    postdata = {'action': 'Resubmit'}
    response = self.post(url, postdata)
    self.assertResponseRedirect(response)
    invite = GSoCRequest.all().get()
    self.assertEqual('pending', invite.status)
    self.assertEmailSent(to=other_data.profile.email, n=3)
예제 #12
0
    def testInviteOrgAdmin(self):
        # test GET
        self.data.createOrgAdmin(self.org)
        url = '/gsoc/invite/org_admin/' + self.org.key().name()
        response = self.get(url)
        self.assertInviteTemplatesUsed(response)

        # create other user to send invite to
        other_data = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data.createOtherUser('*****@*****.**')
        other_data.createProfile()
        other_data.notificationSettings(new_invites=True)
        other_user = other_data.user

        # test POST
        override = {
            'link_id': other_user.link_id,
            'status': 'pending',
            'role': 'org_admin',
            'user': other_user,
            'org': self.org,
            'type': 'Invitation',
            'parent': other_user,
        }
        response, properties = self.modelPost(url, GSoCRequest, override)
        self.assertEmailSent(to=other_data.profile.email, n=1)

        invitation = GSoCRequest.all().get()
        properties.pop('link_id')
        self.assertPropertiesEqual(properties, invitation)

        other_data2 = GSoCProfileHelper(self.gsoc, self.dev_test)
        other_data2.createOtherUser('*****@*****.**')
        other_data2.createProfile()
        other_data2.notificationSettings()

        invitation.delete()
        override[
            'link_id'] = '[email protected], [email protected]'
        other_data.notificationSettings()
        response, properties = self.modelPost(url, GSoCRequest, override)
        self.assertEmailSent(to=other_data.profile.email, n=1)

        invitations = GSoCRequest.all().fetch(2)
        self.assertEqual(2, len(invitations))
        invitation = invitations[0]
        properties.pop('link_id')
        self.assertPropertiesEqual(properties, invitation)
        properties['user'] = other_data2.user
        properties['parent'] = other_data2.user
        self.assertPropertiesEqual(properties, invitations[1])

        # test withdraw/resubmit invite
        url = '/gsoc/invitation/%s/%s/%s' % (self.gsoc.key().name(),
                                             invitation.parent_key().name(),
                                             invitation.key().id())

        other_data.notificationSettings(invite_handled=True)

        postdata = {'action': 'Withdraw'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        invite = GSoCRequest.all().get()
        self.assertEqual('withdrawn', invite.status)
        self.assertEmailSent(to=other_data.profile.email, n=2)

        # test that you can resubmit
        postdata = {'action': 'Resubmit'}
        response = self.post(url, postdata)
        self.assertResponseRedirect(response)
        invite = GSoCRequest.all().get()
        self.assertEqual('pending', invite.status)
        self.assertEmailSent(to=other_data.profile.email, n=3)