-
Notifications
You must be signed in to change notification settings - Fork 0
New Project - Hotel #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| .git | ||
| ../.gitignore | ||
| .dockerignore | ||
| .env | ||
| .env.local | ||
| db.sqlite3 | ||
| *.pyc | ||
| __pycache__ | ||
| *.egg-info | ||
| .pytest_cache | ||
| .coverage | ||
| venv/ | ||
| env/ | ||
| .idea/ | ||
| .vscode/ | ||
| *.log | ||
| node_modules/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Python | ||
| *.py[cod] | ||
| *$py.class | ||
| __pycache__/ | ||
| *.so | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # Virtual Environment | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
| .venv | ||
| .env | ||
| .env.local | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .DS_Store | ||
|
|
||
| # Django | ||
| *.sqlite3 | ||
| *.sqlite | ||
| hotel/db.sqlite3 | ||
| /media/ | ||
| /staticfiles/ | ||
| .django_cache | ||
|
|
||
| # Testing | ||
| .coverage | ||
| .pytest_cache/ | ||
| htmlcov/ | ||
|
|
||
| # Logs | ||
| *.log | ||
| logs/ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Database backups | ||
| *.sql | ||
| *.sql.gz | ||
|
|
||
| # Docker | ||
| .docker/ | ||
|
|
||
| # Node (if using with frontend) | ||
| node_modules/ | ||
| npm-debug.log | ||
|
|
||
| # Misc | ||
| .tmp/ | ||
| temp/ | ||
| *.bak | ||
| .idea |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Используем официальный образ Python | ||
| FROM python:3.14 | ||
|
|
||
| # Установим рабочую директорию | ||
| WORKDIR /app | ||
|
|
||
| # Установим переменные окружения | ||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
|
||
| # Установим зависимости системы | ||
| RUN apt-get update && apt-get install -y \ | ||
| gcc \ | ||
| postgresql-client \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Копируем requirements.txt | ||
| COPY ../requirements.txt . | ||
|
|
||
| # Устанавливаем Python зависимости | ||
| RUN pip install -r requirements.txt uvicorn | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а чего тут uvicorn отдельно стоит ? |
||
| COPY .env . | ||
|
|
||
| # Копируем весь проект | ||
| COPY . . | ||
|
|
||
|
|
||
| # Открываем порт | ||
| EXPOSE 8000 | ||
|
|
||
| # Запускаем сервер | ||
| CMD ["uvicorn", "hotel:application", "--host", "0.0.0.0", "--port", "8000"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| services: | ||
| db: | ||
| image: postgres:18.1 | ||
| container_name: hotel_db | ||
| environment: | ||
| POSTGRES_DB: hotel_db | ||
| POSTGRES_USER: hotel_user | ||
| POSTGRES_PASSWORD: hotel_password | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data | ||
| ports: | ||
| - "5432:5432" | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U hotel_user -d hotel_db"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| web: | ||
| build: . | ||
| container_name: hotel_api | ||
| command: > | ||
| sh -c "python manage.py migrate && | ||
| python manage.py runserver 0.0.0.0:8000" | ||
| volumes: | ||
| - .:/app | ||
| ports: | ||
| - "8000:8000" | ||
| environment: | ||
| DEBUG: "True" | ||
| ALLOWED_HOSTS: "localhost,127.0.0.1" | ||
| DATABASE_URL: postgresql://hotel_user:hotel_password@db:5432/hotel_db | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
| stdin_open: true | ||
| tty: true | ||
|
|
||
| volumes: | ||
| postgres_data: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| ASGI config for hotel 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.2/howto/deployment/asgi/ | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from django.core.asgi import get_asgi_application | ||
|
|
||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hotel.settings') | ||
|
|
||
| application = get_asgi_application() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| """ | ||
| Django settings for hotel project. | ||
|
|
||
| Generated by 'django-admin startproject' using Django 5.2.9. | ||
|
|
||
| For more information on this file, see | ||
| https://docs.djangoproject.com/en/5.2/topics/settings/ | ||
|
|
||
| For the full list of settings and their values, see | ||
| https://docs.djangoproject.com/en/5.2/ref/settings/ | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from decouple import config | ||
|
|
||
| # 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.2/howto/deployment/checklist/ | ||
|
|
||
|
|
||
| SECRET_KEY = config('SECRET_KEY') | ||
| DEBUG = config('DEBUG', default= False, cast=bool) | ||
|
|
||
|
|
||
| ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'web', '*'] | ||
|
|
||
|
|
||
| # Application definition | ||
|
|
||
| INSTALLED_APPS = [ | ||
| 'django.contrib.admin', | ||
| 'django.contrib.auth', | ||
| 'django.contrib.contenttypes', | ||
| 'django.contrib.sessions', | ||
| 'django.contrib.messages', | ||
| 'django.contrib.staticfiles', | ||
| 'hotel_app.apps.HotelAppConfig', | ||
| 'rest_framework', | ||
| ] | ||
|
|
||
| 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 = 'hotel.urls' | ||
|
|
||
| TEMPLATES = [ | ||
| { | ||
| 'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
| 'DIRS': [], | ||
| 'APP_DIRS': True, | ||
| 'OPTIONS': { | ||
| 'context_processors': [ | ||
| 'django.template.context_processors.request', | ||
| 'django.contrib.auth.context_processors.auth', | ||
| 'django.contrib.messages.context_processors.messages', | ||
| ], | ||
| }, | ||
| }, | ||
| ] | ||
|
|
||
| WSGI_APPLICATION = 'hotel.wsgi.application' | ||
|
|
||
|
|
||
| # Database | ||
| # https://docs.djangoproject.com/en/5.2/ref/settings/#databases | ||
|
|
||
| DATABASES = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а чего тут не постгрес? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В докер компоуз у тебч постгря |
||
| 'default': { | ||
| 'ENGINE': 'django.db.backends.postgresql', | ||
| 'NAME': config('DB_NAME'), | ||
| 'USER': config('DB_USER'), | ||
| 'PASSWORD': config('DB_PASSWORD'), | ||
| 'HOST': config('DB_HOST', default='localhost'), | ||
| 'PORT': config('DB_PORT', default='5432'), | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| # Password validation | ||
| # https://docs.djangoproject.com/en/5.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', | ||
| }, | ||
| ] | ||
|
|
||
|
|
||
| # Internationalization | ||
| # https://docs.djangoproject.com/en/5.2/topics/i18n/ | ||
|
|
||
| LANGUAGE_CODE = 'ru' | ||
|
|
||
| TIME_ZONE = 'Europe/Moscow' | ||
|
|
||
| USE_I18N = True | ||
|
|
||
| USE_TZ = True | ||
|
|
||
|
|
||
| # Static files (CSS, JavaScript, Images) | ||
| # https://docs.djangoproject.com/en/5.2/howto/static-files/ | ||
|
|
||
| STATIC_URL = '/static/' | ||
| # Default primary key field type | ||
| # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field | ||
|
|
||
| DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
|
||
| REST_FRAMEWORK = { | ||
| 'DEFAULT_FILTER_BACKENDS': ['rest_framework.filters.OrderingFilter'], | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """ | ||
| URL configuration for hotel project. | ||
|
|
||
| The `urlpatterns` list routes URLs to views. For more information please see: | ||
| https://docs.djangoproject.com/en/5.2/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, re_path, include | ||
| from hotel_app.views import * | ||
|
|
||
|
|
||
| urlpatterns = [ | ||
| path('admin/', admin.site.urls), | ||
| path('api/v1/hotel/', HotelRoomsList.as_view()), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. обычно пишется во множественно числе hotels |
||
| path('api/v1/hotel/<int:pk>/', HotelRoomsUpdate.as_view()), | ||
| path('api/v1/hoteldelete/<int:pk>/', HotelRoomsDestroy.as_view()), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. глаголы не по REST принципу |
||
| path('api/v1/reservations/', ReservationsList.as_view()), | ||
| path('api/v1/reservarions/<int:pk>/', ReservationsUpdate.as_view()), | ||
| path('api/v1/reservationsdelete/<int:pk>/', ReservationsDestroy.as_view()), | ||
| ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| WSGI config for hotel 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.2/howto/deployment/wsgi/ | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from django.core.wsgi import get_wsgi_application | ||
|
|
||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hotel.settings') | ||
|
|
||
| application = get_wsgi_application() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from django.contrib import admin | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
| class HotelAppConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'hotel_app' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Generated by Django 5.2.8 on 2026-01-11 11:23 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ] | ||
|
|
||
| operations = [ | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно использовать poerty или uv
В этом проекте пусть останется, но в следующем другоц пакетный менеджер