Exemplo n.º 1
0
def invite_user(request):
    form = UserForm(name='invite', **json.loads(request.body))
    if not form.validate():
        raise Http400

    user = UserModel.invite_user(request, form.email.data)
    return JsonResponse(user)
Exemplo n.º 2
0
def update_user(request, user_id):
    user_id = long(user_id)
    form = UserForm(**json.loads(request.body))
    if not form.validate():
        raise Http400
    user = UserModel.get_by_id(user_id)
    if user is None:
        raise Http404
    user.name = form.name.data
    user.permission = form.permission.data
    user.put()
    return JsonResponse(user)
Exemplo n.º 3
0
def add_project_member(request, project_id):
    form = UserForm(name='invite', **json.loads(request.body))
    if not form.validate():
        raise Http400
    project = ProjectModel.get_by_id(long(project_id))
    if project is None:
        raise Http404
    if request.user.permission != UserPermission.root and\
                    request.user.key().id() not in project.root_ids:
        raise Http403
    user = UserModel.invite_user(request, form.email.data)
    project.member_ids.append(user.key().id())
    project.put()
    return JsonResponse(user)
Exemplo n.º 4
0
def add_application_member(request, application_id):
    form = UserForm(name='invite', **json.loads(request.body))
    if not form.validate():
        raise Http400
    application = ApplicationModel.get_by_id(long(application_id))
    if application is None:
        raise Http404
    if request.user.permission != UserPermission.root and\
                    request.user.key().id() not in application.root_ids:
        raise Http403
    user = UserModel.invite_user(request, form.email.data)
    application.member_ids.append(user.key().id())
    application.put()
    return JsonResponse(user)