Annotate webhooks/transifex.py, webhooks/yo.py.

This commit is contained in:
Evan Palmer 2016-06-05 15:14:45 -07:00 committed by Tim Abbott
parent 7f0709b65c
commit 8afeb7d8ce
2 changed files with 10 additions and 3 deletions

View File

@ -1,10 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from __future__ import absolute_import from __future__ import absolute_import
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.http import HttpRequest, HttpResponse
from zerver.models import UserProfile, Client
from zerver.lib.actions import check_send_message from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success, json_error
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from typing import Optional
@api_key_only_webhook_view('Transifex') @api_key_only_webhook_view('Transifex')
@has_request_variables @has_request_variables
@ -13,6 +15,7 @@ def api_transifex_webhook(request, user_profile, client,
language=REQ(), translated=REQ(default=None), language=REQ(), translated=REQ(default=None),
reviewed=REQ(default=None), reviewed=REQ(default=None),
stream=REQ(default='transifex')): stream=REQ(default='transifex')):
# type: (HttpRequest, UserProfile, Client, str, str, str, Optional[int], Optional[int], str) -> HttpResponse
subject = "{} in {}".format(project, language) subject = "{} in {}".format(project, language)
if translated: if translated:
body = "Resource {} fully translated.".format(resource) body = "Resource {} fully translated.".format(resource)

View File

@ -3,14 +3,18 @@ from __future__ import absolute_import
from zerver.lib.actions import check_send_message from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile, Client
from django.http import HttpRequest, HttpResponse
from typing import Optional
import ujson import ujson
@api_key_only_webhook_view('Yo') @api_key_only_webhook_view('Yo')
@has_request_variables @has_request_variables
def api_yo_app_webhook(request, user_profile, client, email=REQ(default=None), def api_yo_app_webhook(request, user_profile, client, email=REQ(default=None),
username=REQ(default='Yo Bot'), topic=REQ(default='None'), username=REQ(default='Yo Bot'), topic=REQ(default=None),
user_ip=REQ(default='None')): user_ip=REQ(default=None)):
# type: (HttpRequest, UserProfile, Client, Optional[str], str, Optional[str], Optional[str]) -> HttpResponse
body = ('Yo from %s') % (username,) body = ('Yo from %s') % (username,)
check_send_message(user_profile, client, 'private', [email], topic, body) check_send_message(user_profile, client, 'private', [email], topic, body)