Exemplo n.º 1
0
def update_userprofile(request, user_id):
    profile = get_object_or_404(UserProfile, user__id=user_id)
    if request.method == "GET":
        profile_form = JudoUserProfileForm(instance=profile)
    if request.method == "POST":
        profile_form = JudoUserProfileForm(request.POST, instance=profile)
        if profile_form.is_valid():
            profile = profile_form.save()
    context = RequestContext(request, {"profile": profile, "profile_form": profile_form})
    return render('checkin/update_user_profile.html', context)
Exemplo n.º 2
0
def create_userprofile(request, user_id):
    try:
        profile = UserProfile.objects.get(user__id=user_id)
        return redirect('update_userprofile', user_id=user_id)
    except Exception as e:
        print e
        user = get_object_or_404(User, id=user_id)
        if request.method == "GET":
            user_profile_form = JudoUserProfileForm(initial={"user": user})
        else:
            user_profile_form = JudoUserProfileForm(request.POST)
            if user_profile_form.is_valid():
                user_profile = user_profile_form.save()
        context = RequestContext(request, {'profile_form': user_profile_form, "person": user})
        return render('checkin/create_user_profile.html', context)