Пример #1
0
def edit_user(request):
    """
    Allows a user to edit the profile. This should be limited...
    """
    session = DBSession()
    user = get_object_or_404(User, request.matchdict.get('user'))
    form = EditUserForm(request.POST, obj=user)
    form.group.query = session.query(Group).all()
    if request.method == 'POST' and form.validate():
        group = session.query(Group).get(form.group_id.data)
        user.name = form.name.data
        user.email = form.email.data
        user.group = group
        session.merge(user)
        return HTTPFound(location=request.route_url('admin-users'))
    else:
        return {'user': user, 'form': form}
Пример #2
0
def show_meter(request):
    meter = get_object_or_404(Meter, request.matchdict.get('meter_id'))
    return {'meter': meter}