Beispiel #1
0
    def testAccessGrantedForValidStatus(self):
        """Tests that access is denied if the organization has an invalid status."""
        self.org.status = ndb_org_model.Status.ACCEPTED
        self.org.put()

        # the access checkers passes only for non-rejected organizations
        access_checker = access.UrlOrgStatusAccessChecker([
            ndb_org_model.Status.ACCEPTED, ndb_org_model.Status.PRE_ACCEPTED,
            ndb_org_model.Status.PRE_REJECTED
        ])
        access_checker.checkAccess(self.data, None)
Beispiel #2
0
    def testAccessDeniedForInvalidStatus(self):
        """Tests that access is denied if the organization has an invalid status."""
        self.org.status = ndb_org_model.Status.REJECTED
        self.org.put()

        # the access checkers passes only for non-rejected organizations
        access_checker = access.UrlOrgStatusAccessChecker([
            ndb_org_model.Status.ACCEPTED, ndb_org_model.Status.PRE_ACCEPTED,
            ndb_org_model.Status.PRE_REJECTED
        ])
        with self.assertRaises(exception.UserError) as context:
            access_checker.checkAccess(self.data, None)
        self.assertEqual(context.exception.status, httplib.FORBIDDEN)
Beispiel #3
0
class OrgApplicationSubmitPage(base.GSoCRequestHandler):
  """View to submit application to a program by organization representatives."""

  access_checker = access.ConjuctionAccessChecker([
      access.IS_USER_ORG_ADMIN_FOR_NDB_ORG,
      access.UrlOrgStatusAccessChecker(
          [org_model.Status.APPLYING, org_model.Status.PRE_ACCEPTED,
          org_model.Status.PRE_REJECTED])])

  def djangoURLPatterns(self):
    """See base.RequestHandler.djangoURLPatterns for specification."""
    return [
        soc_url_patterns.url(
            r'org/application/submit/%s$' % url_patterns.ORG,
            self, name=urls.UrlNames.ORG_APPLICATION_SUBMIT)]

  def templatePath(self):
    """See base.RequestHandler.templatePath for specification."""
    return 'modules/gsoc/org_app/take.html'

  def context(self, data, check, mutator):
    """See base.RequestHandler.context for specification."""
    application = org_logic.getApplicationResponse(data.url_ndb_org.key)
    form_data = application.to_dict() if application else None

    form = gsoc_forms.SurveyTakeForm(
        survey=data.org_app, data=data.POST or form_data)

    return {
        'page_name': ORG_APPLICATION_SUBMIT_PAGE_NAME,
        'forms': [form],
        'error': bool(form.errors),
        'tabs': tabs.orgTabs(data, selected_tab_id=tabs.ORG_APP_RESPONSE_TAB_ID)
        }

  def post(self, data, check, mutator):
    """See base.RequestHandler.post for specification."""
    form = gsoc_forms.SurveyTakeForm(survey=data.org_app, data=data.POST)
    if not form.is_valid():
      # TODO(nathaniel): problematic self-use.
      return self.get(data, check, mutator)
    else:
      properties = form.getSurveyResponseProperties()
      setApplicationResponse(
          data.url_ndb_org.key, data.org_app.key(), properties)

      url = links.LINKER.organization(
          data.url_ndb_org.key, urls.UrlNames.ORG_APPLICATION_SUBMIT)
      return http.HttpResponseRedirect(url)
Beispiel #4
0
      if not result:
        raise exception.BadRequest(message=result.extra)
      else:
        org_properties = form.getOrgProperties()
        org_properties['contact'] = result.extra

        updateOrganizationTxn(data.url_ndb_org.key, org_properties)

        url = links.LINKER.organization(
            data.url_ndb_org.key, urls.UrlNames.ORG_PROFILE_EDIT)
        return http.HttpResponseRedirect(url)


ORG_PREFERENCES_EDIT_PAGE_ACCESS_CHECKER = access.ConjuctionAccessChecker([
    access.IS_USER_ORG_ADMIN_FOR_NDB_ORG,
    access.UrlOrgStatusAccessChecker([org_model.Status.ACCEPTED])])

class OrgPreferencesEditPage(base.GSoCRequestHandler):
  """View to edit organization preferences."""

  access_checker = ORG_PREFERENCES_EDIT_PAGE_ACCESS_CHECKER

  def templatePath(self):
    """See base.RequestHandler.templatePath for specification."""
    return 'modules/gsoc/org_profile/base.html'

  def djangoURLPatterns(self):
    """See base.RequestHandler.djangoURLPatterns for specification."""
    return [
        soc_url_patterns.url(
            r'org/preferences/edit/%s$' % url_patterns.ORG,