serve gamerooms index
This commit is contained in:
parent
254655eed4
commit
e6fa8a7e31
2 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint, request, jsonify, session
|
||||
from models.User import User, user_schema, users_schema
|
||||
from models.GameRoom import GameRoom
|
||||
from models.GameRoom import GameRoom, rooms_schema, room_schema
|
||||
from database import db
|
||||
from ..decorators import jwt_required
|
||||
|
||||
|
@ -12,7 +12,8 @@ def get_room():
|
|||
|
||||
@api_rooms.route('/', methods=['GET'])
|
||||
def get_rooms():
|
||||
response = {"status" : "success"}
|
||||
rooms = GameRoom.query.all()
|
||||
response = rooms_schema.dumps(rooms)
|
||||
return jsonify(response)
|
||||
|
||||
# protected route
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from app import db, ma
|
||||
from marshmallow import fields
|
||||
# TODO User >---< GameRoom
|
||||
|
||||
# ! Game Room >-< Users join table
|
||||
|
@ -40,3 +41,21 @@ class GameRoom(db.Model):
|
|||
self.description = description
|
||||
self.private = private
|
||||
self.language = language
|
||||
|
||||
class LanguageSchema(ma.ModelSchema):
|
||||
id = fields.Int()
|
||||
name = fields.Str()
|
||||
iso = fields.Str()
|
||||
|
||||
language_schema = LanguageSchema()
|
||||
|
||||
class RoomSchema(ma.ModelSchema):
|
||||
id = fields.Int()
|
||||
name = fields.Str()
|
||||
description = fields.Str()
|
||||
private = fields.Bool()
|
||||
language = fields.Nested(LanguageSchema)
|
||||
|
||||
|
||||
room_schema = RoomSchema()
|
||||
rooms_schema = RoomSchema(many=True)
|
Loading…
Reference in a new issue