Beispiel #1
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)
Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #5
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)
Beispiel #6
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()
Beispiel #7
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)
Beispiel #8
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)
Beispiel #9
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()
Beispiel #10
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()