Example #1
0
def profile_register(request):
    if request.method == 'POST':
        form = ProfileRegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save()
            return HttpResponseRedirect('/register/success/')

    else:
        form = ProfileRegistrationForm()

    return render(request, 'register.html', {'form': form})
Example #2
0
def profile_edit(request, profile_id):
    profile = Profile.objects.get(pk=profile_id)
    if request.method == "POST":
        form = ProfileRegistrationForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save(force_update=True)
            return HttpResponseRedirect("/profile/list/")
    else:
        form = ProfileRegistrationForm(instance=profile)

    return render(request, "profileEdit.html", {"form": form, "profile_id": profile_id})
Example #3
0
def profile_register(request):
    if request.method == "POST":
        form = ProfileRegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save()
            return HttpResponseRedirect("/register/success/")

    else:
        form = ProfileRegistrationForm()

    return render(request, "register.html", {"form": form})
def profile_register(request):
    if request.method == 'POST':
        form = ProfileRegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save()
            return HttpResponseRedirect('/profile/list')
    
    else:
        form = ProfileRegistrationForm()
    details = Details.objects.get(user=request.user)

    return render(request, 'register.html', {'form' : form , 'sport' : str(details.sport)})
Example #5
0
def profile_edit(request, profile_id):
    profile = Profile.objects.get(pk=profile_id)
    if request.method == 'POST':
        form = ProfileRegistrationForm(request.POST,
                                       request.FILES,
                                       instance=profile)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save(force_update=True)
            return HttpResponseRedirect('/profile/list/')
    else:
        form = ProfileRegistrationForm(instance=profile)

    return render(request, 'profileEdit.html', {
        'form': form,
        'profile_id': profile_id
    })
    return render(request, 'register.html', {'form' : form , 'sport' : str(details.sport)})

@login_required
def profile_edit(request, profile_id):
    try:
        profile = Profile.objects.get(pk=profile_id)
    except Exception, e:
        return render(request, 'profileEdit.html', {'error' : 'yes','message': "This ID does not exist" })
    if profile.user == request.user :
        pass
    else :
        return render(request, 'profileEdit.html', {'error' : 'yes','message': "You do not have access to this ID" })
    if request.method == 'POST':
        form = ProfileRegistrationForm(request.POST, request.FILES, instance=profile)
        if form.is_valid():
            post = form.save(commit=False)
            post.user_id = request.user.pk
            post.save(force_update=True)
            return HttpResponseRedirect('/profile/list/')   
    else:
        form = ProfileRegistrationForm(instance=profile)
    details = Details.objects.get(user=request.user)
    return render(request, 'profileEdit.html', {'form' : form , 'profile_id' : profile_id, 'error' : 'no',  'sport' : str(details.sport)  })

@login_required
def profile_delete(request, profile_id):
    try:
        Profile.objects.get(pk=profile_id).delete()
        profiles = Profile.objects.filter(user=request.user)
    except Exception, e: