mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
integrations: Use dir_name instead of name for default view fn.
Use the directory name as the template literal in the default view function path.
This commit is contained in:
@@ -259,7 +259,7 @@ class PythonAPIIntegration(Integration):
|
|||||||
|
|
||||||
|
|
||||||
class WebhookIntegration(Integration):
|
class WebhookIntegration(Integration):
|
||||||
DEFAULT_FUNCTION_PATH = "zerver.webhooks.{name}.view.api_{name}_webhook"
|
DEFAULT_FUNCTION_PATH = "zerver.webhooks.{dir_name}.view.api_{dir_name}_webhook"
|
||||||
DEFAULT_URL = "api/v1/external/{name}"
|
DEFAULT_URL = "api/v1/external/{name}"
|
||||||
DEFAULT_CLIENT_NAME = "Zulip{name}Webhook"
|
DEFAULT_CLIENT_NAME = "Zulip{name}Webhook"
|
||||||
DEFAULT_DOC_PATH = "{name}/doc.md"
|
DEFAULT_DOC_PATH = "{name}/doc.md"
|
||||||
@@ -296,8 +296,12 @@ class WebhookIntegration(Integration):
|
|||||||
url_options=url_options,
|
url_options=url_options,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if dir_name is None:
|
||||||
|
dir_name = self.name
|
||||||
|
self.dir_name = dir_name
|
||||||
|
|
||||||
if function is None:
|
if function is None:
|
||||||
function = self.DEFAULT_FUNCTION_PATH.format(name=name)
|
function = self.DEFAULT_FUNCTION_PATH.format(dir_name=dir_name)
|
||||||
self.function_name = function
|
self.function_name = function
|
||||||
|
|
||||||
if url is None:
|
if url is None:
|
||||||
@@ -308,10 +312,6 @@ class WebhookIntegration(Integration):
|
|||||||
doc = self.DEFAULT_DOC_PATH.format(name=name)
|
doc = self.DEFAULT_DOC_PATH.format(name=name)
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
|
||||||
if dir_name is None:
|
|
||||||
dir_name = self.name
|
|
||||||
self.dir_name = dir_name
|
|
||||||
|
|
||||||
def get_function(self) -> Callable[[HttpRequest], HttpResponseBase]:
|
def get_function(self) -> Callable[[HttpRequest], HttpResponseBase]:
|
||||||
return import_string(self.function_name)
|
return import_string(self.function_name)
|
||||||
|
|
||||||
@@ -508,7 +508,6 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [
|
|||||||
display_name="GitHub Sponsors",
|
display_name="GitHub Sponsors",
|
||||||
logo="images/integrations/logos/github.svg",
|
logo="images/integrations/logos/github.svg",
|
||||||
dir_name="github",
|
dir_name="github",
|
||||||
function="zerver.webhooks.github.view.api_github_webhook",
|
|
||||||
doc="github/githubsponsors.md",
|
doc="github/githubsponsors.md",
|
||||||
stream_name="github",
|
stream_name="github",
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user