Check whether the module already exists in the database

Signed-off-by: Petr Šabata <contyk@redhat.com>
This commit is contained in:
Petr Šabata
2016-07-08 14:29:42 +02:00
parent 2ff0c163d3
commit 2b62d67387
2 changed files with 4 additions and 0 deletions

View File

@@ -124,6 +124,7 @@ Possible response codes are for various requests include:
- HTTP 403 Forbidden - The SCM URL is not pointing to a whitelisted SCM server.
- HTTP 404 Not Found - The requested URL has no handler associated with it or
the requested resource doesn't exist.
- HTTP 409 Conflict - The submitted module's NVR already exists.
- HTTP 422 Unprocessable Entity - The submitted modulemd file is not valid or
the module components cannot be retrieved
- HTTP 500 Internal Server Error - An unknown error occured.

View File

@@ -99,6 +99,9 @@ def submit_build():
mmd.loads(yaml)
except:
return "Invalid modulemd", 422
if db.session.query(rida.database.Module).filter_by(name=mmd.name,
version=mmd.version, release=mmd.release).first():
return "Module already exists", 409
module = rida.database.Module(name=mmd.name, version=mmd.version,
release=mmd.release, state="init", modulemd=yaml)
db.session.add(module)