- Added permissions for editing and deleting CSV field mappings. - Created type converter for CSV cells to handle various data types. - Implemented database migrations for CSV field mappings and import logs. - Seeded initial system templates for nutrition and activity data imports. - Developed admin endpoints for managing system CSV templates. - Introduced user endpoints for CSV import analysis and mapping retrieval. - Added tests for core CSV parser functionalities, including delimiter detection and value conversion.
20 lines
614 B
Python
20 lines
614 B
Python
"""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"))
|