Beispiel #1
0
def profile_edit(request, template='accounts/profile_edit.html', form=UserProfileForm):
    if request.method == "POST":
	form = form(request.POST, request.FILES)
	if form.is_valid():
	    form.save()
	    return redirect('accounts.views.profile_edit')
    else:
	form = form(initial={
	    'user': request.user.id, 
	    'first_name': request.user.first_name,
	    'last_name': request.user.last_name,
	    'about': request.user.profile.about,
	    'skills': request.user.profile.skills,
	    'experience': request.user.profile.experience,
	    'phone_number': request.user.profile.phone_number,
	    'location': request.user.profile.location,
	    'slug': request.user.profile.slug
	    })

    return render_to_response(template, {
	    'form': form,
	    'site': Site.objects.get_current().domain,
	    'age': calculate_age(request.user.profile.birthday),
	    'profile': request.user.get_profile(),
	}, context_instance=RequestContext(request))
Beispiel #2
0
    def get_context_data(self, **kwargs):
	obj = super(ProfileDetailView, self).get_object()
	context = super(ProfileDetailView, self).get_context_data(**kwargs)
	context['age'] = calculate_age(obj.birthday)
	context['site'] = Site.objects.get_current().domain
	return context