Beispiel #1
0
def signup(request):
    if request.method == 'POST':
        first_name = request.POST['firstname']
        last_name = request.POST['lastname']
        username = request.POST['email']
        password1 = request.POST['password']
        password2 = request.POST['confirmpassword']
        email = request.POST['email']
        if password1 == password2:
            if User.objects.filter(username=username).exists():
                messages.info(request, 'Username taken')
                return redirect('signup')
            elif User.objects.filter(email=email).exists():
                messages.infor(request, 'email taken')
                return redirect('signup')
            else:
                user = User.objects.create_user(username=username,
                                                password=password1,
                                                email=email,
                                                first_name=first_name,
                                                last_name=last_name)
                user.save()
                return redirect('login')

        else:
            print('password not matching..')
        return redirect('/')
    else:
        return render(request, 'signup.html')
Beispiel #2
0
def display_profile(request, user_id):
    try:
        single_profile = Profile.single_profile(user_id)
        projects_posted = Project.user_projects(user_id)
        return render(request, 'profiledisplay.html', {
            "profile": single_profile,
            "projects": projects_posted
        })
    except Profile.DoesNotExist:
        messages.info(request, 'The user has not set a profile yet')
    except Project.DoesNotExist:
        messages.infor(request, 'The user has not posted any project yet')
        return redirect('home')
Beispiel #3
0
def single_profile(request, userid):
    profile = UserProfile.objects.all()
    try:
        singleprofile = UserProfile.single_profile(userid)
        businessowned = Business.businessowner(userid)
        newsbyuser = News.newsbyuser(userid)

    except UserProfile.DoesNotExist:
        messages.info(request, 'The user has not created a profile yet')

    except Business.DoesNotExist:
        messages.info(request, 'The user has no business posted')

    except News.DoesNotExist:
        messages.infor(request, 'User has not postedany alerts.')

    return render(request, 'profile.html', {"profile": profile})
Beispiel #4
0
def remove_item(slug, request):
    ordered_item = Order.objects.filter(user=requst.user, ordered=False)
    if ordered_item.exists():
        order = ordered_item[0]
        if order.items.filter(item_slug=ordered_item.slug).exists():
            item_order = OrderItem.objects.filter(item=item,
                                                  user=request.user,
                                                  ordered=False)
            item_order = item_order[0]
            order.items.remove(item_order)
            messages.info(request,
                          "This item was removed from your shopping cart")
            return redirect("core:order-summary")
        else:
            messages.info(request, "This item is not in your cart")
            return redirect("core:product", slug=slug)
    else:
        messages.infor(request, "This item doesn't exist")
        return redirect("core:product", slug=slug)