示例#1
0
def add_integrations_context(context: Dict[str, Any]) -> None:
    alphabetical_sorted_categories = OrderedDict(sorted(CATEGORIES.items()))
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    enabled_integrations_count = len(list(filter(lambda v: v.is_enabled(), INTEGRATIONS.values())))
    # Subtract 1 so saying "Over X integrations" is correct. Then,
    # round down to the nearest multiple of 10.
    integrations_count_display = ((enabled_integrations_count - 1) // 10) * 10
    context['categories_dict'] = alphabetical_sorted_categories
    context['integrations_dict'] = alphabetical_sorted_integration
    context['integrations_count_display'] = integrations_count_display
示例#2
0
def add_integrations_context(context: Dict[str, Any]) -> None:
    alphabetical_sorted_categories = OrderedDict(sorted(CATEGORIES.items()))
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    enabled_integrations_count = len(list(filter(lambda v: v.is_enabled(), INTEGRATIONS.values())))
    # Subtract 1 so saying "Over X integrations" is correct. Then,
    # round down to the nearest multiple of 10.
    integrations_count_display = ((enabled_integrations_count - 1) // 10) * 10
    context['categories_dict'] = alphabetical_sorted_categories
    context['integrations_dict'] = alphabetical_sorted_integration
    context['integrations_count_display'] = integrations_count_display

    if "html_settings_links" in context and context["html_settings_links"]:
        settings_html = '<a href="../../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../../#streams">streams page</a>'
    else:
        settings_html = 'Zulip settings page'
        subscriptions_html = 'streams page'

    context['settings_html'] = settings_html
    context['subscriptions_html'] = subscriptions_html
示例#3
0
    def test_integration_doc_endpoints(self) -> None:
        self._test('/integrations/',
                   'native integrations.',
                   extra_strings=[
                       'And hundreds more through',
                       'Hubot',
                       'Zapier',
                       'IFTTT'
                   ])

        for integration in INTEGRATIONS.keys():
            url = '/integrations/doc-html/{}'.format(integration)
            self._test(url, '', doc_html_str=True)
示例#4
0
    def get_context_data(self, **kwargs):
        # type: (Optional[Dict[str, Any]]) -> Dict[str, Any]
        context = super(IntegrationView, self).get_context_data(**kwargs)  # type: Dict[str, Any]
        alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
        context['integrations_dict'] = alphabetical_sorted_integration

        settings_html = '<a href="../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../#subscriptions">subscriptions page</a>'

        context['settings_html'] = settings_html
        context['subscriptions_html'] = subscriptions_html

        return context
示例#5
0
def add_integrations_context(context: Dict[str, Any]) -> None:
    alphabetical_sorted_categories = OrderedDict(sorted(CATEGORIES.items()))
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    context['categories_dict'] = alphabetical_sorted_categories
    context['integrations_dict'] = alphabetical_sorted_integration

    if "html_settings_links" in context and context["html_settings_links"]:
        settings_html = '<a href="../../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../../#streams">streams page</a>'
    else:
        settings_html = 'Zulip settings page'
        subscriptions_html = 'streams page'

    context['settings_html'] = settings_html
    context['subscriptions_html'] = subscriptions_html
示例#6
0
def add_integrations_context(context):
    # type: (Dict[str, Any]) -> None
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    alphabetical_sorted_hubot_lozenges = OrderedDict(sorted(HUBOT_LOZENGES.items()))
    context['integrations_dict'] = alphabetical_sorted_integration
    context['hubot_lozenges_dict'] = alphabetical_sorted_hubot_lozenges

    if context["html_settings_links"]:
        settings_html = '<a href="../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../#streams">streams page</a>'
    else:
        settings_html = 'Zulip settings page'
        subscriptions_html = 'streams page'

    context['settings_html'] = settings_html
    context['subscriptions_html'] = subscriptions_html
示例#7
0
    def get_context_data(self, **kwargs):
        context = super(IntegrationView, self).get_context_data(**kwargs)
        alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
        context['integrations_dict'] = alphabetical_sorted_integration

        settings_html = '<a href="../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../#subscriptions">subscriptions page</a>'

        external_api_path_subdomain = settings.EXTERNAL_API_PATH
        external_api_uri_subdomain = settings.EXTERNAL_API_URI

        context['settings_html'] = settings_html
        context['subscriptions_html'] = subscriptions_html
        context['external_api_path_subdomain'] = external_api_path_subdomain
        context['external_api_uri_subdomain'] = external_api_uri_subdomain

        return context
示例#8
0
    def test_doc_html_str_non_ajax_call(self) -> None:
        # We don't need to test all the pages for 404
        for integration in list(INTEGRATIONS.keys())[5]:
            with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
                url = '/en/integrations/doc-html/{}'.format(integration)
                result = self.client_get(url, subdomain="", follow=True)
                self.assertEqual(result.status_code, 404)
                result = self.client_get(url, subdomain="zephyr", follow=True)
                self.assertEqual(result.status_code, 404)

            url = '/en/integrations/doc-html/{}'.format(integration)
            result = self.client_get(url, subdomain="", follow=True)
            self.assertEqual(result.status_code, 404)
            result = self.client_get(url, subdomain="zephyr", follow=True)
            self.assertEqual(result.status_code, 404)

        result = self.client_get('/integrations/doc-html/nonexistent_integration', follow=True)
        self.assertEqual(result.status_code, 404)
示例#9
0
    def test_doc_html_str_non_ajax_call(self) -> None:
        # We don't need to test all the pages for 404
        for integration in list(INTEGRATIONS.keys())[5]:
            with self.settings(ROOT_DOMAIN_LANDING_PAGE=True):
                url = '/en/integrations/doc-html/{}'.format(integration)
                result = self.client_get(url, subdomain="", follow=True)
                self.assertEqual(result.status_code, 404)
                result = self.client_get(url, subdomain="zephyr", follow=True)
                self.assertEqual(result.status_code, 404)

            url = '/en/integrations/doc-html/{}'.format(integration)
            result = self.client_get(url, subdomain="", follow=True)
            self.assertEqual(result.status_code, 404)
            result = self.client_get(url, subdomain="zephyr", follow=True)
            self.assertEqual(result.status_code, 404)

        result = self.client_get(
            '/integrations/doc-html/nonexistent_integration', follow=True)
        self.assertEqual(result.status_code, 404)
示例#10
0
def add_integrations_context(context):
    # type: (Dict[str, Any]) -> None
    alphabetical_sorted_categories = OrderedDict(sorted(CATEGORIES.items()))
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    context['categories_dict'] = alphabetical_sorted_categories
    context['integrations_dict'] = alphabetical_sorted_integration

    if "html_settings_links" in context and context["html_settings_links"]:
        settings_html = '<a href="../../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../../#streams">streams page</a>'
    else:
        settings_html = 'Zulip settings page'
        subscriptions_html = 'streams page'

    context['settings_html'] = settings_html
    context['subscriptions_html'] = subscriptions_html

    for name in alphabetical_sorted_integration:
        alphabetical_sorted_integration[name].add_doc_context(context)
示例#11
0
    def get_context_data(self, **kwargs):
        # type: (Optional[Dict[str, Any]]) -> Dict[str, Any]
        context = super(IntegrationView, self).get_context_data(**kwargs)  # type: Dict[str, Any]
        alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
        alphabetical_sorted_hubot_lozenges = OrderedDict(sorted(HUBOT_LOZENGES.items()))
        context['integrations_dict'] = alphabetical_sorted_integration
        context['hubot_lozenges_dict'] = alphabetical_sorted_hubot_lozenges

        if context["html_settings_links"]:
            settings_html = '<a href="../#settings">Zulip settings page</a>'
            subscriptions_html = '<a target="_blank" href="../#subscriptions">subscriptions page</a>'
        else:
            settings_html = 'Zulip settings page'
            subscriptions_html = 'subscriptions page'

        context['settings_html'] = settings_html
        context['subscriptions_html'] = subscriptions_html

        return context
示例#12
0
    def get_context_data(self, **kwargs):
        # type: (Optional[Dict[str, Any]]) -> Dict[str, Any]
        context = super(
            IntegrationView,
            self).get_context_data(**kwargs)  # type: Dict[str, Any]
        alphabetical_sorted_integration = OrderedDict(
            sorted(INTEGRATIONS.items()))
        alphabetical_sorted_hubot_lozenges = OrderedDict(
            sorted(HUBOT_LOZENGES.items()))
        context['integrations_dict'] = alphabetical_sorted_integration
        context['hubot_lozenges_dict'] = alphabetical_sorted_hubot_lozenges

        if context["html_settings_links"]:
            settings_html = '<a href="../#settings">Zulip settings page</a>'
            subscriptions_html = '<a target="_blank" href="../#subscriptions">subscriptions page</a>'
        else:
            settings_html = 'Zulip settings page'
            subscriptions_html = 'subscriptions page'

        context['settings_html'] = settings_html
        context['subscriptions_html'] = subscriptions_html

        return context
示例#13
0
def add_integrations_context(context):
    # type: (Dict[str, Any]) -> None
    alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
    alphabetical_sorted_hubot_lozenges = OrderedDict(
        sorted(HUBOT_LOZENGES.items()))
    context['integrations_dict'] = alphabetical_sorted_integration
    context['hubot_lozenges_dict'] = alphabetical_sorted_hubot_lozenges

    if context["html_settings_links"]:
        settings_html = '<a href="../#settings">Zulip settings page</a>'
        subscriptions_html = '<a target="_blank" href="../#streams">streams page</a>'
    else:
        settings_html = 'Zulip settings page'
        subscriptions_html = 'streams page'

    context['settings_html'] = settings_html
    context['subscriptions_html'] = subscriptions_html

    for name in alphabetical_sorted_integration:
        alphabetical_sorted_integration[name].add_doc_context(context)

    for name in alphabetical_sorted_hubot_lozenges:
        alphabetical_sorted_hubot_lozenges[name].add_doc_context(context)
示例#14
0
 def test_check_if_every_integration_has_logo_that_exists(self) -> None:
     for integration in INTEGRATIONS.values():
         self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
示例#15
0
 def get_context_data(self, **kwargs):
     context = super(IntegrationView, self).get_context_data(**kwargs)
     alphabetical_sorted_integration = OrderedDict(
         sorted(INTEGRATIONS.items()))
     context['integrations_dict'] = alphabetical_sorted_integration
     return context
示例#16
0
 def test_check_if_every_integration_has_logo_that_exists(self) -> None:
     for integration in INTEGRATIONS.values():
         self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
示例#17
0
 def test_check_if_every_integration_has_logo_that_exists(self) -> None:
     for integration in INTEGRATIONS.values():
         self.assertTrue(
             os.path.isfile(settings.DEPLOY_ROOT + integration.logo_url),
             integration.name)
示例#18
0
 def get_context_data(self, **kwargs):
     context = super(IntegrationView, self).get_context_data(**kwargs)
     alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
     context['integrations_dict'] = alphabetical_sorted_integration
     return context