Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix comments
Roland Geiderbdbab881b477
diff --git a/wger/core/api/views.py b/wger/core/api/views.pyindex f041ee4da..a2aeede82 100644--- a/wger/core/api/views.py+++ b/wger/core/api/views.py@@ -395,7 +395,9 @@ def upload_powersync_data(request):status=200,)- logger.info(f'Received PowerSync data for table {table} via {http_verb} for user {user_id}')+ # Debug, not info: clients push one row per request, so a first health+ # import writes a five figure number of these lines for a single user+ logger.debug(f'Received PowerSync data for table {table} via {http_verb} for user {user_id}')handler = POWERSYNC_REGISTRY.get(table)if handler is None:diff --git a/wger/measurements/api/serializers.py b/wger/measurements/api/serializers.pyindex 7d28bd7b0..dc3f371a6 100644--- a/wger/measurements/api/serializers.py+++ b/wger/measurements/api/serializers.py@@ -123,9 +123,11 @@ class CategorySerializer(serializers.ModelSerializer):"""Only one category per metric type and user.- The constraint carries a condition, for which DRF generates no validator- of its own, so a duplicate would otherwise only surface as an- IntegrityError when saving.+ DRF generates a validator for a UniqueConstraint only when the+ serializer maps every field of it. The owner is not part of the payload+ (it is passed to save() by the viewset and the PowerSync handler), so+ this constraint is skipped and a duplicate would otherwise only surface+ as an IntegrityError when saving."""user_id = self._get_user_id()if metric_type == MetricType.CUSTOM or user_id is None:diff --git a/wger/utils/viewsets.py b/wger/utils/viewsets.pyindex e464e7ba0..9c67f7954 100644--- a/wger/utils/viewsets.py+++ b/wger/utils/viewsets.py@@ -66,7 +66,9 @@ def check_fk_ownership(payload: dict, owner_objects: list[tuple], user_id: int)continueowner = obj.get_owner_object()- if owner and hasattr(owner, 'user') and owner.user_id != user_id:+ # Ask for the id rather than for ``user``: the latter dereferences the+ # foreign key and loads the whole user row, which this never looks at+ if owner and hasattr(owner, 'user_id') and owner.user_id != user_id:logger.warning(f'{model_class.__name__} {pk} does not belong to user {user_id}')return Falsereturn True