├── .gitignore ├── accounts ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-311.pyc │ ├── admin.cpython-311.pyc │ ├── apps.cpython-311.pyc │ ├── forms.cpython-311.pyc │ ├── models.cpython-311.pyc │ └── views.cpython-311.pyc ├── admin.py ├── apps.py ├── migrations │ ├── __init__.py │ └── __pycache__ │ │ └── __init__.cpython-311.pyc ├── models.py ├── templates │ ├── login.html │ └── register.html ├── tests.py └── views.py ├── app ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-311.pyc │ ├── settings.cpython-311.pyc │ ├── urls.cpython-311.pyc │ └── wsgi.cpython-311.pyc ├── asgi.py ├── settings.py ├── templates │ └── base.html ├── urls.py └── wsgi.py ├── carros_uwsgi.ini ├── cars ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-311.pyc │ ├── admin.cpython-311.pyc │ ├── apps.cpython-311.pyc │ ├── forms.cpython-311.pyc │ ├── models.cpython-311.pyc │ ├── signals.cpython-311.pyc │ └── views.cpython-311.pyc ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_brand_alter_car_brand.py │ ├── 0003_car_photo_car_plate.py │ ├── 0004_carinventory.py │ ├── 0005_car_bio.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-311.pyc │ │ ├── 0002_brand_alter_car_brand.cpython-311.pyc │ │ ├── 0003_car_photo_car_plate.cpython-311.pyc │ │ ├── 0004_carinventory.cpython-311.pyc │ │ ├── 0005_car_bio.cpython-311.pyc │ │ └── __init__.cpython-311.pyc ├── models.py ├── signals.py ├── templates │ ├── car_delete.html │ ├── car_detail.html │ ├── car_update.html │ ├── cars.html │ └── new_car.html ├── tests.py └── views.py ├── manage.py ├── openai_api ├── __pycache__ │ └── client.cpython-311.pyc └── client.py ├── requirements.txt └── uwsgi_params /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | db.sqlite3 3 | media -------------------------------------------------------------------------------- /accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__init__.py -------------------------------------------------------------------------------- /accounts/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/admin.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/admin.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/apps.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/apps.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/forms.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/forms.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/models.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/models.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/__pycache__/views.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/__pycache__/views.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'accounts' 7 | -------------------------------------------------------------------------------- /accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /accounts/migrations/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/accounts/migrations/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /accounts/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |
13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /accounts/templates/register.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | 5 | 29 | 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.forms import UserCreationForm, AuthenticationForm 2 | from django.contrib.auth import authenticate, login, logout 3 | from django.shortcuts import render, redirect 4 | 5 | 6 | def register_view(request): 7 | if request.method == "POST": 8 | user_form = UserCreationForm(request.POST) 9 | if user_form.is_valid(): 10 | user_form.save() 11 | return redirect('login') 12 | else: 13 | user_form = UserCreationForm() 14 | return render(request, 'register.html', {'user_form': user_form}) 15 | 16 | 17 | def login_view(request): 18 | if request.method == "POST": 19 | username = request.POST["username"] 20 | password = request.POST["password"] 21 | user = authenticate(request, username=username, password=password) 22 | if user is not None: 23 | login(request, user) 24 | return redirect('cars_list') 25 | else: 26 | login_form = AuthenticationForm() 27 | else: 28 | login_form = AuthenticationForm() 29 | return render(request, 'login.html', {'login_form': login_form}) 30 | 31 | 32 | def logout_view(request): 33 | logout(request) 34 | return redirect('cars_list') 35 | -------------------------------------------------------------------------------- /app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/app/__init__.py -------------------------------------------------------------------------------- /app/__pycache__/__init__.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/app/__pycache__/__init__.cpython-311.pyc -------------------------------------------------------------------------------- /app/__pycache__/settings.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/app/__pycache__/settings.cpython-311.pyc -------------------------------------------------------------------------------- /app/__pycache__/urls.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/app/__pycache__/urls.cpython-311.pyc -------------------------------------------------------------------------------- /app/__pycache__/wsgi.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycodebr/carros/5a6e359a1ed0b3dbbe71f75fe31a906286d8f716/app/__pycache__/wsgi.cpython-311.pyc -------------------------------------------------------------------------------- /app/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for app project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /app/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for app project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.1.6. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | from pathlib import Path 15 | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 17 | BASE_DIR = Path(__file__).resolve().parent.parent 18 | 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ 22 | 23 | # SECURITY WARNING: keep the secret key used in production secret! 24 | SECRET_KEY = 'django-insecure-gf9wfc@y-hhyc!-gufza%0jr#%v-80bt8vceoznvvz9k4nu1#c' 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! 27 | DEBUG = True 28 | 29 | ALLOWED_HOSTS = ['*'] 30 | 31 | 32 | # Application definition 33 | 34 | INSTALLED_APPS = [ 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | 'cars', 42 | 'accounts', 43 | ] 44 | 45 | MIDDLEWARE = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | ROOT_URLCONF = 'app.urls' 56 | 57 | TEMPLATES = [ 58 | { 59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 60 | 'DIRS': ['app/templates'], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'app.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.postgresql', 82 | 'NAME': 'carros', 83 | 'USER': 'postgres', 84 | 'PASSWORD': 'djangomaster', 85 | 'HOST': 'localhost', 86 | 'PORT': '5432', 87 | } 88 | } 89 | 90 | 91 | # Password validation 92 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators 93 | 94 | AUTH_PASSWORD_VALIDATORS = [ 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 106 | }, 107 | ] 108 | 109 | 110 | # Internationalization 111 | # https://docs.djangoproject.com/en/4.1/topics/i18n/ 112 | 113 | LANGUAGE_CODE = 'pt-br' 114 | 115 | TIME_ZONE = 'America/Sao_Paulo' 116 | 117 | USE_I18N = True 118 | 119 | USE_TZ = True 120 | 121 | 122 | # Static files (CSS, JavaScript, Images) 123 | # https://docs.djangoproject.com/en/4.1/howto/static-files/ 124 | 125 | STATIC_URL = 'static/' 126 | STATIC_ROOT = os.path.join(BASE_DIR, 'static/') 127 | 128 | # Default primary key field type 129 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field 130 | 131 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 132 | 133 | MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 134 | MEDIA_URL = '/media/' 135 | -------------------------------------------------------------------------------- /app/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |Tem certeza que deseja deletar o carro {{ object.brand }} {{ object.model }}?
54 | 61 |Foto não disponível
87 | {% endif %} 88 |Ano de fabricação: {{ object.factory_year }}
90 |Ano do modelo: {{ object.model_year }}
91 |Placa: {{ object.plate }}
92 |Preço: R$ {{ object.value }}
93 | {% if object.bio %} 94 |Bio: {{ object.bio }}
95 | {% endif %} 96 |Foto não disponível
120 | {% endif %} 121 |{{ car.factory_year }} - R$ {{ car.value }}
123 |Nenhum carro encontrado.
128 | {% endif %} 129 |