"""Zugriffsregeln für csv_field_mappings (Issue #21)."""

from __future__ import annotations

from typing import Any, Mapping


def user_may_edit_mapping_row(row: Mapping[str, Any], session: Mapping[str, Any]) -> bool:
    if session.get("role") == "admin":
        return True
    if row.get("is_system"):
        return False
    return str(row.get("profile_id")) == str(session.get("profile_id"))


def user_may_delete_mapping(row: Mapping[str, Any], session: Mapping[str, Any]) -> bool:
    if row.get("is_system"):
        return False
    return str(row.get("profile_id")) == str(session.get("profile_id"))
