def profile_edit_view(request): """returns current user information. On POST collects all information fromt the page and edits the user and criteria accordingly. """ username = request.authenticated_userid user = User.lookup_by_attribute(username=username)[0] criteria = Criteria.lookup_by_attribute(user=user)[0] if request.method == 'POST': User.edit(id=user.id, username=username, firstname=request.params.get('first_name'), lastname=request.params.get('last_name'), restaurants=request.params.get('favorite_restaurants'), food=request.params.get('favorite_food') ) Criteria.edit(id=criteria.id, location=request.params.getall('location'), taste=request.params.getall('taste'), diet=request.params.getall('diet'), cost=request.params.getall('cost'), age=request.params.getall('age') ) headers = remember(request, username) return HTTPFound(request.route_url( 'profile_detail', username=username ), headers=headers) profile = {} profile['criteria'] = criteria profile['username'] = username profile['user'] = user return profile
def group_edit_view(request): """returns current group information for editing and then collects all information that has been added by the user whether new or existing and edits the existing entries. """ username = request.authenticated_userid group = Group.lookup_by_attribute(name=request.matchdict['group_name'])[0] criteria = Criteria.lookup_by_attribute(group=group)[0] if request.method == 'POST': criteria = Criteria.edit(location=request.params.getall('location'), taste=request.params.getall('taste'), diet=request.params.getall('diet'), cost=request.params.getall('cost'), age=request.params.getall('age'), id=criteria.id) group = Group.edit(name=request.params.get('name'), description=request.params.get('description'), id=group.id) return HTTPFound(request.route_url('group_detail', group_name=group.name)) profile = {} profile['criteria'] = criteria profile['group'] = group profile['username'] = username return profile