コード例 #1
0
ファイル: routes.py プロジェクト: rbarrette/dino
def ban_user():
    form = request.get_json()
    target = form['target']
    target_uuid = form['target_uuid']
    user_uuid = form['user_uuid']
    duration = form['duration']

    try:
        user_manager.ban_user(user_uuid, target_uuid, duration, target)
    except ValidationException as e:
        return api_response(400, message='invalid duration: %s' % str(e))
    except UnknownBanTypeException as e:
        return api_response(400, message='could not ban user: %s' % str(e))
    except Exception as e:
        logger.exception(traceback.format_exc())
        return api_response(400, message=str(e))

    try:
        user = user_manager.get_user(user_uuid)
        user['name'] = utils.b64d(user['name'])
        user['duration'] = duration
    except NoSuchUserException:
        return api_response(400, message="No such user.")

    if target == 'channel':
        user['channel'] = {
            'uuid': target_uuid,
            'name': channel_manager.name_for_uuid(target_uuid)
        }
    elif target == 'room':
        user['room'] = {
            'uuid': target_uuid,
            'name': room_manager.name_for_uuid(target_uuid)
        }
    return api_response(200, user)
コード例 #2
0
ファイル: routes.py プロジェクト: rbarrette/dino
def get_room(channel_uuid: str, room_uuid: str):
    acls = acl_manager.get_acls_room(room_uuid)
    acls_decoded = list()
    for acl in acls:
        acl['value'] = utils.b64d(acl['value'])
        acls_decoded.append(acl)

    return api_response(
        200, {
            'channel': {
                'uuid': channel_uuid,
                'name': channel_manager.name_for_uuid(channel_uuid)
            },
            'acls': acls_decoded,
            'owners': room_manager.get_owners(room_uuid),
            'moderators': room_manager.get_moderators(room_uuid)
        })
コード例 #3
0
ファイル: routes.py プロジェクト: Xlzman/dino
def users_for_room(channel_uuid, room_uuid):
    owner_form = AddOwnerForm(request.form)
    mod_form = AddModeratorForm(request.form)
    acl_form = CreateRoomAclForm(request.form)

    acls = acl_manager.get_acls_room(room_uuid)
    acls_decoded = list()
    for acl in acls:
        acl['value'] = utils.b64d(acl['value'])
        acls_decoded.append(acl)

    return render_template(
        'users_in_room.html',
        channel_uuid=channel_uuid,
        room_uuid=room_uuid,
        owner_form=owner_form,
        mod_form=mod_form,
        acl_form=acl_form,
        acls=acls_decoded,
        channel_name=channel_manager.name_for_uuid(channel_uuid),
        room_name=room_manager.name_for_uuid(room_uuid),
        owners=room_manager.get_owners(room_uuid),
        moderators=room_manager.get_moderators(room_uuid),
        users=user_manager.get_users_for_room(room_uuid))
コード例 #4
0
ファイル: routes.py プロジェクト: Xlzman/dino
def rooms_for_channel(channel_uuid):
    form = CreateRoomForm(request.form)
    acl_form = CreateChannelAclForm(request.form)
    owner_form = AddOwnerForm(request.form)
    admin_form = AddAdminForm(request.form)

    acls = acl_manager.get_acls_channel(channel_uuid)
    acls_decoded = list()
    for acl in acls:
        acl['value'] = utils.b64d(acl['value'])
        acls_decoded.append(acl)

    return render_template(
        'rooms_in_channel.html',
        form=form,
        owner_form=owner_form,
        admin_form=admin_form,
        acl_form=acl_form,
        owners=channel_manager.get_owners(channel_uuid),
        admins=channel_manager.get_admins(channel_uuid),
        acls=acls_decoded,
        channel_uuid=channel_uuid,
        channel_name=channel_manager.name_for_uuid(channel_uuid),
        rooms=room_manager.get_rooms(channel_uuid))