Esempio n. 1
0
def Profile(request):
    user_membership = get_user_membership(request)
    user_subscription = get_user_subscription(request)
    if request.method == 'POST':
        u_form = userUpdateForm(request.POST, instance=request.user)
        p_form = profileUpdateForm(request.POST,
                                   request.FILES,
                                   instance=request.user.profile)
        if u_form.is_valid() and p_form.is_valid():
            u_form.save()
            p_form.save()
            messages.success(request,
                             'Votre compte a été mis à jour avec succès!')
            return redirect('users:profile')
    else:
        u_form = userUpdateForm(instance=request.user)
        p_form = profileUpdateForm(instance=request.user.profile)

    context = {
        'u_form': u_form,
        'p_form': p_form,
        'user_membership': user_membership,
        'user_subscription': user_subscription
    }
    return render(request, 'profile/profile.html', context)
Esempio n. 2
0
def Profile(request):
    if request.method == 'POST':
        u_form = userUpdateForm(request.POST, instance=request.user)
        p_form = profileUpdateForm(request.POST,
                                   request.FILES,
                                   instance=request.user.profile)
        if u_form.is_valid() and u_form.is_valid():
            u_form.save()
            p_form.save()
            messages.success(request,
                             'Your account has been successfully updated!')
            return redirect('users:profile')
    else:
        u_form = userUpdateForm(instance=request.user)
        p_form = profileUpdateForm(instance=request.user.profile)

    context = {'u_form': u_form, 'p_form': p_form}
    return render(request, 'profile.html', context)
def Profile(request):
    # user = get_object_or_404(User,username=self.kwargs.get('username'))
    my_events = Event.objects.filter(creator=request.user).order_by('-created_date')
    if request.method== 'POST':
        u_form = userUpdateForm(request.POST,instance=request.user)
        p_form = profileUpdateForm(request.POST,request.FILES,instance=request.user.profile)
        if u_form.is_valid() and p_form.is_valid():
            u_form.save()
            p_form.save()
            messages.success(request, 'Your account has been successfully updated!')
            return redirect('users:profile')
    else:
        u_form = userUpdateForm(instance=request.user)
        p_form = profileUpdateForm(instance=request.user.profile)

    context= {
        'u_form':u_form,
        'p_form':p_form,
        'my_events':my_events
    }
    return render(request,'profile/profile.html',context)
Esempio n. 4
0
def profile(request):

    if request.method == 'POST':
        u_form = userUpdateForm(request.POST, instance=request.user)
        p_form = profileUpdateForm(request.POST,
                                   request.FILES,
                                   instance=request.user.profile)
        if u_form.is_valid() and p_form.is_valid():
            u_form.save()
            p_form.save()
            messages.success(request,
                             'Votre compte a été mis à jour avec succès!')
            return redirect('users:profile')
    else:
        u_form = userUpdateForm(instance=request.user)
        p_form = profileUpdateForm(instance=request.user)

    context = {
        'u_form': u_form,
        'p_form': p_form,
    }
    return render(request, 'users/profile.html', context)
Esempio n. 5
0
def Profile(request):
    user_membership = get_user_membership(request)
    user_subscription = get_user_subscription(request)
    if request.method == 'POST':
       u_form = userUpdateForm(request.POST, instance=request.user)
       p_form = profileUpdateForm(request.POST, request.FILED, instance=request.user.profile)
       if u_form.is_valid() and p_form.is_valid():
           u_form.save()
           p_form.save()
           messages.success(request, "Your account has been updated successfully!!")
           return redirect('users:profile')
       else:
           u_form = userUpdateForm(instance=request.user)
           p_form = profileUpdateForm(instance=request.user.profile)

        context= {
            'u_form' : u_form,
            'p_form' : p_form,
            'user_membership' : user_membership,
            'user_subscription' : user_subscription
        }
       return render(request, 'profile/profile.html', context)
Esempio n. 6
0
def profile(request):

    check_is_completed(request)

    context = {}
    context['profile_profileform'] = profileUpdateForm(
        instance=request.user.profile)
    context['profile_userform'] = userUpdateForm(instance=request.user)

    SkillsFormSet = modelformset_factory(SkillLevels, form=SkillsForm)
    context['form'] = SkillsFormSet(queryset=SkillLevels.objects.filter(
        userId=request.user))
    context['UserTitleForm'] = UserTitleForm(instance=request.user.profile)

    return render(request, 'profile.html', context)
Esempio n. 7
0
def update_profile(request):
    if request.method == 'POST':
        profile_form = profileUpdateForm(request.POST, request.FILES)
        if profile_form.is_valid():
            user = request.user
            profile = user.profile

            # We need to manually update the
            profile.classId = profile_form.cleaned_data['classId']
            if profile_form.cleaned_data['picture'] is not 'default.png':
                profile.classId = profile_form.cleaned_data['classId']

            profile.save()

            return JsonResponse({'res': True})
        else:
            return JsonResponse({'res': False})