diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml new file mode 100644 index 0000000..119cb93 --- /dev/null +++ b/.github/workflows/django.yml @@ -0,0 +1,33 @@ +name: Django CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: ['3.10'] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Run Tests + env: + SECRET_KEY: ${{ secrets.SECRET_KEY }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + run: | + python manage.py test diff --git a/.gitignore b/.gitignore index 297959a..d58e0b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,161 @@ -/vendor/ -node_modules/ -npm-debug.log -yarn-error.log +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class -# Laravel 4 specific -bootstrap/compiled.php -app/storage/ +# C extensions +*.so -# Laravel 5 & Lumen specific -public/storage -public/hot +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST -# Laravel 5 & Lumen specific with changed public path -public_html/storage -public_html/hot +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec -storage/*.key +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments .env -Homestead.yaml -Homestead.json -/.vagrant -.phpunit.result.cache +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ +*.iml diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..e96615a --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn yummy.wsgi --log-file - diff --git a/foodordering/__init__.py b/foodordering/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/foodordering/admin.py b/foodordering/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/foodordering/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/foodordering/apps.py b/foodordering/apps.py new file mode 100644 index 0000000..f4e426e --- /dev/null +++ b/foodordering/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class FoodOrderingConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'foodordering' diff --git a/foodordering/migrations/__init__.py b/foodordering/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/foodordering/models.py b/foodordering/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/foodordering/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/foodordering/tests.py b/foodordering/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/foodordering/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/foodordering/views.py b/foodordering/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/foodordering/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..d465c22 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yummy.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cb13f69 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +asgiref==3.8.1 +Django==5.0.4 +django-environ==0.11.2 +gunicorn==21.2.0 +packaging==24.0 +psycopg==3.1.18 +psycopg-binary==3.1.18 +sqlparse==0.4.4 +typing_extensions==4.11.0 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..2bccd9d --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.10.14 diff --git a/yummy/.env.example b/yummy/.env.example new file mode 100644 index 0000000..6b5657d --- /dev/null +++ b/yummy/.env.example @@ -0,0 +1,2 @@ +SECRET_KEY=3n4bu#vp^8b3=8^bq=r@0d_8j@g@^h4nu_d32x!6$8dqabnh7^ +DATABASE_URL=postgres://postgres:@localhost:5432/postgres diff --git a/yummy/__init__.py b/yummy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/yummy/asgi.py b/yummy/asgi.py new file mode 100644 index 0000000..425b7ee --- /dev/null +++ b/yummy/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for yummy project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yummy.settings') + +application = get_asgi_application() diff --git a/yummy/settings.py b/yummy/settings.py new file mode 100644 index 0000000..d33f018 --- /dev/null +++ b/yummy/settings.py @@ -0,0 +1,128 @@ +""" +Django settings for yummy project. + +Generated by 'django-admin startproject' using Django 5.0.3. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" + +import environ +from pathlib import Path + +env = environ.Env() +environ.Env.read_env() + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = env("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [ + '0.0.0.0', + '127.0.0.1', + 'localhost', + 'yummy-food-ordering-f9f48591304f.herokuapp.com' +] + +# Application definition + +INSTALLED_APPS = [ + 'foodordering.apps.FoodOrderingConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'yummy.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'yummy.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + "default": env.db(), +} + +# Password validation +# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/yummy/urls.py b/yummy/urls.py new file mode 100644 index 0000000..a06f2d0 --- /dev/null +++ b/yummy/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for yummy project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/yummy/wsgi.py b/yummy/wsgi.py new file mode 100644 index 0000000..e6a55b1 --- /dev/null +++ b/yummy/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for yummy project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yummy.settings') + +application = get_wsgi_application()