Exemplo n.º 1
0
def edit_address(request, username, template_name='people/edit_address.html'):
    from forms import EditAddressForm

    user = request.user

    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403

    form = EditAddressForm(request.POST or None, user=user)

    if form.is_valid():
        for key, value in form.cleaned_data.iteritems():
            setattr(user, key, value)
            user.put()
        return HttpResponseRedirect(
            reverse('member-profile', kwargs={'username': user.username}))

    ctx = {
        'form': form,
        'profile': user,
        'active': 'edit',
    }
    return render(request,
                  template_name,
                  ctx,
                  context_instance=RequestContext(request))
Exemplo n.º 2
0
def edit_address(request, username, template_name='people/edit_address.html'):
    from forms import EditAddressForm

    user = User.get_by_auth_id('own:%s' % username)

    if user == None:
        raise Http404("User not found")

    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403

    form = EditAddressForm(request.POST or None, user=user)

    if form.is_valid():
        for key, value in form.cleaned_data.iteritems():
            setattr(user,key,value)
            user.put()
        return HttpResponseRedirect(
            reverse('member-profile',
                kwargs={'username':request.user.username}
            )
        )
    

    return render_to_response(template_name, 
        {'form':form},
        context_instance=RequestContext(request))
Exemplo n.º 3
0
def edit_address(request, username, template_name='people/edit_address.html'):
    from forms import EditAddressForm

    user = request.user

    if user.key != request.user.key:
        http403 = HttpResponse("This ain't you!")
        http403.status = 403
        return http403

    form = EditAddressForm(request.POST or None, user=user)

    if form.is_valid():
        for key, value in form.cleaned_data.iteritems():
            setattr(user, key, value)
            user.put()
        return HttpResponseRedirect(
            reverse('member-profile', kwargs={'username': user.username})
        )

    ctx = {
        'form': form,
        'profile': user,
        'active': 'edit',
    }
    return render(request, template_name, ctx,
                  context_instance=RequestContext(request))