Esempio n. 1
0
  def testSurveyResponseTab(self):
    """Tests that survey response tab has the right URL."""
    # organization application is now
    self.org_app.survey_start = timeline_utils.past()
    self.org_app.survey_end = timeline_utils.future()
    self.org_app.put()

    data = request_data.RequestData(None, None, self.kwargs)
    tabs = soc_tabs.orgTabs(data)

    survey_response_tab = [
        tab for tab in tabs.tabs
        if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID][0]
    self.assertEqual(
        '/gsoc/org/application/submit/%s' % self.org.key.id(),
        survey_response_tab.url)

    # organization application is complete
    self.org_app.survey_start = timeline_utils.past(delta=100)
    self.org_app.survey_end = timeline_utils.past(delta=50)
    self.org_app.put()

    data = request_data.RequestData(None, None, self.kwargs)
    tabs = soc_tabs.orgTabs(data)

    survey_response_tab = [
        tab for tab in tabs.tabs
        if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID][0]
    self.assertEqual(
        '/gsoc/org/survey_response/show/%s' % self.org.key.id(),
        survey_response_tab.url)
Esempio n. 2
0
    def testSurveyResponseTab(self):
        """Tests that survey response tab has the right URL."""
        # organization application is now
        self.org_app.survey_start = timeline_utils.past()
        self.org_app.survey_end = timeline_utils.future()
        self.org_app.put()

        data = request_data.RequestData(None, None, self.kwargs)
        tabs = soc_tabs.orgTabs(data)

        survey_response_tab = [
            tab for tab in tabs.tabs
            if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID
        ][0]
        self.assertEqual('/gsoc/org/application/submit/%s' % self.org.key.id(),
                         survey_response_tab.url)

        # organization application is complete
        self.org_app.survey_start = timeline_utils.past(delta=100)
        self.org_app.survey_end = timeline_utils.past(delta=50)
        self.org_app.put()

        data = request_data.RequestData(None, None, self.kwargs)
        tabs = soc_tabs.orgTabs(data)

        survey_response_tab = [
            tab for tab in tabs.tabs
            if tab.tab_id == soc_tabs.ORG_APP_RESPONSE_TAB_ID
        ][0]
        self.assertEqual(
            '/gsoc/org/survey_response/show/%s' % self.org.key.id(),
            survey_response_tab.url)
Esempio n. 3
0
  def context(self, data, check, mutator):
    """See base.RequestHandler.context for specification."""
    form_data = data.url_ndb_org.to_dict()

    # initialize list of tags as comma separated list of values
    form_data['tags'] = ', '.join(form_data['tags'])

    if data.url_ndb_org.contact:
      form_data.update(data.url_ndb_org.contact.to_dict())

    form = _formToEditOrgProfile(request_data=data, data=data.POST or form_data)

    # add a reminder if no application has been submitted and it is still
    # before the deadline
    if (not org_logic.getApplicationResponse(data.url_ndb_org.key) and
        time_utils.isBefore(data.org_app.survey_end)):
      url = links.LINKER.organization(
          data.url_ndb_org.key, urls.UrlNames.ORG_APPLICATION_SUBMIT)
      deadline = data.org_app.survey_end
      org_application_reminder = OrgApplicationReminder(url, deadline)
    else:
      org_application_reminder = None

    return {
        'page_name': ORG_PROFILE_EDIT_PAGE_NAME,
        'forms': [form],
        'error': bool(form.errors),
        'tabs': tabs.orgTabs(data, selected_tab_id=tabs.ORG_PROFILE_TAB_ID),
        'org_application_reminder': org_application_reminder,
        }
