mirror of https://github.com/zulip/zulip.git
parent
c6cfd21bd4
commit
093e5a96d4
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -244,6 +244,12 @@
|
|||
<span class="integration-label">Trac</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-transifex">
|
||||
<a class="integration-link integration-transifex" href="#transifex">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/transifex.png" alt="Transifex logo" />
|
||||
<span class="integration-label">Transifex</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-travis">
|
||||
<a class="integration-link integration-travis" href="#travis">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/travis.png" alt="Travis CI logo" />
|
||||
|
@ -1931,6 +1937,34 @@ TOPIC = Taiga</pre>
|
|||
in <code>zulip_trac_config.py</code>.</p>
|
||||
</div>
|
||||
|
||||
<div id="transifex" class="integration-instructions">
|
||||
|
||||
<p>First, create the stream you'd like to use for Transifex
|
||||
notifications, and subscribe all interested parties to this stream. We
|
||||
recommend the name <code>transifex</code>.</p>
|
||||
|
||||
<p>Next, set up a bot for the integration. You'll need the bot's API key
|
||||
to construct a URL for Transifex.</p>
|
||||
|
||||
<p><code>{{ external_api_uri }}/v1/external/transifex?api_key=abcdefgh&stream=transifex</code></p>
|
||||
|
||||
<p>where <code>api_key</code> is the API key of your Zulip bot,
|
||||
and <code>stream</code> is the stream name you want the
|
||||
notifications sent to.</p>
|
||||
|
||||
<p>Next, in Transifex, go to your project settings page:
|
||||
Project Details → Manage → Edit Project and scroll down to
|
||||
WEB HOOK URL. Paste the URL you constructed into the box and
|
||||
save your changes.</p>
|
||||
|
||||
<p><b>Congratulations! You're done!</b><br />
|
||||
Example message:
|
||||
</p>
|
||||
|
||||
<img class="screenshot" src="/static/images/integrations/transifex/001.png" />
|
||||
|
||||
</div>
|
||||
|
||||
<div id="travis" class="integration-instructions">
|
||||
|
||||
<p>See your Travis CI build notifications in Zulip!</p>
|
||||
|
|
|
@ -1181,3 +1181,44 @@ class CircleCiHookTests(WebhookTestCase):
|
|||
expected_subject = u"RepoName"
|
||||
expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch fixed."
|
||||
self.send_and_test_stream_message('build_passed_when_previous_build_failed', expected_subject, expected_message)
|
||||
|
||||
class TransifexHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'transifex'
|
||||
URL_TEMPLATE = "/api/v1/external/transifex?stream={stream}&api_key={api_key}&{data_template}"
|
||||
URL_DATA_TEMPLATE = "project={project}&language={language}&resource={resource}&{method}"
|
||||
URL_REVIEWED_METHOD_TEMPLATE = "reviewed=100"
|
||||
URL_TRANSLATED_METHOD_TEMPLATE = "translated=100"
|
||||
FIXTURE_DIR_NAME = 'transifex'
|
||||
|
||||
PROJECT = 'project-title'
|
||||
LANGUAGE = 'en'
|
||||
RESOURCE = 'file'
|
||||
REVIEWED = True
|
||||
|
||||
def test_transifex_reviewed_message(self):
|
||||
self.REVIEWED = True
|
||||
expected_subject = "{} in {}".format(self.PROJECT, self.LANGUAGE)
|
||||
expected_message = "Resource {} fully reviewed.".format(self.RESOURCE)
|
||||
self.url = self.build_webhook_url()
|
||||
self.send_and_test_stream_message(None, expected_subject, expected_message)
|
||||
|
||||
def test_transifex_translated_message(self):
|
||||
self.REVIEWED = False
|
||||
expected_subject = "{} in {}".format(self.PROJECT, self.LANGUAGE)
|
||||
expected_message = "Resource {} fully translated.".format(self.RESOURCE)
|
||||
self.url = self.build_webhook_url()
|
||||
self.send_and_test_stream_message(None, expected_subject, expected_message)
|
||||
self.REVIEWED = True
|
||||
|
||||
def build_webhook_url(self):
|
||||
url_data = self.URL_DATA_TEMPLATE.format(
|
||||
project=self.PROJECT,
|
||||
language=self.LANGUAGE,
|
||||
resource=self.RESOURCE,
|
||||
method=self.URL_REVIEWED_METHOD_TEMPLATE if self.REVIEWED else self.URL_TRANSLATED_METHOD_TEMPLATE
|
||||
)
|
||||
api_key = self.get_api_key(self.TEST_USER_EMAIL)
|
||||
return self.URL_TEMPLATE.format(api_key=api_key, stream=self.STREAM_NAME, data_template=url_data)
|
||||
|
||||
def get_body(self, fixture_name):
|
||||
return {}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# Webhooks for external integrations.
|
||||
from __future__ import absolute_import
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.lib.actions import check_send_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
|
||||
|
||||
|
||||
@api_key_only_webhook_view('Transifex')
|
||||
@has_request_variables
|
||||
def api_transifex_webhook(request, user_profile, client,
|
||||
project=REQ(), resource=REQ(),
|
||||
language=REQ(), translated=REQ(default=None),
|
||||
reviewed=REQ(default=None),
|
||||
stream=REQ(default='transifex')):
|
||||
subject = "{} in {}".format(project, language)
|
||||
if translated:
|
||||
body = "Resource {} fully translated.".format(resource)
|
||||
elif reviewed:
|
||||
body = "Resource {} fully reviewed.".format(resource)
|
||||
else:
|
||||
return json_error(_("Transifex wrong request"))
|
||||
check_send_message(user_profile, client, 'stream', [stream], subject, body)
|
||||
return json_success()
|
|
@ -161,6 +161,7 @@ urlpatterns += patterns('zerver.views',
|
|||
url(r'^api/v1/external/stash$', 'webhooks.stash.api_stash_webhook'),
|
||||
url(r'^api/v1/external/taiga$', 'webhooks.taiga.api_taiga_webhook'),
|
||||
url(r'^api/v1/external/teamcity$', 'webhooks.teamcity.api_teamcity_webhook'),
|
||||
url(r'^api/v1/external/transifex', 'webhooks.transifex.api_transifex_webhook'),
|
||||
url(r'^api/v1/external/travis$', 'webhooks.travis.api_travis_webhook'),
|
||||
url(r'^api/v1/external/yo$', 'webhooks.yo.api_yo_app_webhook'),
|
||||
url(r'^api/v1/external/zendesk$', 'webhooks.zendesk.api_zendesk_webhook'),
|
||||
|
|
Loading…
Reference in New Issue