Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 4, 2024
1 parent 0ff596a commit 8132458
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 74 deletions.
144 changes: 90 additions & 54 deletions apps/account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,102 @@


class LoginForm(forms.Form):
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..."
}))
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):
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"
}))
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
4 changes: 1 addition & 3 deletions apps/cart/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@


def cart(request):
return {
"cart": Cart(request)
}
return {"cart": Cart(request)}
2 changes: 1 addition & 1 deletion apps/orders/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from localflavor.us.forms import USZipCodeField # noqa
from localflavor.us.forms import USZipCodeField # noqa
from .models import Order


Expand Down
4 changes: 2 additions & 2 deletions apps/orders/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required # noqa
from django.contrib.auth.decorators import login_required # noqa
from django.shortcuts import get_object_or_404, redirect, render
from django.contrib import messages
from apps.cart.cart import Cart
from apps.coupons.forms import CouponApplyForm
from .forms import OrderCreateForm
from .models import Order, OrderItem
from .tasks import order_created # noqa
from .tasks import order_created # noqa


def order_create(request):
Expand Down
2 changes: 1 addition & 1 deletion apps/payment/admin.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from django.contrib import admin # noqa
from django.contrib import admin # noqa
2 changes: 1 addition & 1 deletion apps/payment/models.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from django.db import models # noqa
from django.db import models # noqa
2 changes: 1 addition & 1 deletion apps/payment/tests.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from django.test import TestCase # noqa
from django.test import TestCase # noqa
1 change: 1 addition & 0 deletions core/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(bind=True)
def debug_task(self):
print(f"Request: {self.request!r}")
6 changes: 3 additions & 3 deletions core/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .apps import * # noqa
from .celery import * # noqa
from .email import * # noqa
from .stripe import * # noqa
from .celery import * # noqa
from .email import * # noqa
from .stripe import * # noqa
2 changes: 1 addition & 1 deletion core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

DEBUG = os.getenv("DEBUG") in ["true", "1", True]

ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", 'localhost').split()
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "localhost").split()

INSTALLED_APPS = DJANGO_DEFAULT_APPS + PROJECT_APPS + THIRTY_PARTY_APPS

Expand Down
14 changes: 7 additions & 7 deletions core/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('POSTGRES_NAME'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
'USER': os.getenv('POSTGRES_USER', 'postgres'),
'HOST': os.getenv('POSTGRES_HOST', 'localhost'),
'PORT': os.getenv('POSTGRES_PORT', 5432)
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("POSTGRES_NAME"),
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
"USER": os.getenv("POSTGRES_USER", "postgres"),
"HOST": os.getenv("POSTGRES_HOST", "localhost"),
"PORT": os.getenv("POSTGRES_PORT", 5432),
}
}

0 comments on commit 8132458

Please sign in to comment.