From d2651c2be358e8d080065443377daee570b29ec3 Mon Sep 17 00:00:00 2001 From: ferdzo Date: Fri, 9 Jan 2026 14:27:55 +0100 Subject: [PATCH] Updated form, docker changes. --- .env.example | 3 + Dockerfile | 5 +- docker-compose.yml | 6 +- pyproject.toml | 4 +- serviceCRM/settings.py | 15 ++- serviceCRM/templates/serviceCRM/list.html | 4 +- serviceCRM/templates/serviceCRM/nalog.html | 40 +++--- .../templates/serviceCRM/print_receipt.html | 113 ++++++++++------ .../serviceCRM/public_track_form.html | 61 +++++---- .../serviceCRM/public_track_result.html | 84 ++++++------ serviceCRM/templates/table_tailwind.html | 125 ++++++++++++++++++ serviceCRM/views.py | 18 ++- uv.lock | 73 +++++++++- 13 files changed, 404 insertions(+), 147 deletions(-) create mode 100644 serviceCRM/templates/table_tailwind.html diff --git a/.env.example b/.env.example index e7c4d0d..2c24b57 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,4 @@ SECRET_KEY=django-insecure-change-me-in-production-!@#$%^&*() +# Comma separated list of trusted origins (include protocol) +CSRF_TRUSTED_ORIGINS=https://servis.ferdzo.xyz,https://www.servis.ferdzo.xyz + diff --git a/Dockerfile b/Dockerfile index 35d8c3b..f79419c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ COPY manage.py ./ RUN uv sync --frozen --no-dev +# Collect static files +RUN SECRET_KEY=dummy-key-for-build DEBUG=False uv run manage.py collectstatic --noinput FROM python:3.13-alpine @@ -24,6 +26,7 @@ RUN apk add --no-cache postgresql-client COPY --from=builder /app/.venv /app/.venv COPY --from=builder /app/serviceCRM/ /app/serviceCRM/ COPY --from=builder /app/manage.py /app/ +COPY --from=builder /app/staticfiles/ /app/staticfiles/ RUN adduser -D -u 1000 appuser && \ chown -R appuser:appuser /app @@ -35,4 +38,4 @@ ENV PYTHONUNBUFFERED=1 EXPOSE 8000 -CMD ["python", "-m", "uvicorn", "serviceCRM.asgi:application", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file +CMD ["gunicorn", "--bind", "0.0.0.0:8000", "-k", "uvicorn.workers.UvicornWorker", "serviceCRM.asgi:application"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b81bec6..346ed10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,10 @@ -version: '3.8' - services: web: build: . - volumes: - - .:/app ports: - "8000:8000" + volumes: + - ./db.sqlite3:/app/db.sqlite3 env_file: - .env environment: diff --git a/pyproject.toml b/pyproject.toml index 960dd47..f55cd1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "servicecrm" version = "0.1.0" description = "A CRM application built with Django." readme = "README.md" -requires-python = ">=3.14" +requires-python = ">=3.13" dependencies = [ "asgiref>=3.11.0", "cffi>=2.0.0", @@ -19,6 +19,7 @@ dependencies = [ "django-tables2>=2.8.0", "dnspython>=2.8.0", "feedparser>=6.0.12", + "gunicorn>=23.0.0", "nanoid>=2.0.0", "pillow>=12.1.0", "publicsuffix>=1.1.1", @@ -32,4 +33,5 @@ dependencies = [ "typing-extensions>=4.15.0", "tzdata>=2025.3", "uvicorn>=0.40.0", + "whitenoise>=6.11.0", ] diff --git a/serviceCRM/settings.py b/serviceCRM/settings.py index f6c684b..54cd7f6 100644 --- a/serviceCRM/settings.py +++ b/serviceCRM/settings.py @@ -29,6 +29,12 @@ DEBUG = env.bool('DEBUG', default=False) ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['*']) +CSRF_TRUSTED_ORIGINS = env.list('CSRF_TRUSTED_ORIGINS', default=[]) + +# Trust the X-Forwarded-Proto header for SSL +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') +USE_X_FORWARDED_HOST = True +USE_X_FORWARDED_PORT = True # Application definition @@ -39,7 +45,7 @@ INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', - 'whitenoise.runserver_nostatic', # Add whitenoise before staticfiles + # 'whitenoise.runserver_nostatic', # Removed to allow default Django static serving in dev 'django.contrib.staticfiles', 'crispy_forms', 'crispy_tailwind', @@ -57,6 +63,8 @@ DJANGO_TABLES2_TABLE_ATTRS = { 'class': 'bg-white divide-y divide-gray-200', }, } +DJANGO_TABLES2_TEMPLATE = "table_tailwind.html" + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # Add whitenoise middleware @@ -146,8 +154,11 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR / 'staticfiles' +STATICFILES_DIRS = [ + BASE_DIR / "serviceCRM" / "static", +] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' # Default primary key field type diff --git a/serviceCRM/templates/serviceCRM/list.html b/serviceCRM/templates/serviceCRM/list.html index 3b4ec4e..6b93c57 100644 --- a/serviceCRM/templates/serviceCRM/list.html +++ b/serviceCRM/templates/serviceCRM/list.html @@ -51,7 +51,5 @@ -
- {% render_table table %} -
+ {% render_table table %} {% endblock%} \ No newline at end of file diff --git a/serviceCRM/templates/serviceCRM/nalog.html b/serviceCRM/templates/serviceCRM/nalog.html index bd18cda..9d911ba 100644 --- a/serviceCRM/templates/serviceCRM/nalog.html +++ b/serviceCRM/templates/serviceCRM/nalog.html @@ -4,17 +4,17 @@
-

Сервисен Налог #{{ data.ticket_id }}

-

Креиран на {{ data.date }} (Интерен ID: {{ data.id }})

+

Сервисен Налог #{{ data.ticket_id }}

+

Креиран на {{ data.date }} (Интерен ID: {{ data.id }})

-
-
Име на клиент
-
{{ data.name }}
-
-
Телефонски број
-
{{ data.phone }}
+
Име на клиент
+
{{ data.name }}
-
-
Опис на дефект
-
{{ data.description }}
+
+
Телефонски број
+
{{ data.phone }}
-
-
Статус
-
{{ data.get_status_display }}
+
+
Опис на дефект
+
{{ data.description }}
+
+
+
Статус
+
{{ data.get_status_display }}
{% if data.note %} -
-
Интерна забелешка
-
{{ data.note }}
+
+
Интерна забелешка
+
{{ data.note }}
{% endif %} {% if data.done %} diff --git a/serviceCRM/templates/serviceCRM/print_receipt.html b/serviceCRM/templates/serviceCRM/print_receipt.html index c7fb4c0..2a02bf7 100644 --- a/serviceCRM/templates/serviceCRM/print_receipt.html +++ b/serviceCRM/templates/serviceCRM/print_receipt.html @@ -5,6 +5,7 @@ Потврда #{{ ticket.id }} +