mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 23:31:31 +02:00
- Target delete failed when scan data existed: scans.target_id and activity_logs.target_id FKs had no ON DELETE rule. Add ondelete CASCADE (scans) / SET NULL (activity_logs) to the models + a migration that alters the existing constraints. Deleting a target now cascades its scans (and their subdomains/activities/commands) and nulls audit-log refs. - Targets list: clicking the row checkbox bubbled to the row and navigated to the target summary. Wrap the checkbox in a stopProp container. - Scan history: add per-row + select-all checkboxes and a bulk action bar (cancel running / delete selected) mirroring the targets pattern, backed by scansStore.removeMany/cancelMany.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
from shared.enums.activity import ActivityEvent, ActivityLevel
|
|
from shared.utils.datetime import utc_now
|
|
|
|
|
|
class ActivityLog(SQLModel, table=True):
|
|
__tablename__ = "activity_logs"
|
|
|
|
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
|
timestamp: datetime = Field(default_factory=utc_now, index=True)
|
|
level: ActivityLevel = Field(default=ActivityLevel.INFO)
|
|
event_type: ActivityEvent = Field(index=True)
|
|
title: str = Field(max_length=200)
|
|
description: str | None = Field(default=None, max_length=2000)
|
|
|
|
project_id: uuid.UUID | None = Field(
|
|
default=None, foreign_key="projects.id", index=True
|
|
)
|
|
target_id: uuid.UUID | None = Field(
|
|
default=None, foreign_key="targets.id", index=True, ondelete="SET NULL"
|
|
)
|
|
user_id: uuid.UUID | None = Field(default=None, foreign_key="users.id", index=True)
|
|
|
|
|
|
class ActivityLogRead(BaseModel):
|
|
id: uuid.UUID
|
|
timestamp: datetime
|
|
level: ActivityLevel
|
|
event_type: ActivityEvent
|
|
title: str
|
|
description: str | None = None
|
|
project_id: uuid.UUID | None = None
|
|
target_id: uuid.UUID | None = None
|
|
user_id: uuid.UUID | None = None
|