Esempio n. 4
0
    def context(self, data, check, mutator):
        """See base.RequestHandler.context for specification."""
        form_data = data.url_ndb_org.to_dict()

        # initialize list of tags as comma separated list of values
        form_data["tags"] = ", ".join(form_data["tags"])

        if data.url_ndb_org.contact:
            form_data.update(data.url_ndb_org.contact.to_dict())

        form = _formToEditOrgProfile(request_data=data, data=data.POST or form_data)

        # add a reminder if no application has been submitted and it is still
        # before the deadline
        if not org_logic.getApplicationResponse(data.url_ndb_org.key) and time_utils.isBefore(data.org_app.survey_end):
            url = links.LINKER.organization(data.url_ndb_org.key, urls.UrlNames.ORG_APPLICATION_SUBMIT)
            deadline = data.org_app.survey_end
            org_application_reminder = OrgApplicationReminder(url, deadline)
        else:
            org_application_reminder = None

        return {
            "page_name": ORG_PROFILE_EDIT_PAGE_NAME,
            "forms": [form],
            "error": bool(form.errors),
            "tabs": tabs.orgTabs(data, selected_tab_id=tabs.ORG_PROFILE_TAB_ID),
            "org_application_reminder": org_application_reminder,
        }
Esempio n. 5
0
  def context(self, data, check, mutator):
    """See base.RequestHandler.context for specification."""
    form_data = data.url_ndb_org.to_dict()

    form = _OrgPreferencesForm(data=data.POST or form_data)
    return {
        'error': bool(form.errors),
        'forms': [form],
        'page_name': ORG_PREFERENCES_EDIT_PAGE_NAME,
        'tabs': tabs.orgTabs(data, selected_tab_id=tabs.ORG_PREFERENCES_TAB_ID)
        }
Esempio n. 6
0
    def context(self, data, check, mutator):
        """See base.RequestHandler.context for specification."""
        form_data = data.url_ndb_org.to_dict()

        form = _OrgPreferencesForm(data=data.POST or form_data)
        return {
            "error": bool(form.errors),
            "forms": [form],
            "page_name": ORG_PREFERENCES_EDIT_PAGE_NAME,
            "tabs": tabs.orgTabs(data, selected_tab_id=tabs.ORG_PREFERENCES_TAB_ID),
        }
Esempio n. 7
0
  def testPreferencesTab(self):
    """Tests that Preferences tab is present for accepted organizations only."""
    # check that tab is not present for organizations that are not accepted
    statuses = [
        org_model.Status.APPLYING, org_model.Status.PRE_ACCEPTED,
        org_model.Status.PRE_REJECTED, org_model.Status.REJECTED]
    for status in statuses:
      self.org.status = status
      self.org.put()
      data = request_data.RequestData(None, None, self.kwargs)
      tabs = soc_tabs.orgTabs(data)
      self.assertNotIn(
          soc_tabs.ORG_PREFERENCES_TAB_ID, [tab.tab_id for tab in tabs.tabs])

    # check that tab is present for an organization that is accepted
    self.org.status = org_model.Status.ACCEPTED
    self.org.put()
    data = request_data.RequestData(None, None, self.kwargs)
    tabs = soc_tabs.orgTabs(data)
    self.assertIn(
        soc_tabs.ORG_PREFERENCES_TAB_ID, [tab.tab_id for tab in tabs.tabs])
Esempio n. 8
0
    def testPreferencesTab(self):
        """Tests that Preferences tab is present for accepted organizations only."""
        # check that tab is not present for organizations that are not accepted
        statuses = [
            org_model.Status.APPLYING, org_model.Status.PRE_ACCEPTED,
            org_model.Status.PRE_REJECTED, org_model.Status.REJECTED
        ]
        for status in statuses:
            self.org.status = status
            self.org.put()
            data = request_data.RequestData(None, None, self.kwargs)
            tabs = soc_tabs.orgTabs(data)
            self.assertNotIn(soc_tabs.ORG_PREFERENCES_TAB_ID,
                             [tab.tab_id for tab in tabs.tabs])

        # check that tab is present for an organization that is accepted
        self.org.status = org_model.Status.ACCEPTED
        self.org.put()
        data = request_data.RequestData(None, None, self.kwargs)
        tabs = soc_tabs.orgTabs(data)
        self.assertIn(soc_tabs.ORG_PREFERENCES_TAB_ID,
                      [tab.tab_id for tab in tabs.tabs])
Esempio n. 9
0
    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),
        }
Esempio n. 10
0
  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)
        }