Messin with some other stuff
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from sqlite3 import Connection, Cursor
|
||||
from database import SmartCursor
|
||||
|
||||
import random
|
||||
|
||||
class GameTable:
|
||||
_game_table_id: int
|
||||
@@ -39,6 +39,8 @@ class GameTable:
|
||||
|
||||
def commit(self, cursor):
|
||||
if not self._created:
|
||||
if self._game_table_id == 0:
|
||||
self._game_table_id = random.randint(1, 999999999)
|
||||
cursor.execute(
|
||||
"""INSERT INTO game_tables
|
||||
(game_table_id, game_table_name, game_table_link, active, docker_id)
|
||||
@@ -67,7 +69,7 @@ class GameTable:
|
||||
self._game_table_id,
|
||||
),
|
||||
)
|
||||
self._updated = False
|
||||
self._updated = True
|
||||
return
|
||||
|
||||
@property
|
||||
|
||||
23
src/main.py
23
src/main.py
@@ -3,6 +3,7 @@ import sqlite3
|
||||
from game_tables import GameService, GameTable
|
||||
from key_tables import KeyService, KeyTable
|
||||
import container_managment
|
||||
from database import SmartCursor
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -48,6 +49,28 @@ def get_tables():
|
||||
return jsonify([table.toJson() for table in tables])
|
||||
|
||||
|
||||
@app.route("/api/tables", methods=["POST"])
|
||||
def create_table():
|
||||
app.logger.info(request.get_json())
|
||||
app.logger.info(request.get_json()["table_name"])
|
||||
db = get_db()
|
||||
with SmartCursor(connection=db) as smartCursor:
|
||||
table = GameTable(
|
||||
game_table_id=0,
|
||||
game_table_name=request.get_json()["table_name"],
|
||||
game_table_link=request.get_json()["table_link"],
|
||||
active=False,
|
||||
docker_id=None,
|
||||
)
|
||||
app.logger.info(table._created)
|
||||
app.logger.info(table._updated)
|
||||
table.commit(smartCursor)
|
||||
app.logger.info(table._created)
|
||||
app.logger.info(table._updated)
|
||||
db.commit()
|
||||
return jsonify({}), 200
|
||||
|
||||
|
||||
@app.route("/api/tables/<table_id>")
|
||||
def get_table(table_id):
|
||||
gameService = GameService(get_db())
|
||||
|
||||
Reference in New Issue
Block a user