diff --git a/taiga/auth/services.py b/taiga/auth/services.py
index 348e41d4..26f3d0db 100644
--- a/taiga/auth/services.py
+++ b/taiga/auth/services.py
@@ -66,7 +66,7 @@ def is_user_already_registered(*, username:str, email:str, github_id:int=None) -
return (True, _("Email is already in use."))
if github_id and user_model.objects.filter(github_id=github_id):
- return (True, _("Github id is already in use"))
+ return (True, _("GitHub id is already in use"))
return (False, None)
diff --git a/taiga/github_hook/api.py b/taiga/github_hook/api.py
index f5bfd4e2..23c4a65a 100644
--- a/taiga/github_hook/api.py
+++ b/taiga/github_hook/api.py
@@ -14,26 +14,19 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-import json
-import hmac
-import hashlib
-
-from rest_framework.exceptions import ParseError
from rest_framework.response import Response
-from rest_framework.exceptions import APIException
-
-from django.views.decorators.csrf import csrf_exempt
from django.utils.translation import ugettext_lazy as _
from taiga.base.api.viewsets import GenericViewSet
+from taiga.base import exceptions as exc
+from taiga.base.utils import json
from taiga.projects.models import Project
from . import event_hooks
from .exceptions import ActionSyntaxException
-
-class Http400(APIException):
- status_code = 400
+import hmac
+import hashlib
class GitHubViewSet(GenericViewSet):
@@ -79,17 +72,17 @@ class GitHubViewSet(GenericViewSet):
def create(self, request, *args, **kwargs):
project = self._get_project(request)
if not project:
- raise Http400(_("The project doesn't exist"))
+ raise exc.BadRequest(_("The project doesn't exist"))
if not self._validate_signature(project, request):
- raise Http400(_("Bad signature"))
+ raise exc.BadRequest(_("Bad signature"))
event_name = request.META.get("HTTP_X_GITHUB_EVENT", None)
try:
payload = json.loads(request.body.decode("utf-8"))
- except ValueError as e:
- raise Http400(_("The payload is not a valid json"))
+ except ValueError:
+ raise exc.BadRequest(_("The payload is not a valid json"))
event_hook_class = self.event_hook_classes.get(event_name, None)
if event_hook_class is not None:
@@ -97,6 +90,6 @@ class GitHubViewSet(GenericViewSet):
try:
event_hook.process_event()
except ActionSyntaxException as e:
- raise Http400(e)
+ raise exc.BadRequest(e)
return Response({})
diff --git a/taiga/github_hook/event_hooks.py b/taiga/github_hook/event_hooks.py
index b4150da4..7f60d7c2 100644
--- a/taiga/github_hook/event_hooks.py
+++ b/taiga/github_hook/event_hooks.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-import re
-
from django.utils.translation import ugettext_lazy as _
from taiga.projects.models import Project, IssueStatus, TaskStatus, UserStoryStatus
@@ -29,8 +27,10 @@ from taiga.projects.notifications.services import send_notifications
from .exceptions import ActionSyntaxException
from .services import get_github_user
-class BaseEventHook(object):
+import re
+
+class BaseEventHook:
def __init__(self, project, payload):
self.project = project
self.payload = payload
@@ -40,7 +40,6 @@ class BaseEventHook(object):
class PushEventHook(BaseEventHook):
-
def process_event(self):
if self.payload is None:
return
@@ -93,12 +92,14 @@ class PushEventHook(BaseEventHook):
element.status = status
element.save()
- snapshot = take_snapshot(element, comment="Status changed from Github commit", user=get_github_user(github_user))
+ snapshot = take_snapshot(element,
+ comment="Status changed from GitHub commit",
+ user=get_github_user(github_user))
send_notifications(element, history=snapshot)
def replace_github_references(project_url, wiki_text):
- template = "\g<1>[Github#\g<2>]({}/issues/\g<2>)\g<3>".format(project_url)
+ template = "\g<1>[GitHub#\g<2>]({}/issues/\g<2>)\g<3>".format(project_url)
return re.sub(r"(\s|^)#(\d+)(\s|$)", template, wiki_text, 0, re.M)
@@ -129,9 +130,10 @@ class IssuesEventHook(BaseEventHook):
)
take_snapshot(issue, user=get_github_user(github_user))
- snapshot = take_snapshot(issue, comment="Created from Github", user=get_github_user(github_user))
+ snapshot = take_snapshot(issue, comment="Created from GitHub", user=get_github_user(github_user))
send_notifications(issue, history=snapshot)
+
class IssueCommentEventHook(BaseEventHook):
def process_event(self):
if self.payload.get('action', None) != "created":
@@ -151,5 +153,7 @@ class IssueCommentEventHook(BaseEventHook):
uss = UserStory.objects.filter(external_reference=["github", github_reference])
for item in list(issues) + list(tasks) + list(uss):
- snapshot = take_snapshot(item, comment="From Github:\n\n{}".format(comment_message), user=get_github_user(github_user))
+ snapshot = take_snapshot(item,
+ comment="From GitHub:\n\n{}".format(comment_message),
+ user=get_github_user(github_user))
send_notifications(item, history=snapshot)
diff --git a/taiga/github_hook/migrations/0001_initial.py b/taiga/github_hook/migrations/0001_initial.py
index 65f10eaa..fc98953d 100644
--- a/taiga/github_hook/migrations/0001_initial.py
+++ b/taiga/github_hook/migrations/0001_initial.py
@@ -15,7 +15,7 @@ def create_github_system_user(apps, schema_editor):
user = User.objects.using(db_alias).create(
username="github-{}".format(random_hash),
email="github-{}@taiga.io".format(random_hash),
- full_name="Github",
+ full_name="GitHub",
is_active=False,
is_system=True,
bio="",
diff --git a/taiga/github_hook/models.py b/taiga/github_hook/models.py
index e69de29b..fca83d73 100644
--- a/taiga/github_hook/models.py
+++ b/taiga/github_hook/models.py
@@ -0,0 +1 @@
+# This file is needed to load migrations
diff --git a/taiga/mdrender/extensions/semi_sane_lists.py b/taiga/mdrender/extensions/semi_sane_lists.py
index 7eba07e7..d208e1c4 100644
--- a/taiga/mdrender/extensions/semi_sane_lists.py
+++ b/taiga/mdrender/extensions/semi_sane_lists.py
@@ -21,7 +21,7 @@ class SemiSaneListExtension(markdown.Extension):
the sane_lists extension, GitHub will mix list types if they're not
separated by multiple newlines.
- Github also recognizes lists that start in the middle of a paragraph. This
+ GitHub also recognizes lists that start in the middle of a paragraph. This
is currently not supported by this extension, since the Python parser has a
deeply-ingrained belief that blocks are always separated by multiple
newlines.
diff --git a/taiga/routers.py b/taiga/routers.py
index db3e397f..ac8c6da8 100644
--- a/taiga/routers.py
+++ b/taiga/routers.py
@@ -131,7 +131,7 @@ from taiga.projects.notifications.api import NotifyPolicyViewSet
router.register(r"notify-policies", NotifyPolicyViewSet, base_name="notifications")
-# Github webhooks
+# GitHub webhooks
from taiga.github_hook.api import GitHubViewSet
router.register(r"github-hook", GitHubViewSet, base_name="github-hook")