Пример #1
0
async def delete_note(sid, uuid):
    pr: PlayerRoom = game_state.get(sid)

    note = Note.get_or_none(uuid=uuid)

    if not note:
        logger.warning(
            f"{pr.player.name} tried to remove non-existant note with id: '{uuid}'"
        )
        return

    note.delete_instance()
Пример #2
0
async def delete_note(sid, uuid):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    note = Note.get_or_none(uuid=data["uuid"])

    if not note:
        logger.warning(
            f"{user.name} tried to remove non-existant note with id: '{uuid}'")
        return

    note.delete_instance()
Пример #3
0
async def new_note(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    if Note.get_or_none(uuid=data["uuid"]):
        logger.warning(
            f"{user.name} tried to overwrite existing note with id: '{data['uuid']}'"
        )
        return

    Note.create(uuid=data["uuid"],
                title=data["title"],
                text=data["text"],
                user=user,
                room=room)
Пример #4
0
async def new_note(sid: str, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    if Note.get_or_none(uuid=data["uuid"]):
        logger.warning(
            f"{pr.player.name} tried to overwrite existing note with id: '{data['uuid']}'"
        )
        return

    Note.create(
        uuid=data["uuid"],
        title=data["title"],
        text=data["text"],
        user=pr.player,
        room=pr.room,
        location=pr.active_location,
    )
Пример #5
0
async def update_note(sid: str, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    note = Note.get_or_none(uuid=data["uuid"])

    if not note:
        logger.warning(
            f"{pr.player.name} tried to update non-existant note with id: '{data['uuid']}'"
        )
        return

    if note.user != pr.player:
        logger.warn(f"{pr.player.name} tried to update note not belonging to him/her.")
    else:
        with db.atomic():
            note.title = data["title"]
            note.text = data["text"]
            note.save()
Пример #6
0
async def update_note(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    note = Note.get_or_none(uuid=data["uuid"])

    if not note:
        logger.warning(
            f"{user.name} tried to update non-existant note with id: '{data['uuid']}'"
        )
        return

    if note.user != user:
        logger.warn(f"{user.name} tried to update note not belonging to him/her.")
    else:
        with db.atomic():
            note.title = data["title"]
            note.text = data["text"]
            note.save()