return error 409 when attempting to create duplicates
This commit is contained in:
parent
4c6d9e8fd7
commit
277e712449
1 changed files with 5 additions and 2 deletions
|
@ -262,8 +262,11 @@ class EventResource(BaseEvent):
|
||||||
cur.close()
|
cur.close()
|
||||||
db.close()
|
db.close()
|
||||||
# send back to client
|
# send back to client
|
||||||
resp.body = """{"id":"%s"}""" % (e[0])
|
if e is None:
|
||||||
resp.status = falcon.HTTP_201
|
resp.status = falcon.HTTP_409
|
||||||
|
else:
|
||||||
|
resp.body = """{"id":"%s"}""" % (e[0])
|
||||||
|
resp.status = falcon.HTTP_201
|
||||||
|
|
||||||
def on_post(self, req, resp):
|
def on_post(self, req, resp):
|
||||||
self.insert_or_update(req, resp, None, """INSERT INTO events ( events_type, events_what, events_when, events_tags, events_geo) VALUES (%s, %s, tstzrange(%s,%s,%s) , %s, %s) RETURNING events_id;""")
|
self.insert_or_update(req, resp, None, """INSERT INTO events ( events_type, events_what, events_when, events_tags, events_geo) VALUES (%s, %s, tstzrange(%s,%s,%s) , %s, %s) RETURNING events_id;""")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue