Exemple #1
0
  def checkAccess(self):
    self.check.isProfileActive()
    
    invite_id = int(self.data.kwargs['id'])
    self.data.invite = GCIRequest.get_by_id(invite_id)
    self.check.isInvitePresent(invite_id)

    # get invited user and check if it is not deleted
    self.data.invited_user = self.data.invite.user
    if not self.data.invited_user:
      logging.warning(
          'User entity does not exist for request with id %s', invite_id)
      raise NotFound('Invited user does not exist')

    # get the organization and check if the current user can manage the invite
    self.data.organization = self.data.invite.org
    self.check.isOrgAdmin()

    if self.data.POST:
      if 'withdraw' in self.data.POST:
        self.check.canInviteBeWithdrawn()
      elif 'resubmit' in self.data.POST:
        self.check.canInviteBeResubmitted()
      else:
        raise BadRequest('No action specified in manage_gci_invite request.')
    def testWithdrawInvite(self):
        self.data.createOrgAdmin(self.org)

        post_data = {"withdraw": ""}
        response = self.post(self._manageInviteUrl(self.invite), post_data)
        self.assertResponseRedirect(response, self._manageInviteUrl(self.invite))

        new_invite = GCIRequest.all().get()
        self.assertTrue(new_invite.status == "withdrawn")
Exemple #3
0
  def getListData(self):
    q = GCIRequest.all()
    q.filter('type', 'Invitation')
    q.filter('user', self.data.user)

    response_builder = lists.RawQueryContentResponseBuilder(
        self.request, self._list_config, q, lists.keyStarter)

    return response_builder.build()
    def testInviteByEmailAddress(self):
        self.data.createOrgAdmin(self.org)
        self._invitee()

        post_data = {"identifiers": "*****@*****.**"}
        response = self.post(self._inviteMentorUrl(), post_data)
        self.assertResponseRedirect(response, "/gci/dashboard/%s" % self.gci.key().name())

        invite = GCIRequest.all().get()
        self.assertPropertiesEqual(self._defaultMentorInviteProperties(), invite)
    def testInviteOrgAdmin(self):
        self.data.createOrgAdmin(self.org)

        invitee = self._invitee()

        post_data = {"identifiers": invitee.user.link_id}
        response = self.post(self._inviteOrgAdminUrl(), post_data)
        self.assertResponseRedirect(response, "/gci/dashboard/%s" % self.gci.key().name())

        invite = GCIRequest.all().get()
        self.assertPropertiesEqual(self._defaultOrgAdminInviteProperties(), invite)
  def testWithdrawInvite(self):
    self.data.createOrgAdmin(self.org)

    post_data = {
        'withdraw': ''
        }
    response = self.post(self._manageInviteUrl(self.invite), post_data)
    self.assertResponseRedirect(response, self._manageInviteUrl(self.invite))

    new_invite = GCIRequest.all().get()
    self.assertTrue(new_invite.status == 'withdrawn')
Exemple #7
0
    def getListData(self):
        if lists.getListIndex(self.request) != self.idx:
            return None

        q = GCIRequest.all()
        q.filter("type", "Request")
        q.filter("org IN", [e.key() for e in self.data.org_admin_for])

        response_builder = lists.RawQueryContentResponseBuilder(self.request, self._list_config, q, lists.keyStarter)

        return response_builder.build()
    def testInviteByEmailAndUsername(self):
        # TODO(dhans): in the perfect world, only one invite should be sent
        self.data.createOrgAdmin(self.org)
        invitee = self._invitee()

        post_data = {"identifiers": "[email protected], %s" % invitee.user.link_id}
        response = self.post(self._inviteMentorUrl(), post_data)

        self.assertResponseRedirect(response, "/gci/dashboard/%s" % self.gci.key().name())

        invite = GCIRequest.all().fetch(10)
        self.assertEqual(len(invite), 2)
    def testOrgAdminInviteAfterMentorInvite(self):
        self.data.createOrgAdmin(self.org)
        invitee = self._invitee()

        GCIInviteHelper().createMentorInvite(self.org, invitee.user)

        post_data = {"identifiers": invitee.user.link_id}
        response = self.post(self._inviteOrgAdminUrl(), post_data)
        self.assertResponseRedirect(response, "/gci/dashboard/%s" % self.gci.key().name())

        invite = GCIRequest.all().filter("role =", "org_admin").get()
        self.assertPropertiesEqual(self._defaultOrgAdminInviteProperties(), invite)
Exemple #10
0
  def checkAccess(self):
    self.check.isProfileActive()

    # fetch the request entity based on the id
    request_id = int(self.data.kwargs['id'])
    self.data.request_entity = GCIRequest.get_by_id(request_id)
    self.check.isRequestPresent(request_id)

    # get the organization and check if the current user can manage the request
    self.data.organization = self.data.request_entity.org
    self.check.isOrgAdmin()

    self.data.is_respondable = self.data.request_entity.status == 'pending'
