mirror of https://github.com/zulip/zulip.git
integrations: Pass context to integration objects.
This commit is contained in:
parent
7ff699cd67
commit
21f5c5cbf4
|
@ -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
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in New Issue