コード例 #1
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def invite_user(application_id):
    """
    POST: settings/application/<application_id>/members
    invite user to join the application
    """
    try:
        application_id = long(application_id)
    except:
        return abort(400)
    user = InviteUserForm(**request.json)
    if not user.validate():
        return validated_failed(**user.validated_messages())

    acs = AccountService()
    aps = ApplicationService()

    # am I owner?
    if not aps.is_my_application(application_id, True):
        return abort(403)

    # invite user
    user = acs.invite_user(user.email.data)
    if user is None:
        return abort(417)

    # add the new user to the application
    aps.add_user_to_application(user.key().id(), application_id)
    return success(201)
コード例 #2
0
def invite_user(application_id):
    """
    POST: settings/application/<application_id>/members
    invite user to join the application
    """
    try:
        application_id = long(application_id)
    except:
        return abort(400)
    user = InviteUserForm(**request.json)
    if not user.validate():
        return validated_failed(**user.validated_messages())

    acs = AccountService()
    aps = ApplicationService()

    # am I owner?
    if not aps.is_my_application(application_id, True):
        return abort(403)

    # invite user
    user = acs.invite_user(user.email.data)
    if user is None:
        return abort(417)

    # add the new user to the application
    aps.add_user_to_application(user.key().id(), application_id)
    return success(201)
コード例 #3
0
def add_application():
    """
    POST: settings/applications
    add an application
    """
    ap = ApplicationForm(**request.json)
    if not ap.validate():
        return validated_failed(**ap.validated_messages())

    aps = ApplicationService()
    aps.add_application(ap.name.data, ap.description.data)
    return success(201)
コード例 #4
0
def update_profile():
    """
    PUT: settings/profile
    update profile
    """
    profile = ProfileForm(**request.json)
    if not profile.validate():
        return validated_failed(**profile.validated_messages())

    acs = AccountService()
    acs.update_profile(profile.name.data)
    return success()
コード例 #5
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def add_application():
    """
    POST: settings/applications
    add an application
    """
    ap = ApplicationForm(**request.json)
    if not ap.validate():
        return validated_failed(**ap.validated_messages())

    aps = ApplicationService()
    aps.add_application(ap.name.data, ap.description.data)
    return success(201)
コード例 #6
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def update_profile():
    """
    PUT: settings/profile
    update profile
    """
    profile = ProfileForm(**request.json)
    if not profile.validate():
        return validated_failed(**profile.validated_messages())

    acs = AccountService()
    acs.update_profile(profile.name.data)
    return success()
コード例 #7
0
def delete_application(application_id):
    """
    DELETE: settings/applications/<application_id>
    delete the application
    """
    try:
        application_id = long(application_id)
    except Exception:
        return abort(400)

    aps = ApplicationService()
    aps.delete_application(application_id)
    return success()
コード例 #8
0
def delete_user(user_id):
    """
    DELETE: settings/users/<user_id>
    delete the user
    """
    try:
        user_id = long(user_id)
    except Exception:
        return abort(400)

    acs = AccountService()
    acs.delete_user(user_id)
    return success()
コード例 #9
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def delete_application(application_id):
    """
    DELETE: settings/applications/<application_id>
    delete the application
    """
    try:
        application_id = long(application_id)
    except Exception:
        return abort(400)

    aps = ApplicationService()
    aps.delete_application(application_id)
    return success()
コード例 #10
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def delete_user(user_id):
    """
    DELETE: settings/users/<user_id>
    delete the user
    """
    try:
        user_id = long(user_id)
    except Exception:
        return abort(400)

    acs = AccountService()
    acs.delete_user(user_id)
    return success()
コード例 #11
0
def delete_application_member(application_id, member_id):
    """
    DELETE: settings/applications/<application_id>/members/<member_id>
    delete a member in the application
    """
    try:
        application_id = long(application_id)
        member_id = long(member_id)
    except:
        return abort(400)

    aps = ApplicationService()
    aps.delete_user_from_application(member_id, application_id)
    return success()
コード例 #12
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def delete_application_member(application_id, member_id):
    """
    DELETE: settings/applications/<application_id>/members/<member_id>
    delete a member in the application
    """
    try:
        application_id = long(application_id)
        member_id = long(member_id)
    except:
        return abort(400)

    aps = ApplicationService()
    aps.delete_user_from_application(member_id, application_id)
    return success()
コード例 #13
0
def add_user():
    """
    POST: settings/users
    add an user
    """
    user = InviteUserForm(**request.json)
    if not user.validate():
        return validated_failed(**user.validated_messages())

    acs = AccountService()
    user = acs.invite_user(user.email.data)
    if user:
        return success(201)
    else:
        return abort(417)
コード例 #14
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def add_user():
    """
    POST: settings/users
    add an user
    """
    user = InviteUserForm(**request.json)
    if not user.validate():
        return validated_failed(**user.validated_messages())

    acs = AccountService()
    user = acs.invite_user(user.email.data)
    if user:
        return success(201)
    else:
        return abort(417)
コード例 #15
0
def update_application(application_id):
    """
    PUT: settings/applications/<application_id>
    update the application
    """
    # check input
    try:
        application_id = long(application_id)
    except Exception:
        return abort(400)

    ap = ApplicationForm(**request.json)
    if not ap.validate():
        return validated_failed(**ap.validated_messages())

    aps = ApplicationService()
    aps.update_application(application_id, ap.name.data, ap.description.data)
    return success()
コード例 #16
0
ファイル: settings_handler.py プロジェクト: kelp404/Victory
def update_application(application_id):
    """
    PUT: settings/applications/<application_id>
    update the application
    """
    # check input
    try:
        application_id = long(application_id)
    except Exception:
        return abort(400)

    ap = ApplicationForm(**request.json)
    if not ap.validate():
        return validated_failed(**ap.validated_messages())

    aps = ApplicationService()
    aps.update_application(application_id, ap.name.data, ap.description.data)
    return success()