Beispiel #1
0
def show_editprofile_page(request):
    if request.method == 'POST':
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            user = edit_form.save()
            request.user.message_set.create(message='Ваши данные обновлены')
            return HttpResponseRedirect('.')
    if request.method == 'GET':
        edit_form = EditProfileForm(user = request.user)
        
    template_context = {'form':edit_form}
    return render_to_response('authorization/edit_profile.html', template_context, RequestContext(request))
Beispiel #2
0
def profile_edit(request):
    if request.method == 'POST':
        #        import ipdb; ipdb.set_trace()
        profile = request.user.get_profile()
        prof_edit_form = EditProfileForm(request.POST,
                                         request.FILES,
                                         instance=profile)
        if prof_edit_form.is_valid():
            #            profile = Profile(name = prof_edit_form.cleaned_data['name'],
            #                              birth_year = prof_edit_form.cleaned_data['birth_year'],
            #                              sex = prof_edit_form.cleaned_data['sex'],
            #                              email = prof_edit_form.cleaned_data['email'],
            #                              sity = prof_edit_form.cleaned_data['sity'],
            #                              image_profile = prof_edit_form.cleaned_data['image_profile'],
            #                              )
            #            profile.save()
            prof_edit_form.save()
            #            import ipdb; ipdb.set_trace()
            return HttpResponseRedirect('/profile/')
    else:
        prof_edit_form = EditProfileForm()
    template = 'profile_edit.html'
    context = {
        'prof_edit_form': prof_edit_form,
    }
    return render_to_response(template,
                              context,
                              context_instance=RequestContext(
                                  request, processors=[custom_proc]))
Beispiel #3
0
def profile_edit(request):
    if request.method == 'POST':
#        import ipdb; ipdb.set_trace()
        profile = request.user.get_profile()
        prof_edit_form = EditProfileForm(request.POST, request.FILES, instance=profile)
        if prof_edit_form.is_valid():
#            profile = Profile(name = prof_edit_form.cleaned_data['name'],
#                              birth_year = prof_edit_form.cleaned_data['birth_year'],
#                              sex = prof_edit_form.cleaned_data['sex'],
#                              email = prof_edit_form.cleaned_data['email'],
#                              sity = prof_edit_form.cleaned_data['sity'],
#                              image_profile = prof_edit_form.cleaned_data['image_profile'],
#                              )
#            profile.save()
            prof_edit_form.save()
#            import ipdb; ipdb.set_trace()
            return HttpResponseRedirect('/profile/')
    else:
        prof_edit_form = EditProfileForm()
    template = 'profile_edit.html'
    context = {'prof_edit_form':prof_edit_form,}    
    return render_to_response(template, context,
                context_instance=RequestContext(request, processors=[custom_proc]))
Beispiel #4
0
def show_editprofile_page(request):
    if request.method == 'POST':
        edit_form = EditProfileForm(user=request.user, data=request.POST)
        if edit_form.is_valid():
            user = edit_form.save()
            request.user.message_set.create(message='Ваши данные обновлены')
            return HttpResponseRedirect('.')
    if request.method == 'GET':
        edit_form = EditProfileForm(user=request.user)

    template_context = {'form': edit_form}
    return render_to_response('authorization/edit_profile.html',
                              template_context, RequestContext(request))