rm db / updates main.py rooms.py
This commit is contained in:
+34
-2
@@ -3,7 +3,7 @@ from pydantic import BaseModel
|
||||
|
||||
from database import fetch_all, fetch_one
|
||||
from auth import create_user, verify_user, create_token, get_current_user
|
||||
from rooms import create_room, search_room, accept_room
|
||||
from rooms import create_room, search_room, accept_room, get_rooms, delete_room, get_room
|
||||
from permissions import has_role
|
||||
from events import create_event, get_user_events, check_event_threshold
|
||||
|
||||
@@ -18,6 +18,9 @@ class Login(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
class GetRooms(BaseModel):
|
||||
user_id: str
|
||||
|
||||
|
||||
class UserCreate(BaseModel):
|
||||
username: str
|
||||
@@ -191,7 +194,7 @@ def api_create_room(
|
||||
except sqlite3.IntegrityError:
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail="invite_code already exists"
|
||||
detail="invite_code or roomname already exists"
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -356,6 +359,35 @@ def respond_event(
|
||||
"going": count_confirmations(event_id)
|
||||
}
|
||||
|
||||
@app.get("/part_of_rooms")
|
||||
def get_the_rooms(
|
||||
user_id: int = Depends(get_current_user)
|
||||
):
|
||||
rooms = get_rooms(user_id)
|
||||
|
||||
return {
|
||||
"rooms": [dict(room) for room in rooms]
|
||||
}
|
||||
|
||||
@app.get("/rooms/{room_id}")
|
||||
def api_get_room(
|
||||
room_id: int,
|
||||
user_id: int = Depends(get_current_user)
|
||||
):
|
||||
|
||||
room = get_room(
|
||||
room_id,
|
||||
user_id
|
||||
)
|
||||
|
||||
if room is None:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail="room not found or no permission"
|
||||
)
|
||||
|
||||
return room
|
||||
|
||||
print()
|
||||
print("YOU CAN NOT START THE SERVER WITH PYTHON")
|
||||
print("start with:")
|
||||
|
||||
Reference in New Issue
Block a user