Commit 29e63ea1 authored by Sébastien Morele's avatar Sébastien Morele
Browse files

quick fixes

parent 6ffd8dfe
......@@ -3,7 +3,7 @@ import json
import sqlite3 as lite
import sys
class InterventionsRessource(object):
class InterventionsCollection(object):
def __init__(self):
try:
self.con = lite.connect("interventions.db")
......@@ -16,9 +16,8 @@ class InterventionsRessource(object):
with self.con:
self.cur = self.con.cursor()
self.cur.execute('SELECT * FROM Interventions;')
data = self.cur.fetchall()
for intervention in data:
interventions.append(intervention)
interventions = self.cur.fetchall()
resp.status = falcon.HTTP_200
resp.body = json.dumps(interventions)
......@@ -29,8 +28,8 @@ class InterventionsRessource(object):
description = data['description']
with self.con:
self.cur = self.con.cursor()
self.con.execute('INSERT INTO Interventions (title, description) VALUES ("{}", "{}")'.format(title, description))
self.cur = self.con.cursor()
self.con.execute('INSERT INTO Interventions (title, description) VALUES ("%s", "%s")' % (title, description))
resp.body = data['title']
resp.status = falcon.HTTP_200
......@@ -69,8 +68,8 @@ class InterventionRessource(object):
description = data['description']
with self.con:
self.cur = self.con.cursor()
self.cur.execute('UPDATE Interventions SET title = "{}", description = "{}" WHERE id={}'.format(title, description, intervention_id))
self.cur = self.con.cursor()
self.cur.execute('UPDATE Interventions SET title = "%s", description = "%s" WHERE id = "%s"' % (title, description, intervention_id))
resp.body = data['title']
resp.status = falcon.HTTP_200
......@@ -78,8 +77,8 @@ class InterventionRessource(object):
api = falcon.API()
interventions = InterventionsRessource()
api.add_route('/interventions', interventions)
interventionsCollection = InterventionsCollection()
api.add_route('/interventions', interventionsCollection)
intervention = InterventionRessource()
api.add_route('/interventions/{intervention_id}', intervention)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment