Skip to content

Commit

Permalink
confirm authorization system
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 4, 2024
1 parent b74a439 commit 61a2919
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 69 deletions.
58 changes: 54 additions & 4 deletions apps/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,66 @@


class LoginForm(forms.Form):
username = forms.CharField(widget=forms.TextInput(attrs={}))
password = forms.CharField(widget=forms.PasswordInput(attrs={}))
username = forms.CharField(widget=forms.TextInput(attrs={
"type": "text",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "username..."
}))
password = forms.CharField(widget=forms.PasswordInput(attrs={
"type": "password",
"class": "form-control rounded-4",
"id": "floatPassword",
"placeholder": "password..."
}))

class Meta:
pass


class RegisterForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput(attrs={}))
password_confirm = forms.CharField(widget=forms.PasswordInput(attrs={}))
first_name = forms.CharField(widget=forms.TextInput(attrs={
"type": "text",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "first name",
}))
last_name = forms.CharField(widget=forms.TextInput(attrs={
"type": "text",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "last name",
}))
username = forms.CharField(widget=forms.TextInput(attrs={
"type": "text",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "username",
}))
email = forms.EmailField(widget=forms.EmailInput(attrs={
"type": "email",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "username",
}))
phone_number = forms.CharField(widget=forms.TextInput(attrs={
"type": "tel",
"class": "form-control rounded-4",
"id": "floatInput",
"placeholder": "phone number",
}))
password = forms.CharField(widget=forms.PasswordInput(attrs={
"type": "password",
"class": "form-control rounded-4",
"id": "floatPassword",
"placeholder": "Password"
}))
password_confirm = forms.CharField(widget=forms.PasswordInput(attrs={
"type": "password",
"class": "form-control rounded-4",
"id": "floatPassword",
"placeholder": "Password"
}))

class Meta:
model = CustomUser
Expand Down
7 changes: 7 additions & 0 deletions apps/cart/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .cart import Cart


def cart(request):
return {
"cart": Cart(request)
}
6 changes: 5 additions & 1 deletion apps/coupons/admin.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from django.contrib import admin # noqa
from django.contrib import admin
from .models import Coupon


admin.site.register(Coupon)
1 change: 1 addition & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"apps.shop.context_processors.categories",
"apps.cart.context_processors.cart",
],
},
},
Expand Down
99 changes: 52 additions & 47 deletions templates/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,56 @@
{% block title %}{% endblock %}

{% block content %}
<!-- Login form -->
<div class="modal modal-signin position-static d-block bg-white" tabindex="-1" role="dialog" id="modalSignin">
<div class="modal-dialog" role="document">
<div class="modal-content rounded-5 shadow">
<div class="modal-header p-5 pb-4 border-bottom-0">
<!-- <h5 class="modal-title">Modal title</h5> -->
<h2 class="fw-bold mb-0">Sign up for free</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>

<div class="modal-body p-5 pt-0">
<form class="">
<div class="form-floating mb-3">
<input type="email" class="form-control rounded-4" id="floatingInput" placeholder="[email protected]">
<label for="floatingInput">
<i class="bi bi-envelope-fill"></i>
Email address
</label>
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">
<i class="bi bi-key-fill"></i>
Password
</label>
</div>
<button class="w-100 mb-2 btn btn-lg rounded-4 btn-primary" type="submit">Sign up</button>
<small class="text-muted">By clicking Sign up, you agree to the terms of use.</small>
<hr class="my-4">
<h2 class="fs-5 fw-bold mb-3">Or use a third-party</h2>
<button class="w-100 py-2 mb-2 btn btn-outline-dark rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#twitter"></use></svg>
Sign up with Twitter
</button>
<button class="w-100 py-2 mb-2 btn btn-outline-primary rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#facebook"></use></svg>
Sign up with Facebook
</button>
<button class="w-100 py-2 mb-2 btn btn-outline-secondary rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#github"></use></svg>
Sign up with GitHub
</button>
</form>
</div>
</div>
</div>
</div>
<!-- Login form -->
<div class="modal modal-signin position-static d-block bg-white" tabindex="-1" role="dialog" id="modalSignin">
<div class="modal-dialog" role="document">
<div class="modal-content rounded-5 shadow">
<div class="modal-header p-5 pb-4 border-bottom-0">
<!-- <h5 class="modal-title">Modal title</h5> -->
<h2 class="fw-bold mb-0">Sign up for free</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>

<div class="modal-body p-5 pt-0">
<form class="{% url 'account:login' %}" method="post">
{% csrf_token %}

<div class="form-floating mb-3">
{{ form.username }}
<label for="floatingInput">
<i class="bi bi-envelope-fill"></i>
Email address
</label>
</div>

<div class="form-floating mb-3">
{{ form.password }}
<label for="floatingPassword">
<i class="bi bi-key-fill"></i>
Password
</label>
</div>

