мерж
This commit is contained in:
commit
c8e1a2a4f3
90 files changed
+995
-655
No files matched your search
@@ -31,15 +31,15 @@ DB_NAME=""
|
||||
DB_USER=""
|
||||
DB_PASSWORD=""
|
||||
DB_HOST=""
|
||||
DB_EXTERNAL_PORT=3306
|
||||
DB_INTERNAL_PORT=3306
|
||||
DB_PORT=3306
|
||||
|
||||
|
||||
REDIS="redis://redis"
|
||||
REDISBROKER="redis://redis"
|
||||
REDIS_PORT=6379
|
||||
REDIS_BASE=0
|
||||
|
||||
AUTO_BACKEND=True
|
||||
AUTO_BACKEND="True"
|
||||
|
||||
FRONTEND_EXTERNAL_PORT=3000
|
||||
FRONTEND_INTERNAL_PORT=3000
|
||||
@@ -47,7 +47,7 @@ FRONTEND_INTERNAL_PORT=3000
|
||||
BACKEND_EXTERNAL_PORT=8000
|
||||
BACKEND_INTERNAL_PORT=8000
|
||||
|
||||
|
||||
DOCKER_RESTART="unless-stopped"
|
||||
|
||||
DOCS_EXTERNAL_PORT=5173
|
||||
DOCS_INTERNAL_PORT=5173
|
||||
@@ -55,4 +55,8 @@ NGINX_EXTERNAL_PORT=80
|
||||
NGINX_INTERNAL_PORT=80
|
||||
|
||||
RUN_WITH_DOCS=False
|
||||
PRODUCTION=False
|
||||
PRODUCTION=True
|
||||
|
||||
MYDEBUG=False
|
||||
DJANGO_CSRF_TRUSTED_ORIGINS="http://localhost, http://portal-t, http://127.0.0.1, http://portal9966/"
|
||||
DJANGO_ALLOWED_HOSTS="*, portal-t, portal9966, localhost, 0.0.0.0"
|
||||
+1
-2
@@ -6,5 +6,4 @@ DB_NAME="accounting"
|
||||
DB_USER="root"
|
||||
DB_PASSWORD="yourpassword"
|
||||
DB_HOST="db"
|
||||
DB_EXTERNAL_PORT=3306
|
||||
DB_INTERNAL_PORT=3306
|
||||
DB_PORT=3306
|
||||
Regular → Executable
File mode changed.
Regular → Executable
+6
-6
@@ -10,10 +10,10 @@ if [ -n "$filesjs" ]; then
|
||||
filesjs_modified=$(echo "$filesjs" | sed 's|^src/front/src/|src/|'| tr '\n' ' ')
|
||||
# Запускаем команду formatter в контейнере
|
||||
echo $filesjs_modified
|
||||
if [ "$(docker-compose -f docker-compose.yml ps -q frontend)" ]; then
|
||||
docker-compose -f docker-compose.yml exec frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||
if [ "$(docker compose -f docker-compose.yml ps -q frontend)" ]; then
|
||||
docker compose -f docker-compose.yml exec frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||
else
|
||||
docker-compose -f docker-compose.yml run --rm frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||
docker compose -f docker-compose.yml run --rm frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||
|
||||
fi
|
||||
fi
|
||||
@@ -32,11 +32,11 @@ pyfiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
|
||||
|
||||
if [ -n "$pyfiles" ]; then
|
||||
pyfiles_mod=$(echo "$pyfiles" | sed 's|^src/back/||'| tr '\n' ' ')
|
||||
if [ "$(docker-compose -f docker-compose.yml ps -q backend)" ]; then
|
||||
if [ "$(docker compose -f docker-compose.yml ps -q backend)" ]; then
|
||||
echo $pyfiles_mod
|
||||
docker-compose -f docker-compose.yml exec backend sh -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||
docker compose -f docker-compose.yml exec backend sh -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||
else
|
||||
docker-compose -f docker-compose.yml run --rm --entrypoint sh backend -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||
docker compose -f docker-compose.yml run --rm --entrypoint sh backend -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||
fi
|
||||
# # Запуск pylint для всех подготовленных Python-файлов
|
||||
# # echo 1
|
||||
@@ -14,4 +14,6 @@ easynpm
|
||||
easydump
|
||||
easyrestore
|
||||
easymanage
|
||||
easydockersave
|
||||
easyserver
|
||||
#
|
||||
+69
-62
@@ -1,10 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
clear_directory() {
|
||||
local dir=$1
|
||||
if [ -d "$dir" ]; then
|
||||
echo "Очистка папки: $dir"
|
||||
rm -rf "$dir"/*
|
||||
else
|
||||
echo "Папка не существует: $dir"
|
||||
fi
|
||||
}
|
||||
# Функция для вывода переменных, определенных во время исполнения скрипта
|
||||
print_script_variables() {
|
||||
set | sort | comm -13 .env.tmp -
|
||||
}
|
||||
# Мина разработчикам с правилами гит-хуков
|
||||
git config core.hooksPath .git-hooks
|
||||
chmod -R +x .git-hooks/
|
||||
# Записываем переменные окружения и функции оболочки во временный файл
|
||||
set | sort > .env.tmp
|
||||
|
||||
@@ -13,7 +23,7 @@ source ".env.base"
|
||||
|
||||
# Создаем локальные файлы из их шаблонов, если они еще не созданы
|
||||
cp -n ${PROJECT_DIR}/.env.local.sample ${PROJECT_DIR}/.env.local
|
||||
# cp -n ${SOURCE_DIR}/settings/local_settings.sample.py ${SOURCE_DIR}/settings/local_settings.py
|
||||
|
||||
|
||||
# Импортируем локальные переменные окружения
|
||||
if [[ -f .env.local ]]; then
|
||||
@@ -28,12 +38,13 @@ ln -sf "${CONFS_DIR}/scripts/easypip.sh" "${PROJECT_DIR}/easypip"
|
||||
ln -sf "${CONFS_DIR}/scripts/easynpm.sh" "${PROJECT_DIR}/easynpm"
|
||||
ln -sf "${CONFS_DIR}/scripts/easydump.sh" "${PROJECT_DIR}/easydump"
|
||||
ln -sf "${CONFS_DIR}/scripts/easyrestore.sh" "${PROJECT_DIR}/easyrestore"
|
||||
ln -sf "${CONFS_DIR}/scripts/easymanage.sh" "${PROJECT_DIR}/easymanage"
|
||||
# ln -sf "${PROJECT_DIR}/scripts/bash.sh" "${PROJECT_DIR}/bash"
|
||||
# ln -sf "${PROJECT_DIR}/scripts/dbshell.sh" "${PROJECT_DIR}/dbshell"
|
||||
# ln -sf "${PROJECT_DIR}/scripts/manage.sh" "${PROJECT_DIR}/manage"
|
||||
# ln -sf "${PROJECT_DIR}/scripts/shell.sh" "${PROJECT_DIR}/shell"
|
||||
# ln -sf "${PROJECT_DIR}/scripts/init.sh" "${PROJECT_DIR}/init"
|
||||
ln -sf "${CONFS_DIR}/scripts/easydockersave.sh" "${PROJECT_DIR}/easydockersave"
|
||||
ln -sf "${CONFS_DIR}/scripts/easyserver.sh" "${PROJECT_DIR}/easyserver"
|
||||
|
||||
|
||||
mkdir -p "${LOCAL_FILES_DIR}/builds"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/builds/images"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/builds/volumes"
|
||||
|
||||
# # Создание локальных файлов для postgres:
|
||||
mkdir -p "${LOCAL_FILES_DIR}/mysql"
|
||||
@@ -53,36 +64,32 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# # Создание локальных файлов для redis:
|
||||
mkdir -p "${LOCAL_FILES_DIR}/redis"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/redis/log"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/redis/data"
|
||||
# # Создание локальных файлов для asgi:
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/log"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/tmp"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/media"
|
||||
# # Создание локальных файлов для centry:
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/celery"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/celery/log"
|
||||
|
||||
|
||||
# # Создание локальных файлов для nginx:
|
||||
mkdir -p "${LOCAL_FILES_DIR}/nginx"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/nginx/conf"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/nginx/log"
|
||||
# mkdir -p "${LOCAL_FILES_DIR}/nginx/certs"
|
||||
|
||||
# Создания docker-compose.override.yml (под gitignore)
|
||||
# touch "${DOCKER_COMPOSES_DIR}/docker-compose.override.yml"
|
||||
|
||||
# # Создание локальных файлов медиа джанги:
|
||||
|
||||
mkdir -p "${LOCAL_FILES_DIR}/django"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/django/media"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/django/media/tmp"
|
||||
mkdir -p "${LOCAL_FILES_DIR}/django/static"
|
||||
clear_directory "${LOCAL_FILES_DIR}/front/"
|
||||
|
||||
mkdir -p "${LOCAL_FILES_DIR}/front/"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Создание конфигов nginx из их шаблонов
|
||||
export NGINX_EXTERNAL_PORT=${NGINX_EXTERNAL_PORT}
|
||||
@@ -90,10 +97,21 @@ export BACKEND_EXTERNAL_PORT=${BACKEND_EXTERNAL_PORT}
|
||||
export FRONTEND_EXTERNAL_PORT=${FRONTEND_EXTERNAL_PORT}
|
||||
export DOCS_EXTERNAL_PORT=${DOCS_EXTERNAL_PORT}
|
||||
export HOST_NAME=${HOST_NAME}
|
||||
|
||||
|
||||
|
||||
# if [[ "${PRODUCTION}" != "False" ]]; then
|
||||
# echo "Сборка версии для сервера!"
|
||||
envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},${FRONTEND_EXTERNAL_PORT},${HOST_NAME}' \
|
||||
< "${CONFS_DIR}/nginx/nginx.prod.conf" > \
|
||||
"${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf"
|
||||
# # Следующие команды заполняют шаблон значениями переменных окружения
|
||||
# else
|
||||
# echo "Сборка версии для РАЗРАБОТКИ!"
|
||||
envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},${FRONTEND_EXTERNAL_PORT},${HOST_NAME}' \
|
||||
< "${CONFS_DIR}/nginx/nginx.dev.conf" > \
|
||||
"${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf"
|
||||
# fi
|
||||
# envsubst '${NGINX_PORT_INTERNAL},${ASGI_PORT_INTERNAL},${DOCS_PORT_INTERNAL},${HOST_NAME}' \
|
||||
# < "${CONFS_DIR}/nginx.prod.conf" > \
|
||||
# "${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf"
|
||||
@@ -102,42 +120,31 @@ envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},
|
||||
|
||||
|
||||
# Дополнение docker-compose.yaml в зависимости от значений переменных окружения
|
||||
# if [[ "${RUN_WITH_REDIS}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.redis.yml"
|
||||
# fi
|
||||
# if [[ "${RUN_WITH_POSTGRES}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.postgres.yml"
|
||||
# fi
|
||||
# if [[ "${RUN_WITH_OVERRIDE_DOCKER_COMPOSE}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.override.yml"
|
||||
# fi
|
||||
|
||||
if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
||||
echo $DOCKER_COMPOSES_DIR
|
||||
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.docs.yml"
|
||||
fi
|
||||
# if [[ "${RUN_WITH_BUILD_LOCALLY}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-asgi-locally.yml"
|
||||
# if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-docs-locally.yml"
|
||||
# fi
|
||||
# fi
|
||||
# ARG_FOUND=false
|
||||
# TARGET_ARG="--lint"
|
||||
# for arg in "$@"; do
|
||||
# if [ "$arg" == "$TARGET_ARG" ]; then
|
||||
# ARG_FOUND=true
|
||||
# break
|
||||
# fi
|
||||
# done
|
||||
# if [ "$ARG_FOUND" = true ]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.frontlint.yml"
|
||||
# else
|
||||
# if [[ "${PRODUCTION}" = "False" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.dev.yml"
|
||||
# else
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.prod.yml"
|
||||
# fi
|
||||
# fi
|
||||
|
||||
|
||||
if [[ "${PRODUCTION}" != "False" ]]; then
|
||||
echo "Сборка версии для сервера!"
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-locally.yml"
|
||||
# if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-docs-locally.yml"
|
||||
# fi
|
||||
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.prod.yml"
|
||||
else
|
||||
echo "Сборка версии для РАЗРАБОТКИ!"
|
||||
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.dev.yml"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Записываем в файл переменные окружения, объявленные в процессе выполнения текущего скрипта
|
||||
|
||||
|
||||
|
||||
@@ -25,4 +25,8 @@ while [ $1 ]
|
||||
shift
|
||||
done
|
||||
echo $COMPOSE_FILE
|
||||
docker compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
||||
if command -v docker compose version &> /dev/null; then
|
||||
docker compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
||||
else
|
||||
docker-compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
||||
fi
|
||||
+44
-70
@@ -1,88 +1,63 @@
|
||||
|
||||
networks:
|
||||
dev:
|
||||
name: ${COMPOSE_PROJECT_NAME}
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
|
||||
frontend:
|
||||
|
||||
restart:
|
||||
always
|
||||
env_file:
|
||||
- .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/dockerfiles/dev
|
||||
args:
|
||||
SOURCE_DIR: ./src/front
|
||||
volumes:
|
||||
|
||||
- ./src/front/:/app
|
||||
- /app/node_modules
|
||||
|
||||
ports:
|
||||
- "${FRONTEND_EXTERNAL_PORT}:${FRONTEND_INTERNAL_PORT}"
|
||||
environment:
|
||||
- CHOKIDAR_USEPOLLING=true
|
||||
|
||||
|
||||
networks:
|
||||
- dev
|
||||
|
||||
|
||||
redis:
|
||||
env_file:
|
||||
- .env
|
||||
image: redis:alpine # Используем легковесный образ Redis
|
||||
ports:
|
||||
- "${REDIS_PORT}:${REDIS_PORT}" # Открываем порт Redis для внешнего доступа (по желанию)
|
||||
networks:
|
||||
- dev
|
||||
|
||||
db:
|
||||
env_file:
|
||||
- .env
|
||||
image: mysql:latest
|
||||
ports:
|
||||
- "${DB_EXTERNAL_PORT}:${DB_INTERNAL_PORT}" # Открываем порт MySQL для внешнего доступа
|
||||
environment:
|
||||
- MYSQL_DATABASE=${DB_NAME}
|
||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- ${CONFS_DIR}/database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- ${LOCAL_FILES_DIR}/mysql/data/:/var/lib/mysql
|
||||
- ${LOCAL_FILES_DIR}/mysql/backup/:/backup/
|
||||
networks:
|
||||
- dev
|
||||
|
||||
backend:
|
||||
entrypoint: /script/backend-entrypoint.sh
|
||||
restart:
|
||||
always
|
||||
build:
|
||||
x-all-base: &all-base
|
||||
|
||||
restart:
|
||||
${DOCKER_RESTART}
|
||||
env_file:
|
||||
- .env
|
||||
# Все наши сервисы для удобства будут в одной сети
|
||||
networks:
|
||||
- dev
|
||||
|
||||
x-backend-base: &backend-base
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/dockerfiles/back
|
||||
|
||||
args:
|
||||
SOURCE_DIR: ./src/back
|
||||
PROJECT_DIR: .
|
||||
|
||||
|
||||
|
||||
services:
|
||||
|
||||
|
||||
redis:
|
||||
container_name: ${COMPOSE_PROJECT_NAME}-redis
|
||||
image: redis:alpine # Используем легковесный образ Redis
|
||||
<<: *all-base
|
||||
|
||||
|
||||
backend:
|
||||
entrypoint: /script/backend-entrypoint.sh
|
||||
container_name: ${COMPOSE_PROJECT_NAME}-backend
|
||||
<<: [*all-base,*backend-base]
|
||||
|
||||
|
||||
ports:
|
||||
- "${BACKEND_EXTERNAL_PORT}:${BACKEND_INTERNAL_PORT}"
|
||||
|
||||
env_file:
|
||||
- .env
|
||||
networks:
|
||||
- dev
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
volumes:
|
||||
- /back/.venv/
|
||||
volumes:
|
||||
- ./src/back:/back
|
||||
- /back/.venv
|
||||
- ${LOCAL_FILES_DIR}/django/media:/back/media/
|
||||
- ${LOCAL_FILES_DIR}/django/static:/back/static/
|
||||
- ${LOCAL_FILES_DIR}/front:/app/front/build
|
||||
|
||||
|
||||
|
||||
|
||||
# command: ["tail", "-f", "/dev/null"]
|
||||
nginx:
|
||||
container_name: ${COMPOSE_PROJECT_NAME}-nginx
|
||||
image: nginx:latest
|
||||
<<: *all-base
|
||||
ports:
|
||||
- "${NGINX_EXTERNAL_PORT}:${NGINX_INTERNAL_PORT}" # Открываем порт 80 для внешнего доступа
|
||||
volumes:
|
||||
@@ -90,8 +65,7 @@ services:
|
||||
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf:/etc/nginx/nginx.conf # Подключаем конфигурацию Nginx
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- dev
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
services:
|
||||
db:
|
||||
image: mysql:latest
|
||||
|
||||
environment:
|
||||
- MYSQL_DATABASE=${DB_NAME}
|
||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- ${CONFS_DIR}/database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- ${LOCAL_FILES_DIR}/mysql/data/:/var/lib/mysql
|
||||
- ${LOCAL_FILES_DIR}/mysql/backup/:/backup/
|
||||
restart:
|
||||
${DOCKER_RESTART}
|
||||
env_file:
|
||||
- .env
|
||||
# Все наши сервисы для удобства будут в одной сети
|
||||
networks:
|
||||
- dev
|
||||
ports:
|
||||
- "${DB_PORT}:${DB_PORT}"
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/dockerfiles/back_dev
|
||||
args:
|
||||
SOURCE_DIR: ./src/back
|
||||
PROJECT_DIR: .
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ports:
|
||||
- "${BACKEND_EXTERNAL_PORT}:${BACKEND_INTERNAL_PORT}"
|
||||
frontend:
|
||||
|
||||
|
||||
restart:
|
||||
${DOCKER_RESTART}
|
||||
env_file:
|
||||
- .env
|
||||
# Все наши сервисы для удобства будут в одной сети
|
||||
networks:
|
||||
- dev
|
||||
|
||||
build:
|
||||
args:
|
||||
SOURCE_DIR: ./src/front
|
||||
context: .
|
||||
dockerfile: docker/dockerfiles/front_dev
|
||||
volumes:
|
||||
|
||||
- ./src/front/:/app
|
||||
- /app/node_modules
|
||||
ports:
|
||||
- "${FRONTEND_EXTERNAL_PORT}:${FRONTEND_INTERNAL_PORT}"
|
||||
environment:
|
||||
|
||||
- CHOKIDAR_USEPOLLING=true
|
||||
|
||||
|
||||
redis:
|
||||
ports:
|
||||
- "${REDIS_PORT}:${REDIS_PORT}" # Открываем порт Redis для внешнего доступа (по желанию)
|
||||
|
||||
nginx:
|
||||
volumes:
|
||||
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf:/etc/nginx/nginx.conf
|
||||
- ${LOCAL_FILES_DIR}/nginx/log/:/var/log/nginx/
|
||||
# - ${LOCAL_FILES_DIR}/django/media:/mnt/resource/media
|
||||
# - ${LOCAL_FILES_DIR}/asgi/tmp/:/tmp/
|
||||
# Важно не забыть прокинуть статику и медиафайлы основного приложения
|
||||
# - ${LOCAL_FILES_DIR}/asgi/static:/mnt/resource/static
|
||||
@@ -0,0 +1,21 @@
|
||||
services:
|
||||
backend:
|
||||
image: ${COMPOSE_PROJECT_NAME}-all
|
||||
build:
|
||||
args:
|
||||
|
||||
SOURCE_DIRFRONT: ./src/front
|
||||
dockerfile: docker/dockerfiles/back_front_prod
|
||||
|
||||
nginx:
|
||||
volumes:
|
||||
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf:/etc/nginx/nginx.conf
|
||||
- ${LOCAL_FILES_DIR}/nginx/log/:/var/log/nginx/
|
||||
- ${LOCAL_FILES_DIR}/django/media:/mnt/resource/media
|
||||
# - ${LOCAL_FILES_DIR}/django/tmp/:/tmp/
|
||||
# Важно не забыть прокинуть статику и медиафайлы основного приложения
|
||||
- ${LOCAL_FILES_DIR}/django/static:/mnt/resource/static
|
||||
- ${LOCAL_FILES_DIR}/front/:/mnt/resource/front/
|
||||
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ ENV SOURCE_DIR=${SOURCE_DIR}
|
||||
# Устанавливаем рабочую директорию
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libmariadb-dev-compat \
|
||||
build-essential \
|
||||
dos2unix \
|
||||
build-essential \
|
||||
pkg-config && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
@@ -18,11 +17,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
COPY ${SOURCE_DIR}/pyproject.toml ${SOURCE_DIR}/README.md ./
|
||||
COPY docker/entries/backend-entrypoint.sh /script/backend-entrypoint.sh
|
||||
|
||||
RUN dos2unix /script/backend-entrypoint.sh && chmod 777 /script/backend-entrypoint.sh && \
|
||||
RUN chmod 777 /script/backend-entrypoint.sh && \
|
||||
python -m pip install --no-cache-dir poetry \
|
||||
&& poetry config virtualenvs.in-project true \
|
||||
&& poetry install --no-interaction --no-ansi
|
||||
# --without dev,test
|
||||
|
||||
# Устанавливаем зависимости
|
||||
# RUN python -m venv env
|
||||
# RUN pip install --no-cache-dir -r r.txt
|
||||
@@ -0,0 +1,48 @@
|
||||
FROM node:lts-alpine as bstage
|
||||
|
||||
ARG SOURCE_DIRFRONT
|
||||
ENV SOURCE_DIR=${SOURCE_DIRFRONT}
|
||||
# Устанавливаем рабочую директорию
|
||||
|
||||
# Копируем package.json и package-lock.json
|
||||
WORKDIR /app
|
||||
|
||||
COPY ${SOURCE_DIRFRONT}/*.json ./
|
||||
COPY ${SOURCE_DIRFRONT}/*.cjs ./
|
||||
COPY ${SOURCE_DIRFRONT}/.* ./
|
||||
|
||||
COPY ${SOURCE_DIR}/*.js ./
|
||||
RUN npm cache clean --force && npm install
|
||||
|
||||
COPY ${SOURCE_DIRFRONT} ./
|
||||
|
||||
|
||||
RUN npm run build
|
||||
|
||||
|
||||
FROM python:3.10.13-slim AS builderstage
|
||||
|
||||
WORKDIR /back
|
||||
|
||||
ARG SOURCE_DIR
|
||||
ENV SOURCE_DIR=${SOURCE_DIR}
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends rsync \
|
||||
libmariadb-dev-compat \
|
||||
build-essential \
|
||||
pkg-config && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=bstage /app/dist /app/dist
|
||||
# Копируем файлы зависимостей в контейнер
|
||||
COPY ${SOURCE_DIR}/pyproject.toml ${SOURCE_DIR}/README.md ./
|
||||
COPY docker/entries/backend-entrypoint.sh /script/backend-entrypoint.sh
|
||||
|
||||
RUN chmod 777 /script/backend-entrypoint.sh && \
|
||||
python -m pip install --no-cache-dir poetry \
|
||||
&& poetry config virtualenvs.in-project true \
|
||||
&& poetry install --no-interaction --no-ansi
|
||||
##--without dev,test
|
||||
|
||||
EXPOSE 8000
|
||||
File renamed without changes.
@@ -5,17 +5,17 @@ do
|
||||
echo "Жду запуска сервера..."
|
||||
done
|
||||
|
||||
until poetry run python manage.py makemigrations
|
||||
do
|
||||
echo "Создаю миграции..."
|
||||
done
|
||||
# until poetry run python manage.py makemigrations
|
||||
# do
|
||||
# echo "Создаю миграции..."
|
||||
# done
|
||||
|
||||
|
||||
until poetry run python manage.py migrate
|
||||
do
|
||||
echo "Применяю при необходимости..."
|
||||
sleep 2
|
||||
done
|
||||
# until poetry run python manage.py migrate
|
||||
# do
|
||||
# echo "Применяю при необходимости..."
|
||||
# sleep 2
|
||||
# done
|
||||
poetry run python manage.py collectstatic --noinput
|
||||
if [ "$PRODUCTION" == "False" ]; then
|
||||
if [ "$AUTO_BACKEND" == "True" ]; then
|
||||
@@ -29,7 +29,7 @@ else
|
||||
# Фронт и бэк в одном
|
||||
|
||||
|
||||
mkdir -p /app/front/ && rsync -av --delete /app/dist/ /app/front/
|
||||
mkdir -p /app/front/build && rsync -av --delete /app/dist/ /app/front/build
|
||||
poetry run daphne -p 8000 -b 0.0.0.0 portal.asgi:application
|
||||
# python -m uvicorn config.asgi:application --bind 0.0.0.0:8000 --worker-class uvicorn.workers.UvicornWorker --timeout 180 --workers $WORKERS_COUNT --log-level debug --access-logfile - --error-logfile - --pid /tmp/gunicorn.pid'
|
||||
# celery --app speaker worker --loglevel=$CELERY_LOGLEVEL --concurrency 1 -E &
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
env/
|
||||
/__pycache__/
|
||||
/*/__pycache__/
|
||||
/**/__pycache__/
|
||||
|
||||
/front/node_modules/
|
||||
*.sqlite3
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -54,7 +54,7 @@ class CustomAuth(ModelBackend):
|
||||
status_code=0
|
||||
|
||||
# !ТУт стучим в AD, потом к Алексею
|
||||
if myDEBUG!=True:
|
||||
if myDEBUG!="True":
|
||||
|
||||
resp= requests.post('http://10.252.44.13:8005/getAD', json.dumps({'user': username, 'password':password, 'usercheck': username}))
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,20 +0,0 @@
|
||||
# Generated by Django 4.2.3 on 2025-01-31 09:54
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('vote', '0002_initial'),
|
||||
('navigation', '0002_news_vote'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='news',
|
||||
name='vote',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='vote.vote'),
|
||||
),
|
||||
]
|
||||
@@ -1,17 +0,0 @@
|
||||
# Generated by Django 4.2.3 on 2025-02-11 12:02
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('navigation', '0003_news_vote'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='news',
|
||||
name='vote',
|
||||
),
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
ENGINE=django.db.backends.mysql
|
||||
DBNAME = accounting
|
||||
USER =
|
||||
PASSWORD=
|
||||
HOST=127.0.0.1
|
||||
PORT=3306
|
||||
@@ -1,42 +0,0 @@
|
||||
from datetime import timedelta
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class Settings:
|
||||
"""
|
||||
Настройки подключений - потом перенести
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Настройки подключений - потом перенести
|
||||
"""
|
||||
self.secret_key = "V7bvDZMztr3EU8S9g1Dipw"
|
||||
self.redis_hosts = [f"{str(os.getenv('REDIS'))}:{str(os.getenv('REDIS_PORT'))}"]
|
||||
self.access_token_lifetime = timedelta(minutes=480)
|
||||
|
||||
self.refresh_token_lifetime = timedelta(days=1)
|
||||
|
||||
self.db = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.mysql",
|
||||
"NAME": os.getenv("DB_NAME"), # Имя базы данных
|
||||
"USER": os.getenv("DB_USER"), # Имя пользователя
|
||||
"PASSWORD": os.getenv("DB_PASSWORD"), # Пароль
|
||||
"HOST": os.getenv("DB_HOST"), # Хост
|
||||
"PORT": os.getenv("DB_INTERNAL_PORT"), # Порт
|
||||
}
|
||||
}
|
||||
|
||||
def foo1(self) -> None:
|
||||
"""
|
||||
Настройки - потом перенести
|
||||
"""
|
||||
return None
|
||||
|
||||
def foo2(self) -> None:
|
||||
"""
|
||||
Настройки подключений - потом перенести
|
||||
"""
|
||||
return None
|
||||
+20
-14
@@ -12,18 +12,18 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
from .ds import Settings
|
||||
stngs = Settings()
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS=100000
|
||||
CORS_ORIGIN_ALLOW_ALL=True
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
LIST_PER_PAGE=25
|
||||
SECRET_KEY=stngs.secret_key
|
||||
SECRET_KEY="V7bvDZMztr3EU8S9g1Dipw"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
myDEBUG=True
|
||||
myDEBUG=os.getenv("MYDEBUG")
|
||||
|
||||
SWAGGER_SETTINGS = {
|
||||
'DEFAULT_INFO': 'import.path.to.urls.api_info',
|
||||
@@ -38,17 +38,13 @@ SWAGGER_SETTINGS = {
|
||||
}
|
||||
}
|
||||
}
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost',
|
||||
'http://127.0.0.1',
|
||||
'http://yourdomain.com', # Add your production domain here
|
||||
]
|
||||
ALLOWED_HOSTS = ["*","portal-t",'portal9966','localhost','0.0.0.0']
|
||||
ALLOWED_HOSTS = str(os.getenv('DJANGO_ALLOWED_HOSTS')).split(', ')
|
||||
CSRF_TRUSTED_ORIGINS = str(os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS')).split(', ')
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts":stngs.redis_hosts,
|
||||
"hosts":[f"{str(os.getenv('REDIS'))}:{str(os.getenv('REDIS_PORT'))}"]
|
||||
},
|
||||
},
|
||||
|
||||
@@ -141,7 +137,17 @@ ASGI_APPLICATION = "portal.asgi.application"
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||
|
||||
DATABASES = stngs.db
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.mysql",
|
||||
"NAME": os.getenv("DB_NAME"), # Имя базы данных
|
||||
"USER": os.getenv("DB_USER"), # Имя пользователя
|
||||
"PASSWORD": os.getenv("DB_PASSWORD"), # Пароль
|
||||
"HOST": os.getenv("DB_HOST"), # Хост
|
||||
"PORT": os.getenv("DB_INTERNAL_PORT"), # Порт
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Password validation
|
||||
@@ -198,8 +204,8 @@ from datetime import timedelta
|
||||
|
||||
|
||||
SIMPLE_JWT = {
|
||||
"ACCESS_TOKEN_LIFETIME": stngs.access_token_lifetime,
|
||||
"REFRESH_TOKEN_LIFETIME": stngs.refresh_token_lifetime,
|
||||
"ACCESS_TOKEN_LIFETIME": timedelta(hours=4),
|
||||
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
|
||||
"ROTATE_REFRESH_TOKENS": False,
|
||||
"BLACKLIST_AFTER_ROTATION": False,
|
||||
"UPDATE_LAST_LOGIN": False,
|
||||
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
anyio
|
||||
asgiref
|
||||
async-timeout
|
||||
attrs
|
||||
autobahn
|
||||
Automat
|
||||
backports.tarfile
|
||||
build==1.2.2.post1
|
||||
CacheControl
|
||||
certifi
|
||||
cffi
|
||||
channels
|
||||
channels-redis
|
||||
charset-normalizer
|
||||
cleo
|
||||
constantly
|
||||
crashtest
|
||||
cryptography
|
||||
daphne
|
||||
defusedxml
|
||||
distlib
|
||||
Django
|
||||
django-ckeditor
|
||||
django-ckeditor-5
|
||||
django-cors-headers
|
||||
django-filter
|
||||
django-grappelli
|
||||
django-js-asset
|
||||
django-templated-mail
|
||||
djangorestframework
|
||||
djangorestframework-simplejwt
|
||||
djoser
|
||||
drf-yasg
|
||||
dulwich
|
||||
et-xmlfile
|
||||
exceptiongroup
|
||||
fastjsonschema
|
||||
filelock
|
||||
findpython
|
||||
h11
|
||||
httpcore
|
||||
httpx
|
||||
hyperlink
|
||||
idna
|
||||
importlib_metadata
|
||||
incremental
|
||||
inflection
|
||||
installer
|
||||
jaraco.classes
|
||||
jaraco.context
|
||||
jaraco.functools
|
||||
jeepney
|
||||
keyring
|
||||
Markdown
|
||||
more-itertools
|
||||
msgpack
|
||||
mysqlclient
|
||||
numpy
|
||||
oauthlib
|
||||
openpyxl
|
||||
packaging
|
||||
pandas
|
||||
pbs-installer
|
||||
Pillow
|
||||
pkginfo
|
||||
platformdirs
|
||||
pyasn1
|
||||
pyasn1-modules
|
||||
pycparser
|
||||
pyOpenSSL
|
||||
pyproject_hooks
|
||||
python-dateutil
|
||||
python3-openid
|
||||
pytz
|
||||
PyYAML
|
||||
RapidFuzz
|
||||
redis
|
||||
requests
|
||||
requests-oauthlib
|
||||
requests-toolbelt
|
||||
SecretStorage
|
||||
service-identity
|
||||
shellingham
|
||||
six
|
||||
sniffio
|
||||
social-auth-app-django
|
||||
social-auth-core
|
||||
sqlparse
|
||||
tomli
|
||||
tomlkit
|
||||
trove-classifiers
|
||||
Twisted
|
||||
txaio
|
||||
typing_extensions
|
||||
tzdata
|
||||
uritemplate
|
||||
urllib3
|
||||
virtualenv
|
||||
XlsxWriter
|
||||
zipp
|
||||
zope.interface
|
||||
zstandard
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing
|
||||
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing, TestFile
|
||||
import nested_admin
|
||||
|
||||
class TestAnswerInline(nested_admin.NestedStackedInline):
|
||||
@@ -13,8 +13,13 @@ class TestQuestionInline(nested_admin.NestedStackedInline):
|
||||
inlines = [TestAnswerInline]
|
||||
fields = ('name', 'file')
|
||||
|
||||
class TestFileInline(nested_admin.NestedStackedInline):
|
||||
model = TestFile
|
||||
extra = 0
|
||||
|
||||
fields = ('file',)
|
||||
class TestAdmin(nested_admin.NestedModelAdmin):
|
||||
inlines = [TestQuestionInline]
|
||||
inlines = [TestFileInline, TestQuestionInline]
|
||||
|
||||
class TestAttemptInline(admin.TabularInline):
|
||||
model = TestAttempt
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("navigation", "0004_remove_news_vote"),
|
||||
|
||||
("tests", "0004_test_is_available"),
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.1.6 on 2025-06-24 08:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0007_alter_testattempt_testing_alter_testing_user"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="test",
|
||||
name="pass_perc",
|
||||
field=models.FloatField(verbose_name="Мин. % правильных ответов"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="testanswer",
|
||||
name="right_wrong",
|
||||
field=models.BooleanField(verbose_name="Правильно"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.4 on 2025-07-22 07:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0008_alter_test_pass_perc_alter_testanswer_right_wrong"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="testquestion",
|
||||
name="name",
|
||||
field=models.TextField(verbose_name="Вопрос"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-01 10:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0009_alter_testquestion_name"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="test",
|
||||
name="name",
|
||||
field=models.CharField(max_length=500, verbose_name="Название теста"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="testanswer",
|
||||
name="name",
|
||||
field=models.TextField(verbose_name="Ответ"),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-07 10:02
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0010_alter_test_name_alter_testanswer_name"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="TestFile",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||
),
|
||||
),
|
||||
(
|
||||
"file",
|
||||
models.FileField(upload_to="tests/test_files/", verbose_name="Приложение"),
|
||||
),
|
||||
(
|
||||
"test",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="test_files",
|
||||
to="tests.test",
|
||||
verbose_name="Тест",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Файл теста",
|
||||
"verbose_name_plural": "Файлы Теста",
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-07 10:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0011_testfile"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="testfile",
|
||||
name="file",
|
||||
field=models.FileField(
|
||||
upload_to="tests/files/help/%(test_id)s/", verbose_name="Приложение"
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.2.4 on 2025-08-07 11:01
|
||||
|
||||
import tests.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("tests", "0012_alter_testfile_file"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="testfile",
|
||||
name="file",
|
||||
field=models.FileField(upload_to=tests.models.id_path, verbose_name="Приложение"),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -12,11 +12,11 @@ class Test(models.Model):
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='Лого Теста')
|
||||
name = models.CharField(max_length=255, blank=False, verbose_name="Название теста")
|
||||
name = models.CharField(max_length=500, blank=False, verbose_name="Название теста")
|
||||
description = models.TextField(verbose_name='Описание')
|
||||
author = models.ForeignKey(User, on_delete=models.CASCADE,
|
||||
verbose_name='Создатель тестирования')
|
||||
pass_perc = models.FloatField(blank=False, verbose_name="Мин. кол-во правильных ответов")
|
||||
pass_perc = models.FloatField(blank=False, verbose_name="Мин. % правильных ответов")
|
||||
time = models.FloatField(blank=False, verbose_name="Время прохождения теста")
|
||||
question_count = models.PositiveIntegerField(blank=False, verbose_name="Количество вопросов")
|
||||
attemps_number = models.PositiveIntegerField(blank=False, verbose_name="Количество попыток")
|
||||
@@ -28,9 +28,29 @@ class Test(models.Model):
|
||||
verbose_name = "Тест"
|
||||
verbose_name_plural = "Тесты"
|
||||
|
||||
def id_path(instance,filename):
|
||||
return f'tests/files/help/{instance.test.id}/{filename}'
|
||||
|
||||
class TestFile(models.Model):
|
||||
test = models.ForeignKey(Test, related_name="test_files",on_delete=models.CASCADE, verbose_name="Тест")
|
||||
file = models.FileField(upload_to=id_path,
|
||||
verbose_name='Приложение')
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Файл теста"
|
||||
verbose_name_plural = "Файлы Теста"
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
|
||||
if self.file:
|
||||
storage, path = self.file.storage, self.file.path
|
||||
storage.delete(path)
|
||||
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
class TestQuestion(models.Model):
|
||||
"""test questions"""
|
||||
name = models.CharField(max_length=255, blank=False, verbose_name="Вопрос")
|
||||
name = models.TextField(blank=False, verbose_name="Вопрос")
|
||||
test = models.ForeignKey(Test,
|
||||
related_name='questions',
|
||||
on_delete=models.CASCADE,
|
||||
@@ -51,7 +71,7 @@ class TestQuestion(models.Model):
|
||||
|
||||
class TestAnswer(models.Model):
|
||||
"""answer options for the question"""
|
||||
name = models.CharField(max_length=255, blank=False, verbose_name="Ответ")
|
||||
name = models.TextField(blank=False, verbose_name="Ответ")
|
||||
file = models.FileField(upload_to='tests/answer_files/',
|
||||
null=True,
|
||||
blank=True,
|
||||
@@ -60,7 +80,7 @@ class TestAnswer(models.Model):
|
||||
related_name='answers',
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name="Вопрос")
|
||||
right_wrong = models.BooleanField(blank=False, verbose_name="Правильно/Неправильно")
|
||||
right_wrong = models.BooleanField(blank=False, verbose_name="Правильно")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Ответ"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# pylint: skip-file
|
||||
import base64
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
from cryptography.fernet import Fernet
|
||||
@@ -107,16 +108,28 @@ class TestResultSerializer(serializers.ModelSerializer):
|
||||
model = TestResult
|
||||
fields = '__all__'
|
||||
|
||||
class TestFileSerializer(serializers.ModelSerializer):
|
||||
filename= serializers.SerializerMethodField()
|
||||
class Meta:
|
||||
model = TestFile
|
||||
fields = ['file','filename']
|
||||
|
||||
def get_filename(self,obj):
|
||||
return os.path.basename(obj.file.name)
|
||||
|
||||
|
||||
class TestsSerializer(serializers.ModelSerializer):
|
||||
datestart = serializers.SerializerMethodField()
|
||||
dateend = serializers.SerializerMethodField()
|
||||
is_passed = serializers.SerializerMethodField()
|
||||
is_active = serializers.SerializerMethodField()
|
||||
|
||||
files = serializers.SerializerMethodField()
|
||||
class Meta:
|
||||
model = Test
|
||||
fields = '__all__'
|
||||
|
||||
def get_files(self,obj):
|
||||
return TestFileSerializer(obj.test_files, many=True).data
|
||||
|
||||
def get_datestart(self, obj):
|
||||
user = self.context['request'].user
|
||||
|
||||
+15
-4
@@ -144,6 +144,7 @@ class TestCreate(APIView):
|
||||
create test
|
||||
"""
|
||||
try:
|
||||
|
||||
self.create_test(request)
|
||||
|
||||
return Response(
|
||||
@@ -151,11 +152,11 @@ class TestCreate(APIView):
|
||||
status=200,
|
||||
)
|
||||
except ValueError as e:
|
||||
|
||||
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
except DatabaseError as e:
|
||||
print(e)
|
||||
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
def create_test(self, request):
|
||||
@@ -180,6 +181,10 @@ class TestCreate(APIView):
|
||||
attemps_number=request.data["attemps_number"],
|
||||
is_available = True
|
||||
)
|
||||
|
||||
test_files=[TestFile(file=file,test=test) for file in request.FILES.getlist("test_files")]
|
||||
if len(test_files)>0:
|
||||
TestFile.objects.bulk_create(test_files)
|
||||
|
||||
questions_files = {
|
||||
file.name: file for file in request.FILES.getlist("questionsfiles")
|
||||
@@ -517,6 +522,10 @@ class TestResultView(generics.ListCreateAPIView):
|
||||
test_answers = TestAnswer.objects.filter(id__in=answer_ids)
|
||||
test = Test.objects.get(id=test_id)
|
||||
answered_questions_total = test_answers.values('question').distinct().count()
|
||||
q_count = test.question_count
|
||||
all_questions = len(TestQuestion.objects.filter(test=test))
|
||||
if all_questions <= q_count:
|
||||
q_count = all_questions
|
||||
|
||||
correct_questions = sum(
|
||||
TestAnswer.objects.filter(
|
||||
@@ -531,8 +540,10 @@ class TestResultView(generics.ListCreateAPIView):
|
||||
|
||||
pass_perc = test.pass_perc
|
||||
correct_answers_perc = 0
|
||||
if answered_questions_total !=0:
|
||||
correct_answers_perc = correct_questions/answered_questions_total*100
|
||||
if q_count !=0:
|
||||
correct_answers_perc = correct_questions/q_count*100
|
||||
# if answered_questions_total !=0:
|
||||
# correct_answers_perc = correct_questions/answered_questions_total*100
|
||||
result = {
|
||||
"is_passed": correct_answers_perc >= pass_perc,
|
||||
"score": correct_questions,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@ import django.db.models.deletion
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('navigation', '0004_remove_news_vote'),
|
||||
|
||||
('vote', '0002_initial'),
|
||||
]
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "1.0.2",
|
||||
"version": "1.2.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -208,7 +208,7 @@ export default {
|
||||
// Устанавливаем начальные даты
|
||||
const currentDate = new Date();
|
||||
const defaultStartDate = new Date(currentDate);
|
||||
defaultStartDate.setHours(9, 0, 0, 0);
|
||||
defaultStartDate.setHours(8, 0, 0, 0);
|
||||
|
||||
const defaultEndDate = new Date(currentDate);
|
||||
defaultEndDate.setHours(18, 0, 0, 0);
|
||||
|
||||
@@ -1,35 +1,60 @@
|
||||
<template>
|
||||
<v-container :class="{ 'pa-4': !isDialog, 'pa-0': isDialog }">
|
||||
<v-row class="justify-center" :class="{ 'mt-6': !isDialog, 'ma-0': isDialog }">
|
||||
<v-col :cols="isDialog ? 12 : '12'" :md="isDialog ? 12 : '8'" :lg="isDialog ? 12 : '6'" class="pa-0">
|
||||
<v-row
|
||||
class="justify-center"
|
||||
:class="{ 'mt-6': !isDialog, 'ma-0': isDialog }"
|
||||
>
|
||||
<v-col
|
||||
:cols="isDialog ? 12 : '12'"
|
||||
:md="isDialog ? 12 : '8'"
|
||||
:lg="isDialog ? 12 : '6'"
|
||||
class="pa-0"
|
||||
>
|
||||
<v-card :elevation="isDialog ? 0 : 2" class="rounded-lg" color="cards">
|
||||
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold">Информация</v-card-title>
|
||||
<v-card-text :class="[
|
||||
'd-flex flex-column ga-6',
|
||||
{ 'border-b-thin': !isDialog, 'pa-0': isDialog }
|
||||
]">
|
||||
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold"
|
||||
>Информация</v-card-title
|
||||
>
|
||||
<v-card-text
|
||||
:class="[
|
||||
'd-flex flex-column ga-6',
|
||||
{ 'border-b-thin': !isDialog, 'pa-0': isDialog },
|
||||
]"
|
||||
>
|
||||
<div class="test-info">
|
||||
<div class="d-flex justify-center mb-4">
|
||||
<v-img
|
||||
:src="data?.file || defaultImage"
|
||||
class="rounded-lg"
|
||||
max-height="200"
|
||||
contain
|
||||
<v-img
|
||||
:src="data?.file || defaultImage"
|
||||
class="rounded-lg"
|
||||
max-height="200"
|
||||
contain
|
||||
/>
|
||||
</div>
|
||||
<div class="text-body-1 mb-4" v-html="formatDescription(data?.description)"></div>
|
||||
|
||||
<div
|
||||
class="text-body-1 mb-4"
|
||||
v-html="formatDescription(data?.description)"
|
||||
></div>
|
||||
|
||||
<div class="d-flex align-center mb-3">
|
||||
<v-icon icon="mdi-clock-outline" color="teal-darken-2" class="mr-2" />
|
||||
<v-icon
|
||||
icon="mdi-clock-outline"
|
||||
color="teal-darken-2"
|
||||
class="mr-2"
|
||||
/>
|
||||
<span class="text-body-1">
|
||||
<strong>Время на прохождение:</strong> {{ formatTime.value }} {{ formatTime.unit }}
|
||||
<strong>Время на прохождение:</strong> {{ formatTime.value }}
|
||||
{{ formatTime.unit }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex align-center mb-3">
|
||||
<v-icon icon="mdi-format-list-numbered" color="teal-darken-2" class="mr-2" />
|
||||
<v-icon
|
||||
icon="mdi-format-list-numbered"
|
||||
color="teal-darken-2"
|
||||
class="mr-2"
|
||||
/>
|
||||
<span class="text-body-1">
|
||||
<strong>Количество вопросов:</strong> {{ data?.question_count }}
|
||||
<strong>Количество вопросов:</strong>
|
||||
{{ data?.question_count }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -39,7 +64,7 @@
|
||||
<strong>Количество попыток:</strong> {{ remainingAttempts !== undefined ? remainingAttempts : data?.attemps_number }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-percent" color="teal-darken-2" class="mr-2" />
|
||||
<span class="text-body-1">
|
||||
@@ -55,7 +80,7 @@
|
||||
class="ml-auto px-9 text-white"
|
||||
@click="startTest"
|
||||
>
|
||||
{{ isExamMode ? 'Начать' : 'Тренироваться' }}
|
||||
{{ isExamMode ? "Начать" : "Тренироваться" }}
|
||||
</v-btn>
|
||||
<v-alert
|
||||
v-else
|
||||
@@ -74,9 +99,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useRoute } from 'vue-router';
|
||||
import { computed } from 'vue';
|
||||
import defaultImage from '@/assets/emblem.png';
|
||||
import { useRoute } from "vue-router";
|
||||
import { computed } from "vue";
|
||||
import defaultImage from "@/assets/emblem.png";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -93,11 +118,11 @@ export default {
|
||||
},
|
||||
setup(props) {
|
||||
const route = useRoute();
|
||||
const isExamMode = computed(() => route.query.mode === 'exam');
|
||||
const isExamMode = computed(() => route.query.mode === "exam");
|
||||
|
||||
const formatTime = computed(() => {
|
||||
if (!props.data?.time) return { value: 0, unit: 'минут' };
|
||||
|
||||
if (!props.data?.time) return { value: 0, unit: "минут" };
|
||||
|
||||
const time = Number(props.data.time);
|
||||
|
||||
// Если число больше 60, значит это секунды (таймер запущен)
|
||||
@@ -106,32 +131,33 @@ export default {
|
||||
const seconds = time % 60;
|
||||
return {
|
||||
value: `${minutes} мин. ${seconds}`,
|
||||
unit: 'сек.'
|
||||
unit: "сек.",
|
||||
};
|
||||
} else {
|
||||
// Если меньше 60, значит это минуты (таймер не запущен)
|
||||
return {
|
||||
value: time,
|
||||
unit: time === 1 ? 'минута' : time >= 2 && time <= 4 ? 'минуты' : 'минут'
|
||||
unit:
|
||||
time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const timeWordDeclension = computed(() => {
|
||||
if (!props.data?.time) return 'минут';
|
||||
|
||||
if (!props.data?.time) return "минут";
|
||||
|
||||
const lastDigit = props.data.time % 10;
|
||||
const lastTwoDigits = props.data.time % 100;
|
||||
|
||||
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return 'минут';
|
||||
if (lastDigit === 1) return 'минута';
|
||||
if (lastDigit >= 2 && lastDigit <= 4) return 'минуты';
|
||||
return 'минут';
|
||||
|
||||
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return "минут";
|
||||
if (lastDigit === 1) return "минута";
|
||||
if (lastDigit >= 2 && lastDigit <= 4) return "минуты";
|
||||
return "минут";
|
||||
});
|
||||
|
||||
|
||||
const formatDescription = (text) => {
|
||||
if (!text) return '';
|
||||
return text.replace(/\r?\n/g, '<br>');
|
||||
if (!text) return "";
|
||||
return text.replace(/\r?\n/g, "<br>");
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -139,9 +165,9 @@ export default {
|
||||
timeWordDeclension,
|
||||
formatDescription,
|
||||
formatTime,
|
||||
defaultImage
|
||||
defaultImage,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -59,9 +59,14 @@
|
||||
<slot name="buttons" :cardValue="cardValue"></slot>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="d-flex align-center status-badge error">
|
||||
<v-icon color="red-darken-1" icon="mdi-alert-circle-outline" size="small" class="mr-2" />
|
||||
<span class="text-red-darken-1 text-body-2 font-weight-medium">Попытки закончились</span>
|
||||
<div>
|
||||
<div class="d-flex status-badge error mb-2">
|
||||
<v-icon color="red-darken-1" icon="mdi-alert-circle-outline" size="small" class="mr-2" />
|
||||
<span class="text-red-darken-1 text-body-2 font-weight-medium">Попытки закончились</span>
|
||||
</div>
|
||||
<div class="text-caption text-grey-darken-1 text-center">
|
||||
Для повторного прохождения<br>обратитесь к администратору
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</v-col>
|
||||
@@ -217,6 +222,15 @@ export default {
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
}
|
||||
|
||||
.no-attempts-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
max-width: 200px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
min-height: 300px;
|
||||
display: flex;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
:answers="answers"
|
||||
:finishTest="openFinishDialog"
|
||||
@change-question="changeQuestion"
|
||||
@answer-changed="onAnswerChanged"
|
||||
/>
|
||||
|
||||
<!-- Результаты теста -->
|
||||
@@ -36,6 +37,7 @@
|
||||
:formattedTime="formatSpentTime"
|
||||
:questions="data?.questions"
|
||||
:userAnswers="answers"
|
||||
:remainingAttempts="remainingAttempts"
|
||||
@restart="startTest"
|
||||
/>
|
||||
|
||||
@@ -147,17 +149,20 @@ export default {
|
||||
const startTest = async () => {
|
||||
await getTestById(testId);
|
||||
|
||||
// Проверяем попытки только для режима экзамена
|
||||
const isExamMode = route.query.mode === 'exam';
|
||||
if (isExamMode && remainingAttempts.value !== undefined && remainingAttempts.value <= 0) {
|
||||
console.log('Нет оставшихся попыток для прохождения теста');
|
||||
return; // Прерываем запуск теста если попыток не осталось
|
||||
return;
|
||||
}
|
||||
|
||||
testStarted.value = true;
|
||||
testFinished.value = false;
|
||||
currentQuestion.value = 0;
|
||||
|
||||
answers.value = Array(data.value.questions.length).fill(null);
|
||||
answers.value = data.value.questions.map((question) => {
|
||||
const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length;
|
||||
return correctAnswersCount > 1 ? [] : null;
|
||||
});
|
||||
|
||||
const initialTime = data.value.time * 60;
|
||||
data.value = { ...data.value, time: initialTime };
|
||||
@@ -169,7 +174,7 @@ export default {
|
||||
|
||||
timer = setInterval(() => {
|
||||
if (data.value?.time > 0) {
|
||||
data.value = { ...data.value, time: data.value.time - 1 };
|
||||
data.value.time = data.value.time - 1;
|
||||
spentTime.value += 1;
|
||||
} else {
|
||||
finishTest();
|
||||
@@ -184,7 +189,6 @@ export default {
|
||||
showFinishDialog.value = false;
|
||||
|
||||
try {
|
||||
// [{ question_id, answers_id: [id, ...] }]
|
||||
let answersToSubmit = [];
|
||||
data.value.questions.forEach((question, questionIndex) => {
|
||||
const answer = answers.value[questionIndex];
|
||||
@@ -231,7 +235,12 @@ export default {
|
||||
() => data.value?.questions,
|
||||
(newQuestions) => {
|
||||
if (newQuestions && Array.isArray(newQuestions)) {
|
||||
answers.value = newQuestions.map(() => null);
|
||||
if (!answers.value || answers.value.length === 0) {
|
||||
answers.value = newQuestions.map((question) => {
|
||||
const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length;
|
||||
return correctAnswersCount > 1 ? [] : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
@@ -260,7 +269,11 @@ export default {
|
||||
);
|
||||
|
||||
const answeredQuestions = computed(
|
||||
() => answers.value.filter((answer) => answer !== null).length,
|
||||
() => answers.value.filter((answer) => {
|
||||
if (answer === null || answer === undefined) return false;
|
||||
if (Array.isArray(answer)) return answer.length > 0;
|
||||
return true;
|
||||
}).length,
|
||||
);
|
||||
|
||||
const testPassed = computed(() => testResults.value?.is_passed ?? false);
|
||||
@@ -271,6 +284,13 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const onAnswerChanged = (questionIndex, value) => {
|
||||
|
||||
const newAnswers = [...answers.value];
|
||||
newAnswers[questionIndex] = value;
|
||||
answers.value = newAnswers;
|
||||
};
|
||||
|
||||
const openFinishDialog = () => {
|
||||
showFinishDialog.value = true;
|
||||
};
|
||||
@@ -293,6 +313,7 @@ export default {
|
||||
answers,
|
||||
currentQuestion,
|
||||
changeQuestion,
|
||||
onAnswerChanged,
|
||||
showFinishDialog,
|
||||
openFinishDialog,
|
||||
correctAnswers,
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<v-btn
|
||||
v-else
|
||||
elevation="0"
|
||||
color="grey-darken-1"
|
||||
color="teal-darken-1"
|
||||
variant="tonal"
|
||||
rounded="lg"
|
||||
class="ml-auto px-6"
|
||||
|
||||
@@ -15,14 +15,17 @@
|
||||
/>
|
||||
|
||||
<!-- Одиночный выбор -->
|
||||
<v-radio-group v-if="!isMultipleChoice" v-model="answers[currentQuestion]">
|
||||
<v-radio
|
||||
v-for="(option, index) in question.answers"
|
||||
:key="index"
|
||||
<v-radio-group
|
||||
v-if="!isMultipleChoice"
|
||||
v-model="currentAnswer"
|
||||
>
|
||||
<v-radio
|
||||
v-for="(option, index) in question.answers"
|
||||
:key="index"
|
||||
:value="option.name"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="text-center">
|
||||
<div>
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`${baseURL.slice(0, -1)}${option.file}`"
|
||||
@@ -39,16 +42,18 @@
|
||||
|
||||
<!-- Множественный выбор -->
|
||||
<div v-else>
|
||||
<p class="text-subtitle-1 text-grey-darken-1 mb-4">Возможно несколько верных ответов</p>
|
||||
<p class="text-subtitle-1 text-grey-darken-1 mb-4">
|
||||
Возможно несколько верных ответов
|
||||
</p>
|
||||
<v-checkbox
|
||||
v-for="(option, index) in question.answers"
|
||||
:key="index"
|
||||
v-model="answers[currentQuestion]"
|
||||
v-model="currentAnswer"
|
||||
:value="option.name"
|
||||
class="mb-n6"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="text-center">
|
||||
<div>
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`${baseURL.slice(0, -1)}${option.file}`"
|
||||
@@ -92,7 +97,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, watch } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
|
||||
@@ -104,31 +109,36 @@ export default {
|
||||
finishTest: Function,
|
||||
answers: Array,
|
||||
},
|
||||
setup(props) {
|
||||
setup(props, { emit }) {
|
||||
const route = useRoute();
|
||||
const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice');
|
||||
const isPracticeMode = computed(
|
||||
() => !route.query.mode || route.query.mode === "practice",
|
||||
);
|
||||
|
||||
const isMultipleChoice = computed(() => {
|
||||
return props.question.answers.filter(answer => answer.right_wrong).length > 1;
|
||||
return (
|
||||
props.question.answers.filter((answer) => answer.right_wrong).length > 1
|
||||
);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.currentQuestion,
|
||||
(newVal) => {
|
||||
if (isMultipleChoice.value && !Array.isArray(props.answers[newVal])) {
|
||||
props.answers[newVal] = [];
|
||||
}
|
||||
const currentAnswer = computed({
|
||||
get() {
|
||||
const answer = props.answers[props.currentQuestion];
|
||||
return answer;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
set(value) {
|
||||
emit('answer-changed', props.currentQuestion, value);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
isMultipleChoice,
|
||||
isPracticeMode,
|
||||
baseURL
|
||||
baseURL,
|
||||
currentAnswer
|
||||
};
|
||||
},
|
||||
emits: ['change-question'],
|
||||
emits: ["change-question", "answer-changed"],
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -152,18 +162,13 @@ export default {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.v-radio-group :deep(.v-radio),
|
||||
.v-radio-group :deep(.v-radio),
|
||||
.v-checkbox {
|
||||
margin-bottom: 12px;
|
||||
transition: transform 0.2s;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.v-radio-group :deep(.v-radio:hover),
|
||||
.v-checkbox:hover {
|
||||
transform: translateX(4px);
|
||||
}
|
||||
|
||||
.v-btn {
|
||||
text-transform: none;
|
||||
font-weight: 500;
|
||||
|
||||
@@ -12,28 +12,11 @@
|
||||
</div>
|
||||
<div v-else class="result-animation error">
|
||||
<v-icon size="64" color="error" class="shake">mdi-close-circle</v-icon>
|
||||
<div class="text-h6 error--text mt-2 fade-in">Не пройдено</div>
|
||||
<div class="text-h6 error--text mt-2 fade-in">Тест не пройден</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<v-row class="mt-2">
|
||||
<v-col cols="12" sm="4">
|
||||
<v-card
|
||||
class="pa-4 text-center result-card"
|
||||
:class="{ 'cursor-pointer': isPracticeMode }"
|
||||
elevation="2"
|
||||
:color="testPassed ? 'success-light' : 'error-light'"
|
||||
@click="isPracticeMode && (showAnswersDialog = true)"
|
||||
>
|
||||
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
|
||||
mdi-checkbox-marked-circle
|
||||
</v-icon>
|
||||
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
|
||||
<div class="text-body-2">
|
||||
{{ isPracticeMode ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }}
|
||||
</div>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="4">
|
||||
<v-card class="pa-4 text-center result-card" elevation="2">
|
||||
@@ -43,6 +26,24 @@
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="4">
|
||||
<v-card
|
||||
class="pa-4 text-center result-card"
|
||||
:class="{ 'cursor-pointer': !fromCompletedTab }"
|
||||
elevation="2"
|
||||
:color="testPassed ? 'success-light' : 'error-light'"
|
||||
@click="!fromCompletedTab && (showAnswersDialog = true)"
|
||||
>
|
||||
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
|
||||
mdi-checkbox-marked-circle
|
||||
</v-icon>
|
||||
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
|
||||
<div class="text-body-2">
|
||||
{{ !fromCompletedTab ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }}
|
||||
</div>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="4">
|
||||
<v-card class="pa-4 text-center result-card" elevation="2">
|
||||
<v-icon size="36" color="primary" class="mb-2">mdi-clock-outline</v-icon>
|
||||
@@ -52,11 +53,11 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Модальное окно с правильными ответами (только для тренировочного режима) -->
|
||||
<v-dialog v-if="isPracticeMode" v-model="showAnswersDialog" max-width="600">
|
||||
<!-- Модальное окно с правильными ответами -->
|
||||
<v-dialog v-model="showAnswersDialog" max-width="600">
|
||||
<v-card>
|
||||
<v-card-title class="d-flex align-center text-h6 font-weight-bold px-4 py-3 bg-teal-darken-4 text-white">
|
||||
<span>Правильные ответы</span>
|
||||
<span>{{ isPracticeMode ? 'Правильные ответы' : 'Результаты по вопросам' }}</span>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon="mdi-close" variant="text" @click="showAnswersDialog = false" color="white"></v-btn>
|
||||
</v-card-title>
|
||||
@@ -78,33 +79,46 @@
|
||||
</div>
|
||||
</v-expansion-panel-title>
|
||||
<v-expansion-panel-text>
|
||||
<p class="mb-2 font-weight-bold">{{ question.name }}</p>
|
||||
<v-divider class="mb-2"></v-divider>
|
||||
<div v-for="answer in question.answers" :key="answer.id" class="mb-2 d-flex align-center">
|
||||
<v-icon
|
||||
:color="getAnswerColor(index, answer)"
|
||||
size="small"
|
||||
class="mr-2"
|
||||
>
|
||||
{{ getAnswerIcon(index, answer) }}
|
||||
</v-icon>
|
||||
<span :class="{ 'font-weight-bold': isAnswerCorrect(index, answer) }">
|
||||
{{ answer.name }}
|
||||
</span>
|
||||
<v-chip
|
||||
v-if="answer.isUserAnswer"
|
||||
size="small"
|
||||
class="ml-2"
|
||||
:color="answer.right_wrong === true ? 'success' : 'error'"
|
||||
variant="outlined"
|
||||
>
|
||||
Ваш ответ
|
||||
</v-chip>
|
||||
</div>
|
||||
<div v-if="hasUserAnswer(index)" class="mt-4">
|
||||
<p class="mb-4 font-weight-bold">{{ question.name }}</p>
|
||||
|
||||
<!-- Показываем варианты ответов только в тренировочном режиме -->
|
||||
<div v-if="isPracticeMode">
|
||||
<v-divider class="mb-2"></v-divider>
|
||||
<div class="text-caption">
|
||||
{{ isQuestionCorrect(index) ? 'Правильно ✓' : 'Неправильно ✗' }}
|
||||
<div v-for="answer in question.answers" :key="answer.id" class="mb-2 d-flex align-center">
|
||||
<v-icon
|
||||
:color="getAnswerColor(index, answer)"
|
||||
size="small"
|
||||
class="mr-2"
|
||||
>
|
||||
{{ getAnswerIcon(index, answer) }}
|
||||
</v-icon>
|
||||
<span :class="{ 'font-weight-bold': isAnswerCorrect(index, answer) }">
|
||||
{{ answer.name }}
|
||||
</span>
|
||||
<v-chip
|
||||
v-if="answer.isUserAnswer"
|
||||
size="small"
|
||||
class="ml-2"
|
||||
:color="answer.right_wrong === true ? 'success' : 'error'"
|
||||
variant="outlined"
|
||||
>
|
||||
Ваш ответ
|
||||
</v-chip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- В режиме экзамена показываем только статус ответа -->
|
||||
<div v-if="hasUserAnswer(index)">
|
||||
<v-divider v-if="isPracticeMode" class="mb-2"></v-divider>
|
||||
<div class="text-body-2 font-weight-medium d-flex align-center">
|
||||
<v-icon
|
||||
:color="isQuestionCorrect(index) ? 'success' : 'error'"
|
||||
class="mr-2"
|
||||
size="small"
|
||||
>
|
||||
{{ isQuestionCorrect(index) ? 'mdi-check-circle' : 'mdi-close-circle' }}
|
||||
</v-icon>
|
||||
{{ isQuestionCorrect(index) ? 'Правильно' : 'Неправильно' }}
|
||||
</div>
|
||||
</div>
|
||||
</v-expansion-panel-text>
|
||||
@@ -114,9 +128,10 @@
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<!-- Кнопка "Попробовать ещё раз" для тренировочного режима -->
|
||||
<div v-if="isPracticeMode && !fromCompletedTab" class="d-flex justify-center mt-6">
|
||||
<!-- Кнопка "Попробовать ещё раз" или информационное сообщение -->
|
||||
<div class="d-flex justify-center mt-6">
|
||||
<v-btn
|
||||
v-if="canRetry"
|
||||
color="teal-darken-1"
|
||||
@click="$emit('restart')"
|
||||
class="px-6"
|
||||
@@ -125,6 +140,16 @@
|
||||
<v-icon start>mdi-refresh</v-icon>
|
||||
Попробовать ещё раз
|
||||
</v-btn>
|
||||
|
||||
<v-alert
|
||||
v-else-if="getRetryMessage"
|
||||
type="info"
|
||||
variant="tonal"
|
||||
class="text-center"
|
||||
:icon="testPassed ? 'mdi-check-circle' : 'mdi-information'"
|
||||
>
|
||||
{{ getRetryMessage }}
|
||||
</v-alert>
|
||||
</div>
|
||||
</v-card>
|
||||
</template>
|
||||
@@ -157,6 +182,10 @@ export default {
|
||||
fromCompletedTab: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
remainingAttempts: {
|
||||
type: Number,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
@@ -164,6 +193,29 @@ export default {
|
||||
const showAnswersDialog = ref(false);
|
||||
|
||||
const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice');
|
||||
const isExamMode = computed(() => route.query.mode === 'exam');
|
||||
|
||||
const canRetry = computed(() => {
|
||||
if (props.fromCompletedTab) return false;
|
||||
if (isPracticeMode.value) return true;
|
||||
if (isExamMode.value) {
|
||||
// В режиме экзамена можно повторить только если есть попытки и тест не пройден
|
||||
return props.remainingAttempts > 0 && !props.testPassed;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const getRetryMessage = computed(() => {
|
||||
if (isExamMode.value && props.remainingAttempts !== undefined) {
|
||||
if (props.testPassed) {
|
||||
return 'Тест успешно пройден. Повторное прохождение недоступно.';
|
||||
}
|
||||
if (props.remainingAttempts <= 0) {
|
||||
return 'Нет оставшихся попыток для прохождения теста. Для повторного прохождения обратитесь к администратору.';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const getQuestionStatusColor = (questionIndex) => {
|
||||
if (!props.questions[questionIndex]?.answers) return 'grey';
|
||||
@@ -301,6 +353,9 @@ export default {
|
||||
return {
|
||||
showAnswersDialog,
|
||||
isPracticeMode,
|
||||
isExamMode,
|
||||
canRetry,
|
||||
getRetryMessage,
|
||||
isQuestionCorrect,
|
||||
hasUserAnswer,
|
||||
showUserAnswer,
|
||||
|
||||
@@ -613,7 +613,7 @@ export default {
|
||||
|
||||
errorMessage.value =
|
||||
hasEmptyQuestions || hasInvalidAnswers
|
||||
? 'Все вопросы и ответы должны быть заполнены'
|
||||
? 'Все вопросы и ответы должны быть заполнены. Выбраны правильные ответы к вопросам.'
|
||||
: '';
|
||||
},
|
||||
{ deep: true },
|
||||
|
||||
@@ -4,7 +4,7 @@ import { VCalendar } from 'vuetify/labs/VCalendar'
|
||||
|
||||
import { createVuetify } from 'vuetify'
|
||||
import { ru } from 'vuetify/locale'
|
||||
import { VTimePicker } from 'vuetify/labs/VTimePicker'
|
||||
|
||||
|
||||
export default createVuetify({
|
||||
|
||||
@@ -13,7 +13,7 @@ export default createVuetify({
|
||||
},
|
||||
components: {
|
||||
VCalendar,
|
||||
VTimePicker,
|
||||
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light',
|
||||
|
||||
@@ -3,8 +3,8 @@ import axios from "axios";
|
||||
|
||||
const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
|
||||
const spravURLBase = 'http://10.252.44.33/accounting6/'
|
||||
const baseURL = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:8000/' : `http://${window.location.host}/`;
|
||||
const baseWS = process.env.NODE_ENV === 'development' ? 'ws://localhost/' : `ws://${window.location.host}/`;
|
||||
const baseURL = `http://${window.location.host}/`;
|
||||
const baseWS = `ws://${window.location.host}/`;
|
||||
// const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
|
||||
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
||||
// для релизного меняем 'http://ukd/'
|
||||
|
||||
@@ -223,7 +223,8 @@ export default {
|
||||
pagecounter();
|
||||
const accountStore = useAccountStore();
|
||||
const router = useRouter();
|
||||
const activeTab = ref(0);
|
||||
const savedTab = localStorage.getItem('testHomePage_activeTab');
|
||||
const activeTab = ref(savedTab ? parseInt(savedTab) : 0);
|
||||
const currentTest = ref('');
|
||||
const getAllTests = ref([]);
|
||||
const deleteDialog = ref(false);
|
||||
@@ -239,13 +240,38 @@ export default {
|
||||
color: 'error'
|
||||
});
|
||||
|
||||
// Функция для показа уведомлений
|
||||
const showNotification = (text, color = 'error') => {
|
||||
snackbar.value.text = text;
|
||||
snackbar.value.color = color;
|
||||
snackbar.value.show = true;
|
||||
};
|
||||
|
||||
const updateCurrentTestCount = () => {
|
||||
if (activeTab.value === 0) {
|
||||
currentTest.value = getAllTests.value.filter(test =>
|
||||
test.is_active &&
|
||||
test.is_passed !== true &&
|
||||
test.attemps_number > 0
|
||||
).length;
|
||||
}
|
||||
};
|
||||
|
||||
const getAssignedTestsCount = () => {
|
||||
axiosApiInstance
|
||||
.get('/api/tests/gettests?status=active')
|
||||
.then((resp) => {
|
||||
const assignedTests = resp.data.filter(test =>
|
||||
test.is_active &&
|
||||
test.is_passed !== true &&
|
||||
test.attemps_number > 0
|
||||
);
|
||||
currentTest.value = assignedTests.length;
|
||||
})
|
||||
.catch(() => {
|
||||
currentTest.value = 0;
|
||||
});
|
||||
};
|
||||
|
||||
const getTestById = () => {
|
||||
const status = activeTab.value === 2 ? '' :
|
||||
activeTab.value === 0 ? '?status=active' :
|
||||
@@ -258,26 +284,29 @@ export default {
|
||||
})
|
||||
.finally(() => {
|
||||
if (activeTab.value === 0) {
|
||||
currentTest.value = getAllTests.value.filter(test =>
|
||||
test.is_active &&
|
||||
test.is_passed !== true &&
|
||||
test.attemps_number > 0
|
||||
).length;
|
||||
updateCurrentTestCount();
|
||||
} else {
|
||||
getAssignedTestsCount();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getTestById();
|
||||
|
||||
if (activeTab.value !== 0) {
|
||||
getAssignedTestsCount();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => activeTab.value,
|
||||
() => {
|
||||
(newTab) => {
|
||||
localStorage.setItem('testHomePage_activeTab', newTab.toString());
|
||||
getTestById();
|
||||
},
|
||||
);
|
||||
|
||||
const tabs = computed(() => [
|
||||
{ value: 0, title: `Назначенные (${currentTest.value})` },
|
||||
{ value: 0, title: `Назначенные${currentTest.value !== '' ? ` (${currentTest.value})` : ''}` },
|
||||
{ value: 1, title: 'Завершенные' },
|
||||
{ value: 2, title: 'Каталог' },
|
||||
...(accountStore.user.is_staff ? [{ value: 3, title: 'Создать новый тест' }] : []),
|
||||
@@ -363,7 +392,6 @@ export default {
|
||||
const assignmentIds = activeAssignments.map(assignment => assignment.id);
|
||||
await deleteTestingRecord(assignmentIds);
|
||||
|
||||
// Обновляем данные диалога после удаления всех назначений
|
||||
await openAddDialog(selectedTestId.value);
|
||||
|
||||
showNotification('Все назначения успешно отменены', 'green');
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,90 @@
|
||||
# Основной блок конфигурации
|
||||
# user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
# Установка глобальных параметров
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
client_max_body_size 1000M;
|
||||
|
||||
# Логи
|
||||
access_log off;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
|
||||
# Первый сервер
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
# server_name ${HOST_NAME}; # Замените на ваше доменное имя, если необходимо
|
||||
proxy_read_timeout 1000;
|
||||
|
||||
# Указываем путь к статическим файлам
|
||||
location ^~ /static {
|
||||
alias /mnt/resource/static/; # Проксируем запросы к контейнеру backend
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
# Указываем путь к медиа-файлам
|
||||
location /media/ {
|
||||
add_header Content-Security-Policy "frame-ancestors 'self' *.localhost";
|
||||
alias /mnt/resource/media/; # Проксируем запросы к контейнеру backend
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
|
||||
|
||||
location ~ ^/ws(/.*)?$ {
|
||||
proxy_pass http://backend:${BACKEND_EXTERNAL_PORT}; # Убедитесь, что это правильный адрес вашего WebSocket-сервера
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
location / {
|
||||
|
||||
alias /mnt/resource/front/;
|
||||
try_files $uri /index.html;
|
||||
|
||||
# Настройки для WebSocket
|
||||
|
||||
}
|
||||
location ^~ /admin {
|
||||
|
||||
proxy_pass http://backend:${BACKEND_EXTERNAL_PORT};
|
||||
}
|
||||
|
||||
# Обработка всех остальных запросов
|
||||
location ^~ /api/ {
|
||||
proxy_pass http://backend:${BACKEND_EXTERNAL_PORT}; # Прокси на ваш Django backend
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
source ".env"
|
||||
|
||||
AUTO_CONFIRM=false
|
||||
while getopts "y" opt; do
|
||||
case ${opt} in
|
||||
y )
|
||||
AUTO_CONFIRM=true
|
||||
;;
|
||||
\? )
|
||||
echo "Неверный флаг: -$OPTARG" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND -1))
|
||||
|
||||
if [[ "${PRODUCTION}" != "False" ]]; then
|
||||
temp_dir=$(mktemp -d)
|
||||
if [[ "$AUTO_CONFIRM" == false ]]; then
|
||||
read -p "Вы уверены, что хотите сохранить образы всех запущенных контейнеров $COMPOSE_PROJECT_NAME? (y/n): " confirmation
|
||||
if [[ "$confirmation" != "y" && "$confirmation" != "Y" ]]; then
|
||||
echo "Операция отменена."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
running_containers=$(docker ps -q )
|
||||
# Сохраняем образы всех запущенных контейнеров
|
||||
for container in $running_containers; do
|
||||
imagename=$(docker inspect --format='{{.Config.Image}}' $container)
|
||||
echo "Обрабатываю контейнер: $imagename"
|
||||
|
||||
docker save -o "${LOCAL_FILES_DIR}/builds/images/${imagename//\//_}.tar" $imagename
|
||||
|
||||
done
|
||||
echo "Контейнеры $COMPOSE_PROJECT_NAME сохранены"
|
||||
else
|
||||
echo "Переключись в продакшн"
|
||||
fi
|
||||
Regular → Executable
+1
-1
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker-compose -f docker-compose.yml exec backend python manage.py $1 $2 $3
|
||||
docker compose -f docker-compose.yml exec backend poetry run python manage.py $@
|
||||
Regular → Executable
+1
-1
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
until docker-compose -f docker-compose.yml exec frontend npm $1 $2
|
||||
until docker compose -f docker-compose.yml exec frontend npm $1 $2
|
||||
do
|
||||
echo "Ожидаю выполнения npm $1 $2"
|
||||
sleep 2
|
||||
|
||||
Regular → Executable
+3
-3
@@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
until docker-compose -f docker-compose.yml exec backend poetry $1 $2 $3
|
||||
until docker compose -f docker-compose.yml exec backend poetry add $1 $2 $3
|
||||
do
|
||||
echo "Ожидаю выполнения poetry $1 $2"
|
||||
echo "Ожидаю выполнения pip $1 $2"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# until docker-compose -f docker-compose.yml exec backend sh -c 'pip freeze >r.txt'
|
||||
# until docker-compose -f docker-compose.yml exec backend sh -c 'python -m pip freeze >r.txt'
|
||||
# do
|
||||
# echo "Обновляю список установленных пакетов..."
|
||||
# sleep 2
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ".env"
|
||||
AUTO_CONFIRM=false
|
||||
while getopts "y" opt; do
|
||||
case ${opt} in
|
||||
y )
|
||||
AUTO_CONFIRM=true
|
||||
;;
|
||||
\? )
|
||||
echo "Неверный флаг: -$OPTARG" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND -1))
|
||||
|
||||
|
||||
if [[ "${PRODUCTION}" != "False" ]]; then
|
||||
if [[ "$AUTO_CONFIRM" == false ]]; then
|
||||
read -p "Вы уверены, что хотите загрузить образы $COMPOSE_PROJECT_NAME? (y/n): " confirmation
|
||||
if [[ "$confirmation" != "y" && "$confirmation" != "Y" ]]; then
|
||||
echo "Операция отменена."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
for tar_file in ${LOCAL_FILES_DIR}/builds/images/*.tar; do
|
||||
if [ -f "$tar_file" ]; then # Проверяем, что это файл
|
||||
echo "Загружаю образ из файла: $tar_file"
|
||||
docker load -i "$tar_file"
|
||||
else
|
||||
echo "Нет tar-файлов в директории: $DIRECTORY"
|
||||
fi
|
||||
done
|
||||
echo "Контейнеры $COMPOSE_PROJECT_NAME загружены. Можно запускать"
|
||||
else
|
||||
echo "Переключись в продакшн"
|
||||
fi
|
||||
@@ -1,48 +0,0 @@
|
||||
[Unit]
|
||||
Description=gunicorn daemon
|
||||
Requires=gunicorn.socket
|
||||
After=network.target
|
||||
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
#WorkingDirectory=/var/www/proj/DQM/dqmback
|
||||
WorkingDirectory=/var/www/PORTAL_COD2/src
|
||||
# --timeout NNN - set timeout for gunicorn to NNN sec, default - 30sec
|
||||
# --access-logfile FILENAME - log all requests to file FILENAMEA
|
||||
# --error-logfile FILENAME - set error log file to FILENAME
|
||||
# Формат лог-файла кастомизируется, детали - в документации
|
||||
# --capture-output - redirect stdout/stderr to error-logfile
|
||||
# --log-syslog - send Gunicorn logs to Syslog
|
||||
# -log-syslog-prefix SYSLOG_PREFIX - set Syslog Prefix
|
||||
# --log-syslog-facility SYSLOG_FACILITY - set Syslog Facility, default - user(?-да, так в документации)
|
||||
# правильно пользовать local1..local7
|
||||
# --log-level=debug - set debug logging
|
||||
# levels: debug info warning error critical
|
||||
# details: https://docs.gunicorn.org/en/stable/settings.html#logging
|
||||
# --workers N - set number of workers to N
|
||||
# --bind unix:FILENAME - bind to unix socket with name FILENAME
|
||||
# --bind unix:/run/gunicorn.sock
|
||||
# --bind=127.0.0.1:9000 - bind to TCP socket 127.0.0.1:9000
|
||||
# default listen socket: 127.0.0.1:8000
|
||||
# --pid=PIDFILE - user file PIDFILE as PID File
|
||||
#
|
||||
# Howto debug NGinx+Gunicorn: https://mattsegal.dev/django-gunicorn-nginx-logging.html
|
||||
#
|
||||
#ExecStart=/usr/bin/gunicorn --workers 3 --bind unix:/var/www/application.sock wsgi:app
|
||||
|
||||
|
||||
#ExecStart=/var/www/sup/env/bin/uvicorn \
|
||||
ExecStart=/var/www/PORTAL_COD2/env/bin/gunicorn portal.wsgi:application --bind 10.252.44.60:9965 --workers 4 --error-logfile /var/log/portal/portal.error.log
|
||||
|
||||
|
||||
|
||||
# --access-logfile /var/log/gun-ukt/gun-ukt.access.log \
|
||||
# --workers 3 \
|
||||
# --timeout 600 \
|
||||
# --bind unix:/run/gunicorn.sock \
|
||||
# --limit-request-line 0 \
|
||||
# dqmback.wsgi:application
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=WebSocket Daphne Service for PORTAL_COD2-t
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
#Group = nginx
|
||||
WorkingDirectory=/var/www/PORTAL_COD2/src
|
||||
ExecStart=/var/www/PORTAL_COD2/env/bin/python /var/www/PORTAL_COD2/env/bin/daphne -p 9966 portal.asgi:application
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
|
||||
# Daphne, Django channels backend
|
||||
upstream portal-backend {
|
||||
server 127.0.0.1:9966;
|
||||
}
|
||||
|
||||
|
||||
# PORTAL Test server
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
server_name portal-t portal-t.cod2.regions.tax.nalog.ru;
|
||||
|
||||
send_timeout 600;
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
|
||||
root /var/www/PORTAL_COD2/src/front/dist/;
|
||||
include /etc/nginx/mime.types;
|
||||
access_log /var/log/nginx/portal.access.log;
|
||||
error_log /var/log/nginx/portal.error.log;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
location /static {
|
||||
autoindex on;
|
||||
alias /var/www/PORTAL_COD2/src/static/;
|
||||
}
|
||||
|
||||
location /media {
|
||||
alias /var/www/PORTAL_COD2/src/media;
|
||||
|
||||
}
|
||||
|
||||
location ^~ /api/ {
|
||||
client_max_body_size 100m;
|
||||
include proxy_params;
|
||||
proxy_pass http://portal-backend;
|
||||
}
|
||||
|
||||
location ^~ /admin {
|
||||
include proxy_params;
|
||||
proxy_pass http://portal-backend;
|
||||
}
|
||||
|
||||
|
||||
location /ws/ {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_redirect off;
|
||||
proxy_pass http://portal-backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user