Add a first pass at Redmine integration.

The integration supports events generated by creating and editing
issues.

(imported from commit 1988013d7a18df173623c0821e807fd4f42af3bc)
This commit is contained in:
Jessica McKellar 2013-09-23 10:15:23 -04:00 committed by Zev Benjamin
parent 50641c3337
commit 4e74131008
2 changed files with 40 additions and 0 deletions

View File

@ -440,6 +440,45 @@ def api_newrelic_webhook(request, alert=REQ(converter=json_to_dict, default=None
check_send_message(user_profile, get_client("API"), "stream", [stream], subject, content)
return json_success()
@authenticated_api_view
@has_request_variables
def api_redmine_webhook(request, user_profile,
payload=REQ(converter=json_to_dict), stream=REQ):
subject = payload["project"]
if payload["type"] == "new":
# Opening a new ticket.
content = """%s opened [issue %d: %s](%s) in %s
~~~ quote
%s
~~~
**Priority**: %s
**Status**: %s
**Assigned to**: %s
""" % (
payload["author"], payload["issue_id"], payload["issue_subject"],
payload["url"], payload["project"], payload["issue_description"],
payload["priority"], payload["status"], payload["assignee"])
elif payload["type"] == "edit":
# Editing an existing ticket.
content = """%s updated [issue %d: %s](%s) in %s
~~~ quote
%s
~~~""" % (
payload["author"], payload["issue_id"], payload["issue_subject"],
payload["url"], payload["project"], payload["notes"])
else:
return json_error("Unknown issue update type.")
check_send_message(user_profile, get_client("API"), "stream",
[stream], subject, content)
return json_success()
@authenticated_rest_api_view
@has_request_variables
def api_bitbucket_webhook(request, user_profile, payload=REQ(converter=json_to_dict),

View File

@ -149,6 +149,7 @@ urlpatterns += patterns('zerver.views',
url(r'^api/v1/external/newrelic$', 'webhooks.api_newrelic_webhook'),
url(r'^api/v1/external/bitbucket$', 'webhooks.api_bitbucket_webhook'),
url(r'^api/v1/external/desk$', 'webhooks.api_deskdotcom_webhook'),
url(r'^api/v1/external/redmine$', 'webhooks.api_redmine_webhook'),
)
v1_api_and_json_patterns = patterns('zerver.views',