Example #1
0
File: views.py Project: 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})  
Example #2
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})
Example #3
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)