Exemple #11
0
  def testInviteByEmailAddress(self):
    self.data.createOrgAdmin(self.org)
    self._invitee()

    post_data = {
        'identifiers': '*****@*****.**'
        }
    response = self.post(self._inviteMentorUrl(), post_data)
    self.assertResponseRedirect(response,
        '/gci/dashboard/%s' % self.gci.key().name())

    invite = GCIRequest.all().get()
    self.assertPropertiesEqual(self._defaultMentorInviteProperties(), invite)
Exemple #12
0
  def checkAccess(self):
    self.check.isProfileActive()

    request_id = int(self.data.kwargs['id'])
    self.data.request_entity = GCIRequest.get_by_id(request_id)
    self.check.isRequestPresent(request_id)

    self.check.canManageRequest()

    # check if the submitted action is legal
    if self.data.POST:
      if 'withdraw' not in self.data.POST and 'resubmit' not in self.data.POST:
        raise BadRequest('Valid action is not specified in the request.')
      self.check.isRequestManageable()
Exemple #13
0
  def testInviteOrgAdmin(self):
    self.data.createOrgAdmin(self.org)

    invitee = self._invitee()
    
    post_data = {
        'identifiers': invitee.user.link_id,
        }
    response = self.post(self._inviteOrgAdminUrl(), post_data)
    self.assertResponseRedirect(response,
        '/gci/dashboard/%s' % self.gci.key().name())

    invite = GCIRequest.all().get()
    self.assertPropertiesEqual(self._defaultOrgAdminInviteProperties(), invite)
Exemple #14
0
  def testOrgAdminInviteAfterMentorInvite(self):
    self.data.createOrgAdmin(self.org)
    invitee = self._invitee()

    GCIInviteHelper().createMentorInvite(self.org, invitee.user)

    post_data = {
        'identifiers': invitee.user.link_id,
        }
    response = self.post(self._inviteOrgAdminUrl(), post_data)
    self.assertResponseRedirect(response,
        '/gci/dashboard/%s' % self.gci.key().name())

    invite = GCIRequest.all().filter('role =', 'org_admin').get()
    self.assertPropertiesEqual(self._defaultOrgAdminInviteProperties(), invite)
Exemple #15
0
    def testMentorInviteAfterOrgAdminInvite(self):
        # TODO(dhans): this test should fail in the future:
        # a existing mentor invite should be extended to become org_admin one

        self.data.createOrgAdmin(self.org)
        invitee = self._invitee()

        GCIInviteHelper().createOrgAdminInvite(self.org, invitee.user)

        post_data = {"identifiers": invitee.user.link_id}
        response = self.post(self._inviteMentorUrl(), post_data)
        self.assertResponseRedirect(response, "/gci/dashboard/%s" % self.gci.key().name())

        invite = GCIRequest.all().filter("role =", "mentor").get()
        self.assertPropertiesEqual(self._defaultMentorInviteProperties(), invite)
Exemple #16
0
  def checkAccess(self):
    self.check.isUser()

    invite_id = int(self.data.kwargs['id'])
    self.data.invite = GCIRequest.get_by_id(invite_id)
    self.check.isInvitePresent(invite_id)

    self.check.canRespondInvite()
    self.data.is_respondable = self.data.invite.status == 'pending'

    # actual response may be sent only to pending requests
    if self.data.POST:
      if 'accept' not in self.data.POST and 'reject' not in self.data.POST:
        raise BadRequest('Valid action is not specified in the request.')
      self.check.isInviteRespondable()
Exemple #17
0
  def testInviteByEmailAndUsername(self):
    # TODO(dhans): in the perfect world, only one invite should be sent
    self.data.createOrgAdmin(self.org)
    invitee = self._invitee()

    post_data = {
        'identifiers': '[email protected], %s' % invitee.user.link_id
        }
    response = self.post(self._inviteMentorUrl(), post_data)

    self.assertResponseRedirect(response,
        '/gci/dashboard/%s' % self.gci.key().name())

    invite = GCIRequest.all().fetch(10)
    self.assertEqual(len(invite), 2)
Exemple #18
0
  def testMentorInviteAfterOrgAdminInvite(self):
    # TODO(dhans): this test should fail in the future:
    # a existing mentor invite should be extended to become org_admin one

    self.data.createOrgAdmin(self.org)
    invitee = self._invitee()

    GCIInviteHelper().createOrgAdminInvite(self.org, invitee.user)

    post_data = {
        'identifiers': invitee.user.link_id,
        }
    response = self.post(self._inviteMentorUrl(), post_data)
    self.assertResponseRedirect(response,
        '/gci/dashboard/%s' % self.gci.key().name())

    invite = GCIRequest.all().filter('role =', 'mentor').get()
    self.assertPropertiesEqual(self._defaultMentorInviteProperties(), invite)