Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
(BSR) Check no venue with the same siret exists
Browse files Browse the repository at this point in the history
  • Loading branch information
cgaunet authored and cgaunet committed Jun 25, 2021
1 parent f1b967c commit 63449d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/pcapi/core/offerers/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def check_venue_edition(modifications, venue):
errors = ApiErrors()
errors.add_error("siret", "Vous ne pouvez pas modifier le siret d'un lieu")
raise errors
if siret:
venue_with_same_siret = Venue.query.filter_by(siret=siret).one_or_none()
if venue_with_same_siret:
errors = ApiErrors()
errors.add_error("siret", "Un lieu avec le même siret existe déjà")


def _validate_longitude(api_errors, raw_longitude):
Expand Down
8 changes: 4 additions & 4 deletions src/pcapi/core/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,14 @@ def asynchronous_identity_document_verification(image: bytes, email: str) -> Non
)
except Exception as exception:
logger.exception("An error has occured while trying to upload image to encrypted gcp bucket: %s", exception)
raise exceptions.IdentityDocumentUploadException
raise exceptions.IdentityDocumentUploadException()

try:
verify_identity_document.delay({"image_storage_path": image_storage_path})
except Exception as exception:
logger.exception("An error has occured while trying to add cloudtask in queue: %s", exception)
delete_object(image_storage_path)
raise exceptions.CloudTaskCreationException
raise exceptions.CloudTaskCreationException()
return


Expand All @@ -780,10 +780,10 @@ def _get_identity_document_informations(image_storage_path: str) -> Tuple[str, b
if not image_blob:
# This means the image cannot be downloaded.
# It either has been treated or there is a network problem
raise exceptions.IdentityDocumentVerificationException
raise exceptions.IdentityDocumentVerificationException()
email = image_blob.metadata.get("email", "").strip()
if email == "":
raise exceptions.MissingEmailInMetadataException
raise exceptions.MissingEmailInMetadataException()
image = image_blob.download_as_bytes()

return (email, image)
Expand Down

0 comments on commit 63449d0

Please sign in to comment.