API: Upload new version of an extension #138
@ -7,6 +7,7 @@ from rest_framework.views import APIView
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from drf_spectacular.utils import OpenApiParameter, extend_schema
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import transaction
|
||||
|
||||
from common.compare import is_in_version_range, version
|
||||
from extensions.models import Extension, Platform, Version
|
||||
@ -207,6 +208,7 @@ class UploadExtensionVersionView(APIView):
|
||||
if not form.is_valid():
|
||||
return Response({'message': form.errors}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
with transaction.atomic():
|
||||
# Create the file instance
|
||||
file_instance = form.save(commit=False)
|
||||
dfelinto marked this conversation as resolved
Outdated
|
||||
file_instance.user = user
|
||||
|
Loading…
Reference in New Issue
Block a user
this save and the update_or_create below should ideally be together in the same transaction, we should wrap all db writes in one
with transaction.atomic():