Example #1
0
 def post(self, request):
     form = EditProfileForm(request.POST, instance=request.user)
     if form.is_valid():
         form.save()
         messages.success(request,
                          "Your profile has been successfully updated!")
     return render(request, self.template_name, {'form': form})
Example #2
0
def edit_profile(request):
    """
    view untuk fungsionalitas perubahan data profile
    account
    """
    if request.POST:
        old_picture = request.user.profile.picture
        form = EditProfileForm(request.POST, request.FILES,
            instance=request.user.profile)
        if form.is_valid():
            if 'picture' in request.FILES:
                from os import unlink
                if old_picture.name != 'profpic/default.jpg':
                    unlink(old_picture.path)
            form.save()
            request.user.email = form.cleaned_data['email']
            request.user.first_name = form.cleaned_data['first_name']
            request.user.last_name = form.cleaned_data['last_name']
            request.user.save()
            messages.info(request, _('Profile updated'))
            return HttpResponseRedirect(reverse('self_profile'))
    else:
        form = EditProfileForm(instance=request.user.profile,
                initial={'email': request.user.email,
                         'first_name': request.user.first_name,
                         'last_name': request.user.last_name})
    return render_to_response('accounts/edit_profile.html',
            {'form': form},
            context_instance=RequestContext(request))
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect('/apps/profile')
    else:
        form = EditProfileForm(instance=request.user)
        args = {'form': form}
        return render(request, '/apps/edit_profile.html', args)
Example #4
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user.profile)
        if form.is_valid():
            form.save()
            return redirect('accounts:view_profile', request.user.id)
    else:
        form = EditProfileForm(instance=request.user.profile)
    
    return render(request, 'accounts/edit_profile.html', {
        'form': form,
    })
Example #5
0
def edit_profile(request):
    if request.method == "POST":
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            edit_form.save()
            messages.add_message(request, messages.INFO, _("Your profile has been updated."))
            return HttpResponseRedirect(".")

    if request.method == "GET":
        edit_form = EditProfileForm(user=request.user)
    return render_to_response(
        "user/editprofile.html", context_instance=RequestContext(request, {"edit_form": edit_form})
    )
Example #6
0
    def POST(self):
        files_req = self.request.FILES
        if (files_req.get('photo', '')):
            files_req['photo'].name = self.request.user.username

        form = EditProfileForm(self.request, self.request.POST,
                               files_req, instance=self.request.user)
        if not form.is_valid():
            return self.context_response('user/profile.html', {'form': form})

        # Send an email to admins with old data
        old_user = self.request.user
        subject = I18nString(_("[%(site_name)s] %(username)s modified his data"), {
            'site_name': settings.SITE_NAME,
            'username': old_user.username
        })
        message = I18nString(_("Username %(username)s modified his profile. Old data:\n\n"
            u" - Name: %(old_name)s\n"
            u" - Last name: %(old_surnames)s\n"
            u" - Email address: %(old_email)s\n"
            u" - Address: %(old_address)s\n"
            u" - Birth date: %(old_birth_date)s\n"
            u" - Description: %(old_description)s\n\n"
            u"New data:\n\n"
            u" - Name: %(name)s\n"
            u" - Last name: %(surnames)s\n"
            u" - Email address: %(email)s\n"
            u" - Address: %(address)s\n"
            u" - Birth date: %(birth_date)s\n"
            u" - Description: %(description)s\n\n"), {
                'username': old_user.username,
                'old_name': old_user.first_name,
                'old_surnames': old_user.last_name,
                'old_email': old_user.email,
                'old_address': old_user.address,
                'old_birth_date':  old_user.birth_date,
                'old_description': old_user.description,
                'name': form.cleaned_data["first_name"],
                'surnames': form.cleaned_data["last_name"],
                'email': form.cleaned_data["email"],
                'address': form.cleaned_data["address"],
                'birth_date': form.cleaned_data["birth_date"],
                'description': form.cleaned_data["description"]
            })
        mail_owners(subject, message)
        form.save()

        self.flash(_("Profile updated: <a href=\"%s\">view your profile</a>.") %
            reverse("user-view-current"))

        return self.context_response('user/profile.html', {'form': form})
