Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop v0.1 #1

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/
.vscode/
*.iml
.env
.DS_Store
venv/
.pytest_cache/
**__pycache__/
db.sqlite3
64 changes: 43 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
![image](https://github.com/roffi37/kitchen_service/assets/143605204/5fd4ac33-36ce-4f6f-9a21-00472b39a818)# kitchen_service

# Kitchen Service

Imagine you are the owner of restaurant, and you want to improve the communication & rules between your cooks on the kitchen. For this purpose you want to build management system, in which Cooks can create new Dishes & Dishtypes, and also specify, Cooks which are responsible for every Dishes cooking.

Credentials:
`login`: **admin.user2**
`password`: **admin.user2**
=====================
1. python -m venv venv
2. source venv/scripts/activate
3. run python manage.py migrate
4. run python manage.py loaddata db.json
5. run python manage.py runserver
-----------------------------------
On this service, you can use the following functions: read dish types, read dishes, read cooks; register a user (cooks); create dish types, update, delete; create dishes, delete, update;
![image](https://github.com/roffi37/kitchen_service/assets/143605204/30554b1a-a709-435d-8e4a-15185745b0cb)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/dc65b9c4-838d-4e2a-873f-e50166a1c971)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/c430fb7d-ab27-441e-b1cd-303aeb9db19a)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/e9590b90-9670-41f8-90d6-6b666c8ab1ca)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/420cafca-b2d1-4620-ae26-2045252c8a97)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/205958ec-a364-4448-98df-cd32891622fa)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/6fb61f6f-a10e-441b-9835-348429560419)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/9f21a993-88a3-4fae-b220-8107563a53bb)
![image](https://github.com/roffi37/kitchen_service/assets/143605204/bd48a4e3-285c-4e68-9f1e-7fadbf8cae7e)

## Demo

https://kitchen-service-9rkb.onrender.com/


Login: user.admin

Password: y390SBr7

## Functionality
On this service, you can use the following functions: read dish types, read dishes, read cooks; register a user (cooks); create dish types, update, delete; create dishes, delete, update; Offcourse if you are a cook :)


## Run Locally


Clone the project

```bash
python -m venv venv
```

```bash
source venv/scripts/activate
```

```bash
python manage.py migrate

```
```bash
python manage.py loaddata db.json
```

```bash
python manage.py runserver
```

![image](https://github.com/roffi37/kitchen_service/assets/143605204/9482d375-0075-4a9e-a900-086d76dd6199)
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# exit on error
set -o errexit

pip install -r requirements.txt

python manage.py collectstatic --no-input
python manage.py migrate
Empty file added config/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions config/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for config 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/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_asgi_application()
136 changes: 136 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import os

import dj_database_url
from pathlib import Path


# 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/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = 'RENDER' not in os.environ

ALLOWED_HOSTS = ["127.0.0.1"]

RENDER_EXTERNAL_HOSTNAME = os.environ.get('RENDER_EXTERNAL_HOSTNAME')
if RENDER_EXTERNAL_HOSTNAME:
ALLOWED_HOSTS.append(RENDER_EXTERNAL_HOSTNAME)

# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"kitchen",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"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 = "config.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / 'templates']
,
"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 = "config.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}

db_from_env = dj_database_url.config(conn_max_age=500)

DATABASES["default"].update(db_from_env)

DATABASE_URL = "postgres://xazpdkud:[email protected]/xazpdkud"


# Password validation
# https://docs.djangoproject.com/en/4.2/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",
},
]

AUTH_USER_MODEL = "kitchen.Cook"

# Internationalization
# https://docs.djangoproject.com/en/4.2/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/4.2/howto/static-files/

STATIC_URL = "static/"

STATICFILES_DIRS = [BASE_DIR / "static", ]

STATIC_ROOT = BASE_DIR / "staticfiles"


# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

