Пример #1
0
def edit_profile(request):
    profile = request.user.get_profile()
    initial = { 'first_name': profile.user.first_name, 'last_name': profile.user.last_name, 'email': profile.user.email }
    if request.method == "POST":
        form = EditProfileForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            form.save()
            return reverse_redirect('profile')
        else:
			form = EditProfileForm(initial=initial, instance=profile)
        return {'form': form,'profile':profile}
	return {'profile':profile}
Пример #2
0
def profile(request, username=None):
    form = None
    if not username:
        if request.user.is_authenticated():
            u = request.user
            if request.method == 'POST':
                form = EditProfileForm(request.POST, instance=u)
                if form.is_valid():
                    form.save()
                    return HttpResponseRedirect(reverse(profile))
            else:
                form = EditProfileForm(instance=u)
        else: raise Http404
    else:
        u = get_object_or_404(User, username__exact=username)
    return render_to_response('registration/profile.html', {'user': u, 'form': form}, context_instance = RequestContext(request))
Пример #3
0
def edit_profile(request):
    profile = request.user.get_profile()
    if not profile.department is "Human Resource Department":
        initial = {
            "first_name": profile.user.first_name,
            "last_name": profile.user.last_name,
            "email": profile.user.email,
        }
        if request.method == "POST":
            form = EditProfileForm(request.POST, request.FILES, instance=profile)
            if form.is_valid():
                form.save()
                return reverse_redirect("profile")
        else:
            form = EditProfileForm(initial=initial, instance=profile)
        return {"form": form, "profile": profile}
    return {"profile": profile}
Пример #4
0
def edit_profile(request):

    user = request.user
    form = EditProfileForm(request.POST or None, initial={'first_name': user.first_name,
                                                          'last_name': user.last_name,
                                                          'email': user.email})
    if request.method == 'POST':
        if form.is_valid():
            user.first_name = request.POST['first_name']
            user.last_name = request.POST['last_name']
            user.email = request.POST['email']
            user.save()
            return HttpResponseRedirect('%s'%(reverse('profile')))

    context = {
        "form": form
    }

    return render(request, "accounts/edit_profile.html", context)
Пример #5
0
def edit_profile(request):

	profile = request.user.get_profile()
	initial = { 'first_name': profile.user.first_name, 'last_name': profile.user.last_name, 'email': profile.user.email }
	form = EditProfileForm(initial=initial, instance=profile)
	if not profile.department.name is 'Human Resource Department':
		if request.method == "POST":
			form = EditProfileForm(request.POST, request.FILES, instance=profile)
			if form.is_valid():
				my_profile = form.save(commit=False)
				my_profile.personnel_id = request.POST['personnel_id']
				my_profile.designation = request.POST['designation']
				department = Department.objects.get(pk=request.POST['department'])
				my_profile.department = department
				my_profile.official_email = request.POST['official_email']
				my_profile.tax_status = request.POST['tax_status']
				my_profile.save()
				return reverse_redirect('profile')         
		else:
			form = EditProfileForm(initial=initial, instance=profile)
		return {'form': form,'profile':profile}
	return {'profile':profile}
Пример #6
0
def edit_profile(request):

    whichuser = request.user

    if request.method == 'POST':

        form = EditProfileForm(request.POST, request.FILES, instance=request.user)
        if form.is_valid():
            form.save()
            return redirect(profile)




    form = EditProfileForm(instance=request.user)


    args = {'whichuser': whichuser}
    args.update(csrf(request))
    args['form'] = form

    return render(request, 'editprofile.html', args)
Пример #7
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST,
                               request.FILES,
                               instance=request.user)
        if form.is_valid():
            form.save()
            return redirect(reverse('view_profile'))
    else:
        form = EditProfileForm(instance=request.user)

        return render(request, 'edit_profile.html', {'form': form})
Пример #8
0
def edit_profile(request):
    user = request.user
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=user)
        if form.is_valid():
            form.save()
            messages.add_message(request, level=20, message='مشخصات کاربری بروزرسانی شد.')
            return redirect('profile')
    else:
        form = EditProfileForm(instance=user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #9
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect('/accounts/profile')

    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #10
0
def edit_account(request):
    if request.method == "POST":
        form = EditProfileForm(request.POST, instance=request.user)
        if form.is_valid():
            form.save()
            return redirect('homepage')
        else:
            return redirect('/accounts/edit/')
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
    return render(request, 'accounts/edit_account.html', args)
Пример #11
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            messages.success(request, "User details has changed successfully!")
            return redirect(reverse('profile'))
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'edit.html', args)
Пример #12
0
def edit_profile(request):
    if request.method == "POST":
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect(reverse('accounts:view_profile'))

    else:
        form = EditProfileForm(instance=request.user)
        context = {'form': form}
        return render(request, 'accounts/edit_profile.html', context)
