예제 #1
0
def user_profile_edit(request):

    if request.method == 'POST':
        u_fm = EditUserForm(request.POST, request.FILES, instance=request.user)
        if u_fm.is_valid():
            u_fm.save()
            messages.success(request, "Profile Updated Successfully !!!")
            return redirect('profile')
    else:
        u_fm = EditUserForm(instance=request.user)
    return render(request, 'account/profile/editprofile.html',
                  {'u_form': u_fm})
예제 #2
0
파일: views.py 프로젝트: akamad/bolt
def edit(request):
    if request.method =="POST":
        form = EditUserForm(request.POST,instance = request.user)
        if form.is_valid():
            user = form.save(instance = request.user)
            return HttpResponseRedirect('/home/')
    else:
        form = EditUserForm(instance = request.user )
    return render(request,'account/edit.html',{'form':form})  
예제 #3
0
def edit(request):
	if request.method == 'POST':
		user_form = EditUserForm(instance=request.user, data=request.POST)
		profile_form = ProfileEditForm(
				instance=request.user.profile,
				data=request.POST,
				files=request.FILES
			)
		if user_form.is_valid and profile_form.is_valid:
			user_form.save()
			profile_form.save()
			messages.success(request, 'Profile updated Successfully!')
		else:
			messages.error(request, 'Error Updating your profile!')
	else:
		user_form = EditUserForm(instance=request.user)
		profile_form = ProfileEditForm(instance=request.user.profile)

	return render(request, 'account/edit.html', {'user_form': user_form, 'profile_form': profile_form})
예제 #4
0
def settings_view(request):
    if request.method == 'POST':
        form = EditUserForm(request.POST, instance=request.user)
        student_form = EditStudentForm(request.POST,
                                       request.FILES,
                                       instance=request.user.student)
        if form.is_valid() and student_form.is_valid():
            user_form = form.save()
            student = student_form.save(commit=False)
            student.user = user_form
            student.save()
            return redirect('account:settings')

    student_form = EditStudentForm(instance=request.user.student)
    form = EditUserForm(request.POST, instance=request.user)
    student_form.fields['studij'].widget.attrs = {'class': 'form-control'}
    context = {
        'student_form': student_form,
        'form': form,
    }

    return render(request, "account/settings.html", context)