コード例 #1
0
ファイル: views.py プロジェクト: genxstylez/Empor-Fashion
def profile(request):
    profile = UserProfile.objects.get(user=request.user)
    if request.method == 'POST':
        form = ProfileForm(request.POST, instance=profile)
        if form.is_valid():
            profile = form.save(commit=False)
            profile.post_code = request.POST['zipcode']
            profile.county = request.POST['county']
            profile.district = request.POST['district']
            profile.save()

    form = ProfileForm(instance=profile)
    return render(request, 'member/profile.html', {'form': form})
コード例 #2
0
ファイル: views.py プロジェクト: brentcappello/imagesden
def profileedit(request):
    instance_a = get_object_or_404(MemberProfile, user=request.user)
    instance_b = get_object_or_404(User, pk=request.user.id)

    a = ProfileForm(request.POST or None, instance=instance_a)
    b = UserForm(request.POST or None, instance=instance_b)

    if a.is_valid() and b.is_valid():
        a.save() and b.save()
        return HttpResponseRedirect('/dashboard/account/')


    return render(request, 'member/profile-edit.html', {
        'form': a,
        'forms': b,
        })
コード例 #3
0
def profileedit(request):
    instance_a = get_object_or_404(MemberProfile, user=request.user)
    instance_b = get_object_or_404(User, pk=request.user.id)

    a = ProfileForm(request.POST or None, instance=instance_a)
    b = UserForm(request.POST or None, instance=instance_b)

    if a.is_valid() and b.is_valid():
        a.save() and b.save()
        return HttpResponseRedirect('/dashboard/account/')


    return render(request, 'dashboard/profile-edit.html', {
        'form': a,
        'forms': b,
        })
コード例 #4
0
def personal(request):
    """
    Personal data of the user profile
    """
    profile, created = Profile.objects.get_or_create(user=request.user)

    if request.method == "POST":
        old_profile = copy.copy(profile)
        form = ProfileForm(request.POST, instance=profile)
        if form.is_valid():
            form.save()
            messages.success(request, _("Your profile information has been updated successfully."), fail_silently=True)
            signal_responses = signals.post_signal.send(sender=personal, request=request, form=form, extra={'old_profile':old_profile})
            last_response = signals.last_response(signal_responses)
            if last_response:
                return last_response
    else:
        form = ProfileForm(instance=profile)

    template = "member/profile/personal.html"
    data = { 'section': 'personal', 'GOOGLE_MAPS_API_KEY': GOOGLE_MAPS_API_KEY,
             'form': form, }
    signals.context_signal.send(sender=personal, request=request, context=data)
    return render_to_response(template, data, context_instance=RequestContext(request))
コード例 #5
0
def profile_update(request):
    user = request.user
    if not user.is_authenticated():
        return redirect('member:login')
    if request.method == 'POST':
        form = ProfileForm(request.POST, request.FILES)
        form.is_valid()
        form.update(user)
        return redirect('member:profile')
    else:
        form = ProfileForm(initial={
            'nickname': user.nickname,
            'introduction': user.introduction,
        })
    context = {
        'form': form,
    }
    return render(request, 'member/profile_update.html', context)
コード例 #6
0
def personal(request):
    """
    Personal data of the user profile
    """
    profile, created = Profile.objects.get_or_create(user=request.user)

    if request.method == "POST":
        old_profile = copy.copy(profile)
        form = ProfileForm(request.POST, instance=profile)
        if form.is_valid():
            form.save()
            messages.success(
                request,
                _("Your profile information has been updated successfully."),
                fail_silently=True)
            signal_responses = signals.post_signal.send(
                sender=personal,
                request=request,
                form=form,
                extra={'old_profile': old_profile})
            last_response = signals.last_response(signal_responses)
            if last_response:
                return last_response
    else:
        form = ProfileForm(instance=profile)

    template = "member/profile/personal.html"
    data = {
        'section': 'personal',
        'GOOGLE_MAPS_API_KEY': GOOGLE_MAPS_API_KEY,
        'form': form,
    }
    signals.context_signal.send(sender=personal, request=request, context=data)
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
コード例 #7
0
ファイル: tests_forms.py プロジェクト: firm1/zds-member
 def test_valid_profile_form(self):
     data = {}
     form = ProfileForm(data=data)
     self.assertTrue(form.is_valid())