<button class="w-100 mb-2 btn btn-lg rounded-4 btn-primary" type="submit">Sign up</button>
<small class="text-muted">By clicking Sign up, you agree to the terms of use.</small>
<hr class="my-4">

<h2 class="fs-5 fw-bold mb-3">Or use a third-party</h2>
<button class="w-100 py-2 mb-2 btn btn-outline-dark rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#twitter"></use></svg>
Sign up with Twitter
</button>
<button class="w-100 py-2 mb-2 btn btn-outline-primary rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#facebook"></use></svg>
Sign up with Facebook
</button>
<button class="w-100 py-2 mb-2 btn btn-outline-secondary rounded-4" type="submit">
<svg class="bi me-1" width="16" height="16"><use xlink:href="#github"></use></svg>
Sign up with GitHub
</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
32 changes: 22 additions & 10 deletions templates/account/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,50 @@ <h2 class="fw-bold mb-0">Sign up for free</h2>
</div>

<div class="modal-body p-5 pt-0">
<form class="">

<form class="{% url 'account:register' %}" method="post">
{% csrf_token %}
<div class="form-floating mb-3">
<input type="text" class="form-control rounded-4" id="floatingInput" placeholder="First name">
{{ form.first_name }}
<!-- <input type="text" class="form-control rounded-4" id="floatingInput" placeholder="First name"> -->
<label for="floatingInput">First Name</label>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control rounded-4" id="floatingInput" placeholder="Last name">
{{ form.last_name }}
<!-- <input type="text" class="form-control rounded-4" id="floatingInput" placeholder="Last name"> -->
<label for="floatingInput">Last Name</label>
</div>

<div class="form-floating mb-3">
<input type="text" class="form-control rounded-4" id="floatingInput" placeholder="Username">
{{ form.username }}
<!-- <input type="text" class="form-control rounded-4" id="floatingInput" placeholder="Username"> -->
<label for="floatingInput">Username</label>
</div>

<div class="form-floating mb-3">
<input type="email" class="form-control rounded-4" id="floatingInput" placeholder="[email protected]">
{{ form.email }}
<!-- <input type="email" class="form-control rounded-4" id="floatingInput" placeholder="[email protected]"> -->
<label for="floatingInput">Email address</label>
</div>


<div class="form-floating mb-3">
{{ form.phone_number }}
<!-- <input type="email" class="form-control rounded-4" id="floatingInput" placeholder="[email protected]"> -->
<label for="floatingInput">Phone Number</label>
</div>

<div class="form-floating mb-3">
<input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password">
{{ form.password }}
<!-- <input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password"> -->
<label for="floatingPassword">Password</label>
</div>

<div class="form-floating mb-3">
<input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password">
{{ form.password_confirm }}
<!-- <input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password"> -->
<label for="floatingPassword">Password confirm</label>
</div>

<button class="w-100 mb-2 btn btn-lg rounded-4 btn-primary" type="submit">Sign up</button>
<button class="w-100 mb-2 btn btn-lg rounded-4 btn-primary" type="submit">Sign In</button>
<small class="text-muted">By clicking Sign up, you agree to the terms of use.</small>

<hr class="my-4">
Expand Down
17 changes: 11 additions & 6 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,29 @@
<!-- Searching... -->
<input class="form-control form-control-dark" type="text" placeholder="Search" aria-label="Search">

{% if request.user.is_authenticated %}
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" href="./login.html">Log-in</a>
<form action="{% url 'account:logout' %}" method="post" class="nav-link">
{% csrf_token %}
<button type="submit" class="text-white btn btn-outline-dark">Sign-out</button>
</form>
<!-- <a class="nav-link px-3" href="#">Sign-out</a> -->
</div>
</div>
{% else %}
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" href="./register.html">Register</a>
<a class="nav-link px-3" href="{% url 'account:login' %}">Log-in</a>
</div>
</div>

<div class="navbar-nav">
<div class="nav-item text-nowrap">
<form action="#" method="post" class="nav-link">
<button type="submit" class="text-white btn btn-outline-dark">Sign-out</button>
</form>
<!-- <a class="nav-link px-3" href="#">Sign-out</a> -->
<a class="nav-link px-3" href="{% url 'account:register' %}">Register</a>
</div>
</div>
{% endif %}
</header>
<!-- end top header -->

Expand Down
2 changes: 1 addition & 1 deletion templates/cart/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ <h5>${{ item.total_price }}</h5>
<div class="d-flex">
<form class="card p-2" action="{% url 'coupon:apply' %}" method="post">
<div class="input-group">
{{ coupon_apply_form.code }}
{% csrf_token %}
{{ coupon_apply_form.code }}
<!-- <input type="text" class="form-control me-2" placeholder="Promo code"> -->
<button type="submit" class="btn btn-secondary">Apply a coupon</button>
</div>
Expand Down

0 comments on commit 61a2919

Please sign in to comment.