Merge pull request #157 from taigaio/external-references-change
Changed how external reference is obtainedremotes/origin/enhancement/email-actions
commit
ac1b43bdb5
|
@ -110,11 +110,11 @@ class IssuesEventHook(BaseEventHook):
|
|||
|
||||
subject = self.payload.get('issue', {}).get('title', None)
|
||||
description = self.payload.get('issue', {}).get('body', None)
|
||||
github_reference = self.payload.get('issue', {}).get('number', None)
|
||||
github_url = self.payload.get('issue', {}).get('html_url', None)
|
||||
github_user = self.payload.get('issue', {}).get('user', {}).get('id', None)
|
||||
project_url = self.payload.get('repository', {}).get('html_url', None)
|
||||
|
||||
if not all([subject, github_reference, project_url]):
|
||||
if not all([subject, github_url, project_url]):
|
||||
raise ActionSyntaxException(_("Invalid issue information"))
|
||||
|
||||
issue = Issue.objects.create(
|
||||
|
@ -125,7 +125,7 @@ class IssuesEventHook(BaseEventHook):
|
|||
type=self.project.default_issue_type,
|
||||
severity=self.project.default_severity,
|
||||
priority=self.project.default_priority,
|
||||
external_reference=['github', github_reference],
|
||||
external_reference=['github', github_url],
|
||||
owner=get_github_user(github_user)
|
||||
)
|
||||
take_snapshot(issue, user=get_github_user(github_user))
|
||||
|
@ -139,18 +139,18 @@ class IssueCommentEventHook(BaseEventHook):
|
|||
if self.payload.get('action', None) != "created":
|
||||
raise ActionSyntaxException(_("Invalid issue comment information"))
|
||||
|
||||
github_reference = self.payload.get('issue', {}).get('number', None)
|
||||
github_url = self.payload.get('issue', {}).get('html_url', None)
|
||||
comment_message = self.payload.get('comment', {}).get('body', None)
|
||||
github_user = self.payload.get('sender', {}).get('id', None)
|
||||
project_url = self.payload.get('repository', {}).get('html_url', None)
|
||||
comment_message = replace_github_references(project_url, comment_message)
|
||||
|
||||
if not all([comment_message, github_reference, project_url]):
|
||||
if not all([comment_message, github_url, project_url]):
|
||||
raise ActionSyntaxException(_("Invalid issue comment information"))
|
||||
|
||||
issues = Issue.objects.filter(external_reference=["github", github_reference])
|
||||
tasks = Task.objects.filter(external_reference=["github", github_reference])
|
||||
uss = UserStory.objects.filter(external_reference=["github", github_reference])
|
||||
issues = Issue.objects.filter(external_reference=["github", github_url])
|
||||
tasks = Task.objects.filter(external_reference=["github", github_url])
|
||||
uss = UserStory.objects.filter(external_reference=["github", github_url])
|
||||
|
||||
for item in list(issues) + list(tasks) + list(uss):
|
||||
snapshot = take_snapshot(item,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from rest_framework import serializers
|
||||
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin, PgArrayField
|
||||
from taiga.mdrender.service import render as mdrender
|
||||
from taiga.projects.validators import ProjectExistsValidator
|
||||
from taiga.projects.notifications.validators import WatchersValidator
|
||||
|
@ -26,6 +26,7 @@ from . import models
|
|||
|
||||
class IssueSerializer(WatchersValidator, serializers.ModelSerializer):
|
||||
tags = PickleField(required=False)
|
||||
external_reference = PgArrayField(required=False)
|
||||
is_closed = serializers.Field(source="is_closed")
|
||||
comment = serializers.SerializerMethodField("get_comment")
|
||||
generated_user_stories = serializers.SerializerMethodField("get_generated_user_stories")
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from rest_framework import serializers
|
||||
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin, PgArrayField
|
||||
from taiga.mdrender.service import render as mdrender
|
||||
from taiga.projects.validators import ProjectExistsValidator, TaskStatusExistsValidator
|
||||
from taiga.projects.milestones.validators import SprintExistsValidator
|
||||
|
@ -28,6 +28,7 @@ from . import models
|
|||
|
||||
class TaskSerializer(WatchersValidator, serializers.ModelSerializer):
|
||||
tags = PickleField(required=False, default=[])
|
||||
external_reference = PgArrayField(required=False)
|
||||
comment = serializers.SerializerMethodField("get_comment")
|
||||
milestone_slug = serializers.SerializerMethodField("get_milestone_slug")
|
||||
blocked_note_html = serializers.SerializerMethodField("get_blocked_note_html")
|
||||
|
|
|
@ -18,7 +18,7 @@ import json
|
|||
from django.apps import apps
|
||||
from rest_framework import serializers
|
||||
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin
|
||||
from taiga.base.serializers import Serializer, PickleField, NeighborsSerializerMixin, PgArrayField
|
||||
from taiga.mdrender.service import render as mdrender
|
||||
from taiga.projects.validators import ProjectExistsValidator, UserStoryStatusExistsValidator
|
||||
from taiga.projects.userstories.validators import UserStoryExistsValidator
|
||||
|
@ -39,6 +39,7 @@ class RolePointsField(serializers.WritableField):
|
|||
|
||||
class UserStorySerializer(WatchersValidator, serializers.ModelSerializer):
|
||||
tags = PickleField(default=[], required=False)
|
||||
external_reference = PgArrayField(required=False)
|
||||
points = RolePointsField(source="role_points", required=False)
|
||||
total_points = serializers.SerializerMethodField("get_total_points")
|
||||
comment = serializers.SerializerMethodField("get_comment")
|
||||
|
|
|
@ -219,7 +219,7 @@ def test_issues_event_opened_issue(client):
|
|||
"issue": {
|
||||
"title": "test-title",
|
||||
"body": "test-body",
|
||||
"number": 10,
|
||||
"html_url": "http://github.com/test/project/issues/11",
|
||||
},
|
||||
"assignee": {},
|
||||
"label": {},
|
||||
|
@ -249,7 +249,7 @@ def test_issues_event_other_than_opened_issue(client):
|
|||
"issue": {
|
||||
"title": "test-title",
|
||||
"body": "test-body",
|
||||
"number": 10,
|
||||
"html_url": "http://github.com/test/project/issues/11",
|
||||
},
|
||||
"assignee": {},
|
||||
"label": {},
|
||||
|
@ -291,17 +291,17 @@ def test_issues_event_bad_issue(client):
|
|||
|
||||
|
||||
def test_issue_comment_event_on_existing_issue_task_and_us(client):
|
||||
issue = f.IssueFactory.create(external_reference=["github", "10"])
|
||||
issue = f.IssueFactory.create(external_reference=["github", "http://github.com/test/project/issues/11"])
|
||||
take_snapshot(issue, user=issue.owner)
|
||||
task = f.TaskFactory.create(project=issue.project, external_reference=["github", "10"])
|
||||
task = f.TaskFactory.create(project=issue.project, external_reference=["github", "http://github.com/test/project/issues/11"])
|
||||
take_snapshot(task, user=task.owner)
|
||||
us = f.UserStoryFactory.create(project=issue.project, external_reference=["github", "10"])
|
||||
us = f.UserStoryFactory.create(project=issue.project, external_reference=["github", "http://github.com/test/project/issues/11"])
|
||||
take_snapshot(us, user=us.owner)
|
||||
|
||||
payload = {
|
||||
"action": "created",
|
||||
"issue": {
|
||||
"number": 10,
|
||||
"html_url": "http://github.com/test/project/issues/11",
|
||||
},
|
||||
"comment": {
|
||||
"body": "Test body",
|
||||
|
@ -346,7 +346,7 @@ def test_issue_comment_event_on_not_existing_issue_task_and_us(client):
|
|||
payload = {
|
||||
"action": "created",
|
||||
"issue": {
|
||||
"number": 11,
|
||||
"html_url": "http://github.com/test/project/issues/11",
|
||||
},
|
||||
"comment": {
|
||||
"body": "Test body",
|
||||
|
|
Loading…
Reference in New Issue