Example #7
0
def user_settings(request):
    if request.method == 'POST':
        form = EditProfileForm(request.POST, instance=request.user.drinker)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/u/%s' % request.user.username)
    else:
        form = EditProfileForm(instance=request.user.drinker)

    args = {}
    args.update(csrf(request))

    args['form'] = form

    return render_to_response('settings.html', args, context_instance=RequestContext(request))
Example #8
0
def edit_profile(request):
    if request.method == 'POST':
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            edit_form.save()
            messages.add_message(request, messages.INFO,
                                 _('Your profile has been updated.'))
            return HttpResponseRedirect('.')

    if request.method == 'GET':
        edit_form = EditProfileForm(user=request.user)
    return render_to_response('user/editprofile.html',
                              context_instance=RequestContext(
                                  request, {
                                      'edit_form': edit_form,
                                  }))
Example #9
0
def edit_profile(request):
    if request.method == 'POST':
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            edit_form.save()
            m = request.user.message_set.create()
            m.message = 'Your profile has been updated.'
            m.save()
            return HttpResponseRedirect('.')

    if request.method == 'GET':
        edit_form = EditProfileForm(user = request.user)    
    return render_to_response('user/editprofile.html',
        context_instance=RequestContext(request,
            {'edit_form': edit_form,
            }))
Example #10
0
def edit_profile(request, username):
    user = get_object_or_404(User, username=username)
    member = user.get_profile()

    if request.method == 'POST':
        profile_form = EditProfileForm(request.POST, request.FILES)
        if profile_form.is_valid():
            profile_form.save()
            return HttpResponseRedirect(
                reverse('members.views.user',
                        kwargs={'username': user.username}))
    else:
        profile_form = EditProfileForm(
            initial={
                'member_id': member.id,
                'phone': member.phone,
                'phone2': member.phone2,
                'email2': member.email2,
                'address1': member.address1,
                'address2': member.address2,
                'city': member.city,
                'state': member.state,
                'zipcode': member.zipcode,
                'company_name': member.company_name,
                'url_personal': member.url_personal,
                'url_professional': member.url_professional,
                'url_facebook': member.url_facebook,
                'url_twitter': member.url_twitter,
                'url_biznik': member.url_biznik,
                'url_linkedin': member.url_linkedin,
                'url_aboutme': member.url_aboutme,
                'url_github': member.url_github,
                'gender': member.gender,
                'howHeard': member.howHeard,
                'industry': member.industry,
                'neighborhood': member.neighborhood,
                'has_kids': member.has_kids,
                'self_employed': member.self_employed
            })

    return render_to_response('members/edit_profile.html', {
        'user': user,
        'profile_form': profile_form
    },
                              context_instance=RequestContext(request))
Example #11
0
def edit_profile(request, username):
	user = get_object_or_404(User, username=username)
	member = user.get_profile()

	if request.method == 'POST':
		profile_form = EditProfileForm(request.POST, request.FILES)
		if profile_form.is_valid():
			profile_form.save()
			return HttpResponseRedirect(reverse('members.views.user', kwargs={'username':user.username}))
	else:
		profile_form = EditProfileForm(initial={'member_id':member.id, 'phone':member.phone, 'phone2':member.phone2, 'email2':member.email2,
			'address1':member.address1, 'address2':member.address2, 'city':member.city, 'state':member.state, 'zipcode':member.zipcode,
			'company_name':member.company_name, 'url_personal':member.url_personal, 'url_professional':member.url_professional, 
			'url_facebook':member.url_facebook, 'url_twitter':member.url_twitter, 'url_biznik':member.url_biznik, 
			'url_linkedin':member.url_linkedin, 'url_loosecubes':member.url_loosecubes, 'gender':member.gender, 'howHeard':member.howHeard,
			'industry':member.industry, 'neighborhood':member.neighborhood, 'has_kids':member.has_kids, 'self_employed':member.self_employed})

	return render_to_response('members/edit_profile.html',{'user':user, 'profile_form':profile_form}, context_instance=RequestContext(request))
