diff --git a/.gitignore b/.gitignore index a656bc9..ea3ea4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,13 @@ ecommerce/settings.py +__pycache__/ +*.py[cod] +*$py.class + +# Eviroments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ \ No newline at end of file diff --git a/ecommerce/settings.py b/ecommerce/settings.py index 26a7cb1..be182b8 100644 --- a/ecommerce/settings.py +++ b/ecommerce/settings.py @@ -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__))) @@ -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 @@ -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 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..20be3a5 --- /dev/null +++ b/requirements.txt @@ -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 diff --git a/store/views.py b/store/views.py index 9900af1..2a132fc 100644 --- a/store/views.py +++ b/store/views.py @@ -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)