Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
ecommerce/settings.py
__pycache__/
*.py[cod]
*$py.class

# Eviroments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
9 changes: 7 additions & 2 deletions ecommerce/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import dotenv
import os
from django.conf.global_settings import DEFAULT_AUTO_FIELD


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -20,7 +22,9 @@
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'k0h)2avtf__#p+ex@*yl#y=v6cfr48(1-c7q%fh4u97#nk0r=x'

dotenv.load_dotenv()
SECRET_KEY = os.getenv('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down Expand Up @@ -80,6 +84,7 @@
}
}

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
asgiref==3.7.2
Django==4.2.5
Pillow==10.0.1
python-dotenv==1.0.0
sqlparse==0.4.4
typing_extensions==4.8.0
14 changes: 10 additions & 4 deletions store/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ def store(request):
except:
autenticado = False

produtos = Produto.objects.all()

if autenticado:
clienteId = request.session['cliente']
cliente = Cliente.objects.get(id=clienteId)
ordem = Ordem.objects.get(cliente=cliente, completo=False)
carItens = ordem.get_car_itens

produtos = Produto.objects.all()
context = {'produtos': produtos,
'carItens': carItens, 'autenticado': autenticado, 'cliente': cliente}
context = {
'produtos': produtos,
'carItens': carItens,
'autenticado': autenticado,
'cliente': cliente
}
else:
context = {'produtos': produtos, 'cliente': "Você não está logado!"}
return render(request, 'store/store.html', context)


Expand Down