Example #12
0
def edit(request):
    profile = UserProfile.objects.get_or_create(user=request.user)[0]
    if request.method == 'POST':
        form = EditProfileForm(request.POST, request.FILES, instance=profile)

        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/profile/my/')
        else:
            form = EditProfileForm(request.POST, request.FILES, instance=profile)
            return render(request, 'profile/edit.html', {'form': form})

    else:
        profile.birth_date = profile.birth_date.strftime("%m/%d/%Y") if profile.birth_date else profile.birth_date
        form = EditProfileForm(instance=profile)
        return render(request, 'profile/edit.html',
                      {'form': form,
                       'page_title': 'profile/edit',
                       'sidebar_item': 'view-profile'})
Example #13
0
def edit_profile(request):
    """Edit profile view."""
    user = User.objects.get(pk=request.user.id)
    if request.method == 'POST':
        prof_form = EditProfileForm(request.POST, instance=user.profile)
        usr_form = EditUserForm(request.POST, instance=user)
        if prof_form.is_valid() and usr_form.is_valid():
            prof_form.save()
            usr_form.save()
            return redirect("/accounts/profile")
    elif request.method == 'GET':
        profile_edit = EditProfileForm(instance=request.user.profile)
        user_edit = EditUserForm(instance=request.user)
        return render(request,
                      'profile_edit.html',
                      context={
                          'profile_edit': profile_edit,
                          'user_edit': user_edit
                      })
Example #14
0
def edit_profile(request):
    if request.method == 'POST':
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            user = edit_form.save()
            m = request.user.message_set.create()
            m.message = 'Your profile has been updated.'
            m.save()
            
            return HttpResponseRedirect('.')
    if request.method == 'GET':
        edit_form = EditProfileForm(user = request.user)
    payload = {'edit_form':edit_form}
    return render_to_response('accounts/editprofile.html', payload, RequestContext(request))
Example #15
0
def edit_profile(request):
    if request.method == "POST":
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            user = edit_form.save()
            m = request.user.message_set.create()
            m.message = "Your profile has been updated."
            m.save()
            return HttpResponseRedirect(".")

    if request.method == "GET":
        edit_form = EditProfileForm(user=request.user)
    payload = {"edit_form": edit_form}
    return render_to_response(
        "user/editprofile.html", context_instance=RequestContext(request, {"edit_form": edit_form})
    )
Example #16
0
                'old_name': old_user.first_name,
                'old_surnames': old_user.last_name,
                'old_email': old_user.email,
                'old_address': old_user.address,
                'old_birth_date':  old_user.birth_date,
                'old_description': old_user.description,
                'name': form.cleaned_data["first_name"],
                'surnames': form.cleaned_data["last_name"],
                'email': form.cleaned_data["email"],
                'address': form.cleaned_data["address"],
                'birth_date': form.cleaned_data["birth_date"],
                'description': form.cleaned_data["description"]
            })
        mail_owners(subject, message)
        form.save()

<<<<<<< HEAD
        self.flash(_(u"Profil je posodobljen. <a href=\"%s\">Preveri podatke</a>.") %
=======
        self.flash(_("Profile updated: <a href=\"%s\">view your profile</a>.") %
>>>>>>> 2db144ba2c6c34a8f17f795a1186a524059b1aa6
            reverse("user-view-current"))

        return self.context_response('user/profile.html', {'form': form})


class Preferences(ViewClass):
    @login_required
    def GET(self):
        return self.context_response('user/preferences.html',
            {'current_tab': 'user-preferences'})
Example #17
0
 def post(self, request):
     form = EditProfileForm(request.POST, instance=request.user)
     if form.is_valid():
         form.save()
         messages.info(request,"Your profile has been successfully updated!")
     return render(request, self.template_name, {'form': form})