LOGIN_REDIRECT_URL = "/"
10 changes: 10 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path("admin/", admin.site.urls),
path("", include("kitchen.urls", namespace="kitchen")),
path("accounts/", include("django.contrib.auth.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions config/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for config 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/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_wsgi_application()
1 change: 1 addition & 0 deletions db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"model": "admin.logentry", "pk": 1, "fields": {"action_time": "2023-11-22T18:28:09.850Z", "user": 1, "content_type": 7, "object_id": "1", "object_repr": "DishType object (1)", "action_flag": 1, "change_message": "[{\"added\": {}}]"}}, {"model": "admin.logentry", "pk": 2, "fields": {"action_time": "2023-11-22T18:28:33.609Z", "user": 1, "content_type": 8, "object_id": "1", "object_repr": "Dish object (1)", "action_flag": 1, "change_message": "[{\"added\": {}}]"}}, {"model": "admin.logentry", "pk": 3, "fields": {"action_time": "2023-11-22T18:55:23.061Z", "user": 1, "content_type": 6, "object_id": "1", "object_repr": "admin.user", "action_flag": 2, "change_message": "[{\"changed\": {\"fields\": [\"First name\", \"Last name\", \"Years of experience\"]}}]"}}, {"model": "admin.logentry", "pk": 4, "fields": {"action_time": "2023-11-23T17:38:29.750Z", "user": 2, "content_type": 7, "object_id": "7", "object_repr": "Test Dish Type", "action_flag": 3, "change_message": ""}}, {"model": "auth.permission", "pk": 1, "fields": {"name": "Can add log entry", "content_type": 1, "codename": "add_logentry"}}, {"model": "auth.permission", "pk": 2, "fields": {"name": "Can change log entry", "content_type": 1, "codename": "change_logentry"}}, {"model": "auth.permission", "pk": 3, "fields": {"name": "Can delete log entry", "content_type": 1, "codename": "delete_logentry"}}, {"model": "auth.permission", "pk": 4, "fields": {"name": "Can view log entry", "content_type": 1, "codename": "view_logentry"}}, {"model": "auth.permission", "pk": 5, "fields": {"name": "Can add permission", "content_type": 2, "codename": "add_permission"}}, {"model": "auth.permission", "pk": 6, "fields": {"name": "Can change permission", "content_type": 2, "codename": "change_permission"}}, {"model": "auth.permission", "pk": 7, "fields": {"name": "Can delete permission", "content_type": 2, "codename": "delete_permission"}}, {"model": "auth.permission", "pk": 8, "fields": {"name": "Can view permission", "content_type": 2, "codename": "view_permission"}}, {"model": "auth.permission", "pk": 9, "fields": {"name": "Can add group", "content_type": 3, "codename": "add_group"}}, {"model": "auth.permission", "pk": 10, "fields": {"name": "Can change group", "content_type": 3, "codename": "change_group"}}, {"model": "auth.permission", "pk": 11, "fields": {"name": "Can delete group", "content_type": 3, "codename": "delete_group"}}, {"model": "auth.permission", "pk": 12, "fields": {"name": "Can view group", "content_type": 3, "codename": "view_group"}}, {"model": "auth.permission", "pk": 13, "fields": {"name": "Can add content type", "content_type": 4, "codename": "add_contenttype"}}, {"model": "auth.permission", "pk": 14, "fields": {"name": "Can change content type", "content_type": 4, "codename": "change_contenttype"}}, {"model": "auth.permission", "pk": 15, "fields": {"name": "Can delete content type", "content_type": 4, "codename": "delete_contenttype"}}, {"model": "auth.permission", "pk": 16, "fields": {"name": "Can view content type", "content_type": 4, "codename": "view_contenttype"}}, {"model": "auth.permission", "pk": 17, "fields": {"name": "Can add session", "content_type": 5, "codename": "add_session"}}, {"model": "auth.permission", "pk": 18, "fields": {"name": "Can change session", "content_type": 5, "codename": "change_session"}}, {"model": "auth.permission", "pk": 19, "fields": {"name": "Can delete session", "content_type": 5, "codename": "delete_session"}}, {"model": "auth.permission", "pk": 20, "fields": {"name": "Can view session", "content_type": 5, "codename": "view_session"}}, {"model": "auth.permission", "pk": 21, "fields": {"name": "Can add user", "content_type": 6, "codename": "add_cook"}}, {"model": "auth.permission", "pk": 22, "fields": {"name": "Can change user", "content_type": 6, "codename": "change_cook"}}, {"model": "auth.permission", "pk": 23, "fields": {"name": "Can delete user", "content_type": 6, "codename": "delete_cook"}}, {"model": "auth.permission", "pk": 24, "fields": {"name": "Can view user", "content_type": 6, "codename": "view_cook"}}, {"model": "auth.permission", "pk": 25, "fields": {"name": "Can add dish type", "content_type": 7, "codename": "add_dishtype"}}, {"model": "auth.permission", "pk": 26, "fields": {"name": "Can change dish type", "content_type": 7, "codename": "change_dishtype"}}, {"model": "auth.permission", "pk": 27, "fields": {"name": "Can delete dish type", "content_type": 7, "codename": "delete_dishtype"}}, {"model": "auth.permission", "pk": 28, "fields": {"name": "Can view dish type", "content_type": 7, "codename": "view_dishtype"}}, {"model": "auth.permission", "pk": 29, "fields": {"name": "Can add dish", "content_type": 8, "codename": "add_dish"}}, {"model": "auth.permission", "pk": 30, "fields": {"name": "Can change dish", "content_type": 8, "codename": "change_dish"}}, {"model": "auth.permission", "pk": 31, "fields": {"name": "Can delete dish", "content_type": 8, "codename": "delete_dish"}}, {"model": "auth.permission", "pk": 32, "fields": {"name": "Can view dish", "content_type": 8, "codename": "view_dish"}}, {"model": "contenttypes.contenttype", "pk": 1, "fields": {"app_label": "admin", "model": "logentry"}}, {"model": "contenttypes.contenttype", "pk": 2, "fields": {"app_label": "auth", "model": "permission"}}, {"model": "contenttypes.contenttype", "pk": 3, "fields": {"app_label": "auth", "model": "group"}}, {"model": "contenttypes.contenttype", "pk": 4, "fields": {"app_label": "contenttypes", "model": "contenttype"}}, {"model": "contenttypes.contenttype", "pk": 5, "fields": {"app_label": "sessions", "model": "session"}}, {"model": "contenttypes.contenttype", "pk": 6, "fields": {"app_label": "kitchen", "model": "cook"}}, {"model": "contenttypes.contenttype", "pk": 7, "fields": {"app_label": "kitchen", "model": "dishtype"}}, {"model": "contenttypes.contenttype", "pk": 8, "fields": {"app_label": "kitchen", "model": "dish"}}, {"model": "sessions.session", "pk": "36uu52n5f85tnw69biu1dmn1wne72l65", "fields": {"session_data": ".eJxVjEEOgjAURO_StWmg0Na6dO8Zmt__p4IamlBYGe8uJCx0-96beatI6zLEtWKOo6iLatXplyXiJ6ZdyIOme9FcpmUek94Tfdiqb0Xwuh7t38FAddjWDsw9GLA5BIKYLJ0JnJHJnhltZ_NGPTVk2BEjOEm9F3gvpiGQ-nwBRqs6eQ:1r5qVT:ddO_ydyA_UyRm3ZQvPg0ftnobRt8iC9nWcbv1nB-KmQ", "expire_date": "2023-12-06T16:55:19.671Z"}}, {"model": "sessions.session", "pk": "llo3zx7oqcwkoz3t6pnugm7ccqeteiy2", "fields": {"session_data": ".eJxVjEEOwiAQRe_C2hBKGGhduvcMZGBmpGogKe3KeHdt0oVu_3vvv1TEbS1x67zEmdRZWXX63RLmB9cd0B3rrenc6rrMSe-KPmjX10b8vBzu30HBXr61cZS8FWEeSQINdkIyZATdBADe2JA9DwYFGCAIk0nOCo9AEHIAUO8PAlw4bg:1r6DfT:j8lXFSemGI_Z8Kl5Je0rl0h2FxNLTn5HKl2Shp_Azww", "expire_date": "2023-12-07T17:39:11.536Z"}}, {"model": "sessions.session", "pk": "ueqee93n7uxbc33eznbw9u7pb1dyx9q0", "fields": {"session_data": ".eJxVjEEOwiAQRe_C2hBKGGhduvcMZGBmpGogKe3KeHdt0oVu_3vvv1TEbS1x67zEmdRZWXX63RLmB9cd0B3rrenc6rrMSe-KPmjX10b8vBzu30HBXr61cZS8FWEeSQINdkIyZATdBADe2JA9DwYFGCAIk0nOCo9AEHIAUO8PAlw4bg:1r6C5s:IjiAFHS1rP1on45dvngGRFypFpWiZQkZx635WQJFq18", "expire_date": "2023-12-07T15:58:20.528Z"}}, {"model": "kitchen.cook", "pk": 1, "fields": {"password": "pbkdf2_sha256$600000$LMuHVBcno83BpGeAARlhe6$Y/rQ5WijQJDorO/kg9HX3LI+izsFrtd1KaU9P51FcRY=", "last_login": "2023-11-22T16:55:19Z", "is_superuser": true, "username": "admin.user", "first_name": "Barack", "last_name": "Obama", "email": "[email protected]", "is_staff": true, "is_active": true, "date_joined": "2023-11-22T16:55:12Z", "years_of_experience": 17, "groups": [], "user_permissions": []}}, {"model": "kitchen.cook", "pk": 2, "fields": {"password": "pbkdf2_sha256$600000$3HrnuZEnbqsAnOLTY6Cm8y$8isAjjVP/4xWnqPyLyBQprFWYjauO0Y9rzMnJwGlkSI=", "last_login": "2023-11-23T17:39:11.475Z", "is_superuser": true, "username": "admin.user2", "first_name": "", "last_name": "", "email": "[email protected]", "is_staff": true, "is_active": true, "date_joined": "2023-11-23T11:34:44.820Z", "years_of_experience": null, "groups": [], "user_permissions": []}}, {"model": "kitchen.cook", "pk": 3, "fields": {"password": "pbkdf2_sha256$600000$zbHEbsUqq7ESrTFN6QNOKQ$hvrqju5bcOe/jPFw65NSuyg+06J6/I8MKW6QnLKj9SM=", "last_login": null, "is_superuser": false, "username": "testuser", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2023-11-23T17:26:19.779Z", "years_of_experience": null, "groups": [], "user_permissions": []}}, {"model": "kitchen.cook", "pk": 4, "fields": {"password": "", "last_login": null, "is_superuser": false, "username": "cooktest", "first_name": "", "last_name": "", "email": "", "is_staff": false, "is_active": true, "date_joined": "2023-11-23T17:26:20.337Z", "years_of_experience": 5, "groups": [], "user_permissions": []}}, {"model": "kitchen.dishtype", "pk": 1, "fields": {"name": "Pasta"}}, {"model": "kitchen.dishtype", "pk": 2, "fields": {"name": "Pizzas"}}, {"model": "kitchen.dishtype", "pk": 3, "fields": {"name": "Fast Food"}}, {"model": "kitchen.dishtype", "pk": 4, "fields": {"name": "Sushi"}}, {"model": "kitchen.dishtype", "pk": 5, "fields": {"name": "Desserts"}}, {"model": "kitchen.dishtype", "pk": 6, "fields": {"name": "Salads"}}, {"model": "kitchen.dish", "pk": 1, "fields": {"name": "Carbonara", "description": "-", "price": "13.50", "dish_type": 1, "cooks": [1]}}, {"model": "kitchen.dish", "pk": 6, "fields": {"name": "Margherita", "description": "Pizza Margherita (more commonly known in English as Margherita pizza) is a typical Neapolitan pizza, made with San Marzano tomatoes, mozzarella cheese, fresh basil, salt, and extra-virgin olive oil.", "price": "13.00", "dish_type": 2, "cooks": [1]}}, {"model": "kitchen.dish", "pk": 8, "fields": {"name": "Caesar", "description": "Caesar salad with chicken and pumpkin", "price": "5.00", "dish_type": 6, "cooks": [3]}}, {"model": "kitchen.dish", "pk": 9, "fields": {"name": "Caprese", "description": "Caprese salad with tomatoes and mozzarella", "price": "3.45", "dish_type": 6, "cooks": [2]}}, {"model": "kitchen.dish", "pk": 10, "fields": {"name": "Greek", "description": "Greek salad with olives and feta cheese", "price": "5.65", "dish_type": 6, "cooks": [3]}}, {"model": "kitchen.dish", "pk": 11, "fields": {"name": "Cheesecake", "description": "Cheesecake with raspberry sauce", "price": "3.15", "dish_type": 5, "cooks": [1, 2, 3, 4]}}, {"model": "kitchen.dish", "pk": 12, "fields": {"name": "Black Forest", "description": "chocolate cake", "price": "9.45", "dish_type": 5, "cooks": [1, 3]}}, {"model": "kitchen.dish", "pk": 13, "fields": {"name": "Hamburger", "description": "Hamburger with caramelized onions and cheese", "price": "6.75", "dish_type": 3, "cooks": [1, 4]}}, {"model": "kitchen.dish", "pk": 14, "fields": {"name": "Chicken nuggets", "description": "Chicken nuggets with barbecue sauce", "price": "5.45", "dish_type": 3, "cooks": [1, 2, 3, 4]}}, {"model": "kitchen.dish", "pk": 15, "fields": {"name": "Lasagna", "description": "Lasagna with chicken and cream", "price": "10.25", "dish_type": 1, "cooks": [1]}}, {"model": "kitchen.dish", "pk": 16, "fields": {"name": "Pepperoni", "description": "Pepperoni pizza with spicy salami and bell peppers", "price": "8.65", "dish_type": 2, "cooks": [2]}}]
Empty file added kitchen/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions kitchen/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from django.contrib.auth import get_user_model

from kitchen.models import DishType, Dish

admin.site.register(get_user_model())
admin.site.register(DishType)
admin.site.register(Dish)
6 changes: 6 additions & 0 deletions kitchen/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class KitchenConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "kitchen"
Loading