Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions backend/core/serializers/configure_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,24 @@ def __init__(self, *args, **kwargs):
request = self.context.get('request')
user = getattr(request, 'user', None)
if user:
self.fields['integration'].queryset = Integration.objects.filter(owner=user)
self.fields['integration'].queryset = Integration.objects.filter(creator=user)

def validate(self, attrs):
integration = attrs['integration']
app = self.context.get("application")
branch_name = attrs.get("branch_name")

if integration.owner != app.owner:
if integration.creator != app.owner:
raise serializers.ValidationError("Integration and application owner mismatch.")

if integration.type != attrs["type"]:
raise serializers.ValidationError(
f"Integration type '{integration.type}' does not match '{attrs['type']}'"
)

if integration.type == "pms" and integration.provider.lower() == "github":
if attrs["type"] == "pms" and integration.provider.lower() == "github":
if not branch_name:
raise serializers.ValidationError("Branch is required for GitHub PMS integrations.")

return attrs

def validate_integration(self, value):
app = self.context.get('application')
if value.owner != app.owner:
if value.creator != app.owner:
raise serializers.ValidationError("Integration and application owner mismatch.")
return value
8 changes: 4 additions & 4 deletions backend/core/serializers/version_control_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Meta:
model = VCIssueComment
fields = [
'id', 'uuid', 'external_id', 'body', 'author', 'author_association',
'created_at_field', 'updated_at_field', 'url', 'created_at', 'updated_at'
'url', 'created_at', 'updated_at'
]
read_only_fields = ['id', 'uuid', 'created_at', 'updated_at']

Expand All @@ -35,7 +35,7 @@ class Meta:
fields = [
'id', 'uuid', 'external_id', 'number', 'title', 'body', 'state',
'author', 'author_association', 'assignees', 'labels', 'milestone',
'locked', 'created_at_field', 'updated_at_field', 'closed_at', 'url',
'locked', 'closed_at', 'url',
'comments', 'comment_count', 'created_at', 'updated_at'
]
read_only_fields = ['id', 'uuid', 'created_at', 'updated_at']
Expand All @@ -61,7 +61,7 @@ class Meta:
model = VCPRComment
fields = [
'id', 'uuid', 'external_id', 'body', 'author', 'author_association',
'created_at_field', 'updated_at_field', 'url', 'created_at', 'updated_at'
'url', 'created_at', 'updated_at'
]
read_only_fields = ['id', 'uuid', 'created_at', 'updated_at']

Expand All @@ -79,7 +79,7 @@ class Meta:
'author', 'author_association', 'assignees', 'reviewers', 'labels',
'milestone', 'head_branch', 'base_branch', 'merged', 'merged_at',
'merge_commit_sha', 'additions', 'deletions', 'changed_files',
'created_at_field', 'updated_at_field', 'closed_at', 'url',
'closed_at', 'url',
'comments', 'files', 'comment_count', 'file_count',
'created_at', 'updated_at'
]
Expand Down
Empty file.
Loading
Loading