Example #1
0
def signup_view(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=password)
            login(request, user)
            current_user = request.user
            data = UserProfile()
            data.user_id = current_user.id
            data.image = "images/users/user.png"
            data.email = form.cleaned_data.get('email')
            data.phone = form.cleaned_data.get('phone')
            data.biography = form.cleaned_data.get('biography')
            data.facebook = form.cleaned_data.get('facebook')
            data.contact_detail = form.cleaned_data.get('contact_detail')
            data.skype = form.cleaned_data.get('skype')
            data.save()
            return HttpResponseRedirect('/')

    form = SignUpForm()
    category = Category.objects.all()
    setting = Setting.objects.get(pk=1)
    context = {'category': category, 'form': form, 'setting': setting}
    return render(request, 'signup.html', context)
def adduserprofile(request):
    setting = Setting.objects.get(pk=1)
    if request.method == 'POST':
        form2 = UserProfileForm(request.POST, request.FILES)
        if form2.is_valid():
            current_user = request.user
            data2 = UserProfile()
            data2.user_id = current_user.id
            data2.phone = form2.cleaned_data['phone']
            data2.address = form2.cleaned_data['address']
            data2.city = form2.cleaned_data['city']
            data2.country = form2.cleaned_data['country']
            data2.image = form2.cleaned_data['image']
            data2.save()
            messages.success(request, 'Your Content Inserted Succesfully')
            return HttpResponseRedirect('/user')
        else:
            messages.warning(request,
                             'Content Form Error : ' + str(form2.errors))
            return HttpResponseRedirect('/user/useraddprofile')
    else:
        category = Categories.objects.all()
        menu = Menu.objects.all()
        form = UserProfileForm()
        context = {
            'category': category,
            'menu': menu,
            'form': form,
            'setting': setting,
        }
        return render(request, 'user_userprofile.html', context)
Example #3
0
def signup_view(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password1')
            user = authenticate(request, username=username, password=password)
            login(request, user)
            current_user = request.user
            data = UserProfile(
            )  #kişi kayıt olduğunda otomatik profile oluşturmak için
            data.user_id = current_user.id
            data.image = "images/user.jpg"
            data.phone = 123456789
            data.save()
            messages.success(request,
                             "Sisteme başarılı bir şekilde kaydoldunuz")
            return HttpResponseRedirect('/')

        else:
            messages.error(request, "Hata. ")
            return HttpResponseRedirect('/signup')
    form = SignUpForm()
    category = Category.objects.all()
    setting = Setting.objects.get(pk=1)
    context = {'category': category, 'form': form, 'setting': setting}
    return render(request, 'signup.html', context)