Пример #13
0
def edit_profile(request):
    if request.method == "POST":
        current_user = request.user
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return render(request, 'accounts/user_profile.html',
                          {"user": current_user})
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #14
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            messages.success(request, 'Your profile was updated successfully')
            return redirect('/accounts/profile')

    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #15
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect('/accounts/profile')
    else:
        form = EditProfileForm(instance=request.user)
        # Manually delete the password field since the form does not respect the fields definition in forms.py
        del form.fields['password']
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #16
0
def edit_profile(request):
    if request.user.is_admin:
        return HttpResponse('<h1>Page not found</h1>')
    else:
        data = get_object_or_404(Profile, user=request.user)
        if request.method == 'POST':
            form = EditProfileForm(request.POST, instance=data)
            if form.is_valid():
                form.save()
                return redirect('/accounts/profile')
        else:
            form = EditProfileForm(instance=data)
        return render(request, 'accounts/edit_profile.html', {'form' : form})
Пример #17
0
def edit_profile(request):

    notifications = Notification.objects.filter(user=request.user, viewed=False)

    whichuser = request.user

    if request.method == 'POST':

        form = EditProfileForm(request.POST, request.FILES, instance=request.user)
        if form.is_valid():
            form.save()
            return redirect(profile)




    form = EditProfileForm(instance=request.user)


    args = {'whichuser': whichuser, 'notifications': notifications}
    args.update(csrf(request))
    args['form'] = form

    return render(request, 'editprofile.html', args)
Пример #18
0
def edit_profile(request):
    template = 'accounts/edit_profile.html'

    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect('profile')
        else:
            return redirect('edit_profile')
    else:
        form = EditProfileForm(instance=request.user)
    return render(request, template, {'form': form})
Пример #19
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            # return redirect('list_projects')
            return redirect(reverse('accounts:view_profile'))
        return render(request, 'accounts/edit_profile.html', {'form': form})

    else:
        form = EditProfileForm(instance=request.user)

        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #20
0
def edit_profile(request):
    """User edit profile page and form to allow user's to update their details"""
    if request.method == 'POST':
        edit_form = EditProfileForm(request.POST, instance=request.user)

        if edit_form.is_valid():
            edit_form.save()
            messages.success(request,
                             "You have successfully updated your details!")
            return redirect(reverse('profile'))

    else:
        edit_form = EditProfileForm(instance=request.user)
        args = {'edit_form': edit_form}
        return render(request, "edit_profile.html", args)
Пример #21
0
def edit_profile(request):
    """ Edit Profile """

    if request.method == 'POST':

        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('accounts:profile'))

    # method get or invalid form always redirect to the same page again
    form = EditProfileForm(instance=request.user)
    args = {'form': form}
    return render(request, 'accounts/edit_profile.html', args)
Пример #22
0
def edit_profile(request):

    if request.method == 'POST':
        #form = UserChangeForm(request.POST, instance=request.user)
        form = EditProfileForm(request.POST, instance=request.user)
        # instance -
        if form.is_valid():
            form.save()
            return redirect(reverse('accounts:profile'))
    else:
        # else is for GET i.e. intialize a blank form
        #form = UserChangeForm(instance = request.user)
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #23
0
def edit_profile(request):
    #if the user submits changes
    if request.method == 'POST':
        # pass user object so it knows which object it is changing
        form = EditProfileForm(request.POST, instance=request.user)
        if form.is_valid():
            form.save()
            return redirect('/account/profile')
        else:
            return redirect('/account/profile')
    # if just get
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #24
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(
            request.POST, instance=request.user
        )  #UserChangeForm shows everything, we customized a few things

        if form.is_valid():
            form.save()
            return redirect('/accounts/profile')

    else:
        args = {}
        form = EditProfileForm(instance=request.user)
        args['form'] = form
        return render(request, 'accounts/edit_profile.html', args)
Пример #25
0
def update_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)
        profile_form = ProfileForm(request.POST, instance=request.user.userprofile)
        if form.is_valid() and profile_form.is_valid():
            form.save()
            profile_form.save()
            return redirect('/profile')
    else:
        form = EditProfileForm(instance=request.user)
        profile_form = ProfileForm(instance=request.user.userprofile)
    return render(request, 'accounts/edit_profile.html', {
        'form': form,
        'profile_form': profile_form
    })
Пример #26
0
    def post(self, request):
        uform = EditProfileForm(request.POST, instance=request.user)
        aform = EditAvatar(request.POST, request.FILES, instance=request.user)

        if uform.is_valid() and aform.is_valid():
            uform.save()
            aform.save()
            messages.success(request, f'Profile Successfully Modified')
            return redirect('view_profile')

        uform = EditProfileForm(request.POST, instance=request.user)
        aform = EditAvatar(request.POST, request.FILES, instance=request.user)
        args = {'uform': uform, 'aform': aform}

        return render(request, self.template_name, args)
Пример #27
0
def edit_profile(request):
    """"
    Edit current user profile, get instance of request user
    goto EditProfileForm inherit from ChangeForm
    """
    if request.method == "POST":
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('accounts:profile'))

    else:
        form = EditProfileForm(instance=request.user)
        return render(request, 'accounts/edit_profile.html', {'form': form})
Пример #28
0
def edit_profile(request, pk):
    """ Presents a form enabling user to edit their profile """
    user = User.objects.get(email=request.user.email, pk=pk)
    post = get_object_or_404(UserProfile, user=user) if user else None
    if request.method == "POST":
        form = EditProfileForm(request.POST, instance=request.user.userprofile)
        if form.is_valid():
            post = form.save()
            return redirect(profile, user.pk)
    else:
        form = EditProfileForm(instance=post)
    return render(request, 'edit_profile.html', {'form': form})
Пример #29
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)
        if form.is_valid():
            password_confirmation = form.cleaned_data['password_confirmation']
            if request.user.check_password(password_confirmation):
                form.save()
                return redirect('/account/profile/')
            else:
                logout(request)
                return redirect('/account/login/')

    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #30
0
def edit_profile_lp(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)
        # form2 = NewRegForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect(reverse('accounts:view_profile'))
    else:
        form = EditProfileForm(instance=request.user)
        # form2 = NewRegForm(request.POST)

        args = {
            'form': form,
            # 'form2': form2
        }
        return render(request, 'accounts/edit_profile_lp.html', args)
Пример #31
0
def edit_profile(request):
    if request.method == 'POST':
        user_form = EditUserForm(request.POST, instance=request.user)
        profile_form = EditProfileForm(request.POST,
                                       instance=request.user.profile)

        if user_form.is_valid() and profile_form.is_valid():
            user_form.save()
            profile_form.save()
            return redirect(reverse('profile'))
    else:
        user = request.user
        user_form = EditUserForm(instance=request.user)
        profile_form = EditProfileForm(instance=request.user.profile)
        args = {'user_form': user_form, 'profile_form': profile_form}
        return render(request, 'editprofile.html', args)
Пример #32
0
def edit_profile(request):
    if request.method == 'POST':
        epf = EditProfileForm(request.POST, instance=request.user)
        epm = EditProfileMore(request.POST, instance=request.user.userprofile)
        if epf.is_valid() and epm.is_valid():
            epf.save()
            epm.save()
            messages.success(request, ('Your profile was successfully update!'))
            return redirect('/account/profile')
        else:
            messages.error(request, ('Please correct the error below!'))
    else:
        epf = EditProfileForm(instance=request.user)
        epm = EditProfileMore(instance=request.user.userprofile)
        args = {'form1': epf, 'form2': epm}
        return render(request, 'accounts/edit_profile.html', args)
Пример #33
0
def edit_profile(request):
    if request.method == 'POST':
        UserForm = EditUserForm(request.POST, instance=request.user)
        ProfileForm = EditProfileForm(request.POST,
                                      instance=request.user.userprofile)
        if UserForm.is_valid() and ProfileForm.is_valid():
            UserForm.save()
            ProfileForm.save()
            return redirect('/account/profile/?p=' + request.user.username)
        else:
            return redirect('/account/profile/edit')
    else:
        UserForm = EditUserForm(instance=request.user)
        ProfileForm = EditProfileForm(instance=request.user.userprofile)
        args = {'userform': UserForm, 'profileform': ProfileForm}
        return render(request, 'accounts/edit_profile.html', args)
Пример #34
0
def edit_profile(request, part_id=None):
    if request.method == 'POST':
        usr = request.POST.get("usr")
        user_edit = User.objects.filter(id=part_id)
        for i in user_edit:
            form = EditProfileForm(request.POST, instance=i)

        if form.is_valid():
            form.save()
            return redirect(reverse('teacher:addStudent'))
    else:
        user_edit = User.objects.filter(id=part_id)
        for i in user_edit:
            form = EditProfileForm(instance=i)
            args = {'form': form, 'usr': i}
            return render(request, 'accounts/edit_profile.html', args)
Пример #35
0
def edit_profile(request):

#  POST - save filled in form
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)
        if form.is_valid:
            form.save()
            return redirect('/account/profile')
#  GET - load page initially
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit_profile.html', args)
Пример #36
0
def edit_profile(request):
	if request.method == 'POST':
		form = EditProfileForm(request.POST, instance=request.user)
		form2 = ProfileEdit(request.POST, instance=request.user.userprofile)
		if form.is_valid() and form2.is_valid():
			form.save()
			form2.save()
			return redirect(reverse('accounts:view_profile'))
		else:
			redirect('account/profile/edit')
	else:
		form = EditProfileForm(instance=request.user)
		form2 = ProfileEdit(instance=request.user)

		args = {'form':form,'form2':form2}

		return render(request,'accounts/edit_profile.html',args)
Пример #37
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)
        form1 = ProfileForm(request.POST, instance=request.user.userprofile)
        if form.is_valid() and form1.is_valid():
            form.save()
            form1.save()
            return redirect('/account/profile')

    else:
        form = EditProfileForm(instance=request.user.userprofile)
        form1 = ProfileForm(instance=request.user.userprofile)

    return render(request, 'accounts/update_profile.html', {
        'form': form,
        'form1': form1
    })