integrations: Pass context to integration objects.

This commit is contained in:
Umair Khan 2017-04-05 10:21:42 +05:00 committed by Tim Abbott
parent 7ff699cd67
commit 21f5c5cbf4
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from typing import Dict, List, Optional, TypeVar
import os.path import os.path
from typing import Dict, List, Optional, TypeVar, Any
from django.conf import settings from django.conf import settings
from django.conf.urls import url from django.conf.urls import url
from django.core.urlresolvers import LocaleRegexProvider from django.core.urlresolvers import LocaleRegexProvider
@ -32,6 +33,7 @@ class Integration(object):
self.client_name = client_name self.client_name = client_name
self.secondary_line_text = secondary_line_text self.secondary_line_text = secondary_line_text
self.doc = doc self.doc = doc
self.doc_context = None # type: Dict[Any, Any]
if logo is None: if logo is None:
if os.path.isfile(self.DEFAULT_LOGO_STATIC_PATH_SVG.format(name=name)): if os.path.isfile(self.DEFAULT_LOGO_STATIC_PATH_SVG.format(name=name)):
@ -48,6 +50,10 @@ class Integration(object):
# type: () -> bool # type: () -> bool
return True return True
def add_doc_context(self, context):
# type: (Dict[Any, Any]) -> None
self.doc_context = context
class EmailIntegration(Integration): class EmailIntegration(Integration):
def is_enabled(self): def is_enabled(self):
# type: () -> bool # type: () -> bool

View File

@ -102,6 +102,12 @@ def add_integrations_context(context):
context['settings_html'] = settings_html context['settings_html'] = settings_html
context['subscriptions_html'] = subscriptions_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)
class IntegrationView(ApiURLView): class IntegrationView(ApiURLView):
template_name = 'zerver/integrations/index.html' template_name = 'zerver/integrations/index.html'