-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add is_confirmed query parameter to environment issues endpoint * Make environment issue URL optional if issue is unconfirmed * Make environment issues URL optional for unconfirmed cases in frontend
- Loading branch information
Showing
9 changed files
with
108 additions
and
23 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.../migrations/versions/2024_09_23_0840-9d7eed94a543_make_environment_issues_url_nullable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Make environment issues URL nullable | ||
Revision ID: 9d7eed94a543 | ||
Revises: 505b96fd7731 | ||
Create Date: 2024-09-23 08:40:44.972779+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "9d7eed94a543" | ||
down_revision = "505b96fd7731" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.alter_column( | ||
"environment_issue", "url", existing_type=sa.VARCHAR(), nullable=True | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.alter_column( | ||
"environment_issue", "url", existing_type=sa.VARCHAR(), nullable=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
from datetime import datetime | ||
|
||
from pydantic import BaseModel, HttpUrl, field_validator | ||
from pydantic import BaseModel, HttpUrl, model_validator | ||
|
||
from test_observer.common.constants import VALID_ISSUE_HOSTS | ||
|
||
|
||
class EnvironmentReportedIssueRequest(BaseModel): | ||
environment_name: str | ||
description: str | ||
url: HttpUrl | ||
url: HttpUrl | None = None | ||
is_confirmed: bool | ||
|
||
@field_validator("url") | ||
@classmethod | ||
def url_host_must_be_allowed( | ||
cls: type["EnvironmentReportedIssueRequest"], url: HttpUrl | ||
) -> HttpUrl: | ||
if url.host not in VALID_ISSUE_HOSTS: | ||
@model_validator(mode="after") | ||
def validate_url(self) -> "EnvironmentReportedIssueRequest": | ||
if self.url is None and self.is_confirmed: | ||
raise ValueError("A URL is required if the issue is confirmed") | ||
|
||
if self.url is not None and self.url.host not in VALID_ISSUE_HOSTS: | ||
raise ValueError(f"Issue url must belong to one of {VALID_ISSUE_HOSTS}") | ||
return url | ||
|
||
return self | ||
|
||
|
||
class EnvironmentReportedIssueResponse(BaseModel): | ||
id: int | ||
environment_name: str | ||
description: str | ||
url: HttpUrl | ||
url: HttpUrl | None | ||
is_confirmed: bool | ||
created_at: datetime | ||
updated_at: datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters