def add_pro_pic(request):
    form = ProfilePic
    if request.method == 'POST':
        form = ProfilePic(request.POST, request.FILES)
        if form.is_valid():
            user_obj = form.save(commit=False)
            user_obj.user = request.user
            user_obj.save()
            return HttpResponseRedirect(reverse('App_Login:profile'))
    return render(request,
                  'App_Login/add_pro_pic.html',
                  context={'form': form})
Ejemplo n.º 2
0
def change_pro_pic(request):
    form = ProfilePic(instance=request.user.user_profile)
    if request.method == 'POST':
        form= ProfilePic(request.POST,request.FILES,instance=request.user.user_profile)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('App_Login:profile'))
    return render(request,'App_Login/pro_pic_add.html',context={'form':form})
Ejemplo n.º 3
0
def add_pro_pic(request):
    form = ProfilePic()
    if request.method == 'POST':
        form = ProfilePic(request.POST, request.FILES)
        if form.is_valid():
            user_obj = form.save(commit=False)
            user_obj.user = request.user
            user_obj.save()
            messages.success(request, "Profile Picture Added Successfully!!")
            return HttpResponseRedirect(reverse('App_Login:profile'))
    return render(request,
                  'App_Login/pro_pic_add.html',
                  context={'form': form})
Ejemplo n.º 4
0
def user_change(request):
    current_user = request.user
    form = UserProfileChange(instance=current_user)
    profile_form = ProfilePic(instance=request.user.user_profile)
    if request.method == 'POST':
        form = UserProfileChange(request.POST, instance=current_user)
        profile_form = ProfilePic(request.POST,
                                  request.FILES,
                                  instance=request.user.user_profile)
        if form.is_valid() and profile_form.is_valid():
            user = form.save()
            profile = profile_form.save(commit=False)
            profile.user = user
            profile.save()
            form = UserProfileChange(instance=current_user)
    return render(request,
                  'App_Login/change_profile.html',
                  context={
                      'form': form,
                      'profile_form': profile_form
                  })