Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

fix auditlog refs #479

Merged
merged 1 commit into from
May 9, 2022
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
11 changes: 11 additions & 0 deletions src/fidesops/models/fidesops_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from fidesops.core.config import config
from fidesops.db.base_class import Base
from fidesops.models.audit_log import AuditLog
from fidesops.util.cryptographic_util import generate_salt, hash_with_salt


Expand All @@ -20,6 +21,16 @@ class FidesopsUser(Base):
last_login_at = Column(DateTime(timezone=True), nullable=True)
password_reset_at = Column(DateTime(timezone=True), nullable=True)

# passive_deletes="all" prevents audit logs from having their privacy_request_id set to null when
# a privacy_request is deleted. We want to retain for record-keeping.
audit_logs = relationship(
AuditLog,
backref="fidesops_user",
lazy="dynamic",
passive_deletes="all",
primaryjoin="foreign(AuditLog.user_id)==FidesopsUser.id",
)

client = relationship(
"ClientDetail", backref="user", cascade="all, delete", uselist=False
)
Expand Down
3 changes: 2 additions & 1 deletion src/fidesops/models/privacy_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Base,
FidesopsBase,
)
from fidesops.models.audit_log import AuditLog
from fidesops.models.client import ClientDetail
from fidesops.models.fidesops_user import FidesopsUser
from fidesops.models.policy import (
Expand Down Expand Up @@ -134,7 +135,7 @@ class PrivacyRequest(Base):
# passive_deletes="all" prevents audit logs from having their privacy_request_id set to null when
# a privacy_request is deleted. We want to retain for record-keeping.
audit_logs = relationship(
"AuditLog",
AuditLog,
backref="privacy_request",
lazy="dynamic",
passive_deletes="all",
Expand Down