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