Skip to content

Commit

Permalink
Don't create overlay records when there's a file error.
Browse files Browse the repository at this point in the history
  • Loading branch information
deleted committed Oct 25, 2012
1 parent cb273d6 commit c7ea6be
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions geocamTiePoint/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit c7ea6be

Please sign in to comment.