Permalink
Browse files

Don't create overlay records when there's a file error.

  • Loading branch information...
1 parent cb273d6 commit c7ea6be4f784dd73b6d14921107db36323e27e71 @deleted deleted committed Oct 25, 2012
Showing with 8 additions and 7 deletions.
  1. +8 −7 geocamTiePoint/views.py
View
15 geocamTiePoint/views.py
@@ -148,11 +148,6 @@ def overlayNewJSON(request):
if not form.is_valid():
return ErrorJSONResponse( form.errors )
else:
- # create and save new empty overlay so we can refer to it
- # this causes a ValueError if the user isn't logged in
- overlay = models.Overlay(author=request.user,
- isPublic=settings.GEOCAM_TIE_POINT_PUBLIC_BY_DEFAULT)
- overlay.save()
# test to see if there is an image file
# file takes precedence over image url
@@ -188,8 +183,7 @@ def overlayNewJSON(request):
imageType = imageRef.content_type
imageName = imageRef.name
- imageData = models.ImageData(contentType=imageType,
- overlay=overlay)
+ imageData = models.ImageData(contentType=imageType)
if imageType in PDF_MIME_TYPES:
# convert PDF to raster image
@@ -216,6 +210,13 @@ def overlayNewJSON(request):
else:
imageData.image.save('dummy.png', ContentFile(bits), save=False)
imageData.contentType = imageType
+
+ # create and save new empty overlay so we can refer to it
+ # this causes a ValueError if the user isn't logged in
+ overlay = models.Overlay(author=request.user,
+ isPublic=settings.GEOCAM_TIE_POINT_PUBLIC_BY_DEFAULT)
+ overlay.save()
+ imageData.overlay = overlay
imageData.save()
if image is None:

0 comments on commit c7ea6be

Please sign in to comment.