Asistente V1
This commit is contained in:
parent
cd996ba56a
commit
1ff7bbc53c
0
.perm_test_apache
Normal file
0
.perm_test_apache
Normal file
0
.perm_test_exec
Normal file
0
.perm_test_exec
Normal file
3
ai/__init__.py
Normal file
3
ai/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"""Helpers for interacting with the Flatlogic AI proxy from Django code."""
|
||||||
|
|
||||||
|
from .local_ai_api import LocalAIApi, create_response, request, decode_json_from_response # noqa: F401
|
||||||
420
ai/local_ai_api.py
Normal file
420
ai/local_ai_api.py
Normal file
@ -0,0 +1,420 @@
|
|||||||
|
"""
|
||||||
|
LocalAIApi — lightweight Python client for the Flatlogic AI proxy.
|
||||||
|
|
||||||
|
Usage (inside the Django workspace):
|
||||||
|
|
||||||
|
from ai.local_ai_api import LocalAIApi
|
||||||
|
|
||||||
|
response = LocalAIApi.create_response({
|
||||||
|
"input": [
|
||||||
|
{"role": "system", "content": "You are a helpful assistant."},
|
||||||
|
{"role": "user", "content": "Summarise this text in two sentences."},
|
||||||
|
],
|
||||||
|
"text": {"format": {"type": "json_object"}},
|
||||||
|
})
|
||||||
|
|
||||||
|
if response.get("success"):
|
||||||
|
data = LocalAIApi.decode_json_from_response(response)
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# Typical successful payload (truncated):
|
||||||
|
# {
|
||||||
|
# "id": "resp_xxx",
|
||||||
|
# "status": "completed",
|
||||||
|
# "output": [
|
||||||
|
# {"type": "reasoning", "summary": []},
|
||||||
|
# {"type": "message", "content": [{"type": "output_text", "text": "Your final answer here."}]}
|
||||||
|
# ],
|
||||||
|
# "usage": { "input_tokens": 123, "output_tokens": 456 }
|
||||||
|
# }
|
||||||
|
|
||||||
|
The helper automatically injects the project UUID header and falls back to
|
||||||
|
reading executor/.env if environment variables are missing.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import ssl
|
||||||
|
from typing import Any, Dict, Iterable, Optional
|
||||||
|
from urllib import error as urlerror
|
||||||
|
from urllib import request as urlrequest
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"LocalAIApi",
|
||||||
|
"create_response",
|
||||||
|
"request",
|
||||||
|
"fetch_status",
|
||||||
|
"await_response",
|
||||||
|
"extract_text",
|
||||||
|
"decode_json_from_response",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
_CONFIG_CACHE: Optional[Dict[str, Any]] = None
|
||||||
|
|
||||||
|
|
||||||
|
class LocalAIApi:
|
||||||
|
"""Static helpers mirroring the PHP implementation."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_response(params: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
return create_response(params, options or {})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def request(path: Optional[str] = None, payload: Optional[Dict[str, Any]] = None,
|
||||||
|
options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
return request(path, payload or {}, options or {})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def extract_text(response: Dict[str, Any]) -> str:
|
||||||
|
return extract_text(response)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def decode_json_from_response(response: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
||||||
|
return decode_json_from_response(response)
|
||||||
|
|
||||||
|
|
||||||
|
def create_response(params: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
"""Signature compatible with the OpenAI Responses API."""
|
||||||
|
options = options or {}
|
||||||
|
payload = dict(params)
|
||||||
|
|
||||||
|
if not isinstance(payload.get("input"), list) or not payload["input"]:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "input_missing",
|
||||||
|
"message": 'Parameter "input" is required and must be a non-empty list.',
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg = _config()
|
||||||
|
if not payload.get("model"):
|
||||||
|
payload["model"] = cfg["default_model"]
|
||||||
|
|
||||||
|
initial = request(options.get("path"), payload, options)
|
||||||
|
if not initial.get("success"):
|
||||||
|
return initial
|
||||||
|
|
||||||
|
data = initial.get("data")
|
||||||
|
if isinstance(data, dict) and "ai_request_id" in data:
|
||||||
|
ai_request_id = data["ai_request_id"]
|
||||||
|
poll_timeout = int(options.get("poll_timeout", 300))
|
||||||
|
poll_interval = int(options.get("poll_interval", 5))
|
||||||
|
return await_response(ai_request_id, {
|
||||||
|
"interval": poll_interval,
|
||||||
|
"timeout": poll_timeout,
|
||||||
|
"headers": options.get("headers"),
|
||||||
|
"timeout_per_call": options.get("timeout"),
|
||||||
|
})
|
||||||
|
|
||||||
|
return initial
|
||||||
|
|
||||||
|
|
||||||
|
def request(path: Optional[str], payload: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
"""Perform a raw request to the AI proxy."""
|
||||||
|
cfg = _config()
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
resolved_path = path or options.get("path") or cfg["responses_path"]
|
||||||
|
if not resolved_path:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "project_id_missing",
|
||||||
|
"message": "PROJECT_ID is not defined; cannot resolve AI proxy endpoint.",
|
||||||
|
}
|
||||||
|
|
||||||
|
project_uuid = cfg["project_uuid"]
|
||||||
|
if not project_uuid:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "project_uuid_missing",
|
||||||
|
"message": "PROJECT_UUID is not defined; aborting AI request.",
|
||||||
|
}
|
||||||
|
|
||||||
|
if "project_uuid" not in payload and project_uuid:
|
||||||
|
payload["project_uuid"] = project_uuid
|
||||||
|
|
||||||
|
url = _build_url(resolved_path, cfg["base_url"])
|
||||||
|
opt_timeout = options.get("timeout")
|
||||||
|
timeout = int(cfg["timeout"] if opt_timeout is None else opt_timeout)
|
||||||
|
verify_tls = options.get("verify_tls", cfg["verify_tls"])
|
||||||
|
|
||||||
|
headers: Dict[str, str] = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json",
|
||||||
|
cfg["project_header"]: project_uuid,
|
||||||
|
}
|
||||||
|
extra_headers = options.get("headers")
|
||||||
|
if isinstance(extra_headers, Iterable):
|
||||||
|
for header in extra_headers:
|
||||||
|
if isinstance(header, str) and ":" in header:
|
||||||
|
name, value = header.split(":", 1)
|
||||||
|
headers[name.strip()] = value.strip()
|
||||||
|
|
||||||
|
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
|
||||||
|
return _http_request(url, "POST", body, headers, timeout, verify_tls)
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_status(ai_request_id: Any, options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
"""Fetch status for a queued AI request."""
|
||||||
|
cfg = _config()
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
project_uuid = cfg["project_uuid"]
|
||||||
|
if not project_uuid:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "project_uuid_missing",
|
||||||
|
"message": "PROJECT_UUID is not defined; aborting status check.",
|
||||||
|
}
|
||||||
|
|
||||||
|
status_path = _resolve_status_path(ai_request_id, cfg)
|
||||||
|
url = _build_url(status_path, cfg["base_url"])
|
||||||
|
|
||||||
|
opt_timeout = options.get("timeout")
|
||||||
|
timeout = int(cfg["timeout"] if opt_timeout is None else opt_timeout)
|
||||||
|
verify_tls = options.get("verify_tls", cfg["verify_tls"])
|
||||||
|
|
||||||
|
headers: Dict[str, str] = {
|
||||||
|
"Accept": "application/json",
|
||||||
|
cfg["project_header"]: project_uuid,
|
||||||
|
}
|
||||||
|
extra_headers = options.get("headers")
|
||||||
|
if isinstance(extra_headers, Iterable):
|
||||||
|
for header in extra_headers:
|
||||||
|
if isinstance(header, str) and ":" in header:
|
||||||
|
name, value = header.split(":", 1)
|
||||||
|
headers[name.strip()] = value.strip()
|
||||||
|
|
||||||
|
return _http_request(url, "GET", None, headers, timeout, verify_tls)
|
||||||
|
|
||||||
|
|
||||||
|
def await_response(ai_request_id: Any, options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
"""Poll status endpoint until the request is complete or timed out."""
|
||||||
|
options = options or {}
|
||||||
|
timeout = int(options.get("timeout", 300))
|
||||||
|
interval = int(options.get("interval", 5))
|
||||||
|
if interval <= 0:
|
||||||
|
interval = 5
|
||||||
|
per_call_timeout = options.get("timeout_per_call")
|
||||||
|
|
||||||
|
deadline = time.time() + max(timeout, interval)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
status_resp = fetch_status(ai_request_id, {
|
||||||
|
"headers": options.get("headers"),
|
||||||
|
"timeout": per_call_timeout,
|
||||||
|
"verify_tls": options.get("verify_tls"),
|
||||||
|
})
|
||||||
|
if status_resp.get("success"):
|
||||||
|
data = status_resp.get("data") or {}
|
||||||
|
if isinstance(data, dict):
|
||||||
|
status_value = data.get("status")
|
||||||
|
if status_value == "success":
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"status": 200,
|
||||||
|
"data": data.get("response", data),
|
||||||
|
}
|
||||||
|
if status_value == "failed":
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"status": 500,
|
||||||
|
"error": str(data.get("error") or "AI request failed"),
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return status_resp
|
||||||
|
|
||||||
|
if time.time() >= deadline:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "timeout",
|
||||||
|
"message": "Timed out waiting for AI response.",
|
||||||
|
}
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
|
||||||
|
def extract_text(response: Dict[str, Any]) -> str:
|
||||||
|
"""Public helper to extract plain text from a Responses payload."""
|
||||||
|
return _extract_text(response)
|
||||||
|
|
||||||
|
|
||||||
|
def decode_json_from_response(response: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
||||||
|
"""Attempt to decode JSON emitted by the model (handles markdown fences)."""
|
||||||
|
text = _extract_text(response)
|
||||||
|
if text == "":
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
decoded = json.loads(text)
|
||||||
|
if isinstance(decoded, dict):
|
||||||
|
return decoded
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
stripped = text.strip()
|
||||||
|
if stripped.startswith("```json"):
|
||||||
|
stripped = stripped[7:]
|
||||||
|
if stripped.endswith("```"):
|
||||||
|
stripped = stripped[:-3]
|
||||||
|
stripped = stripped.strip()
|
||||||
|
if stripped and stripped != text:
|
||||||
|
try:
|
||||||
|
decoded = json.loads(stripped)
|
||||||
|
if isinstance(decoded, dict):
|
||||||
|
return decoded
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
return None
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_text(response: Dict[str, Any]) -> str:
|
||||||
|
payload = response.get("data") if response.get("success") else response.get("response")
|
||||||
|
if isinstance(payload, dict):
|
||||||
|
output = payload.get("output")
|
||||||
|
if isinstance(output, list):
|
||||||
|
combined = ""
|
||||||
|
for item in output:
|
||||||
|
content = item.get("content") if isinstance(item, dict) else None
|
||||||
|
if isinstance(content, list):
|
||||||
|
for block in content:
|
||||||
|
if isinstance(block, dict) and block.get("type") == "output_text" and block.get("text"):
|
||||||
|
combined += str(block["text"])
|
||||||
|
if combined:
|
||||||
|
return combined
|
||||||
|
choices = payload.get("choices")
|
||||||
|
if isinstance(choices, list) and choices:
|
||||||
|
message = choices[0].get("message")
|
||||||
|
if isinstance(message, dict) and message.get("content"):
|
||||||
|
return str(message["content"])
|
||||||
|
if isinstance(payload, str):
|
||||||
|
return payload
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def _config() -> Dict[str, Any]:
|
||||||
|
global _CONFIG_CACHE # noqa: PLW0603
|
||||||
|
if _CONFIG_CACHE is not None:
|
||||||
|
return _CONFIG_CACHE
|
||||||
|
|
||||||
|
_ensure_env_loaded()
|
||||||
|
|
||||||
|
base_url = os.getenv("AI_PROXY_BASE_URL", "https://flatlogic.com")
|
||||||
|
project_id = os.getenv("PROJECT_ID") or None
|
||||||
|
responses_path = os.getenv("AI_RESPONSES_PATH")
|
||||||
|
if not responses_path and project_id:
|
||||||
|
responses_path = f"/projects/{project_id}/ai-request"
|
||||||
|
|
||||||
|
_CONFIG_CACHE = {
|
||||||
|
"base_url": base_url,
|
||||||
|
"responses_path": responses_path,
|
||||||
|
"project_id": project_id,
|
||||||
|
"project_uuid": os.getenv("PROJECT_UUID"),
|
||||||
|
"project_header": os.getenv("AI_PROJECT_HEADER", "project-uuid"),
|
||||||
|
"default_model": os.getenv("AI_DEFAULT_MODEL", "gpt-5-mini"),
|
||||||
|
"timeout": int(os.getenv("AI_TIMEOUT", "30")),
|
||||||
|
"verify_tls": os.getenv("AI_VERIFY_TLS", "true").lower() not in {"0", "false", "no"},
|
||||||
|
}
|
||||||
|
return _CONFIG_CACHE
|
||||||
|
|
||||||
|
|
||||||
|
def _build_url(path: str, base_url: str) -> str:
|
||||||
|
trimmed = path.strip()
|
||||||
|
if trimmed.startswith("http://") or trimmed.startswith("https://"):
|
||||||
|
return trimmed
|
||||||
|
if trimmed.startswith("/"):
|
||||||
|
return f"{base_url}{trimmed}"
|
||||||
|
return f"{base_url}/{trimmed}"
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_status_path(ai_request_id: Any, cfg: Dict[str, Any]) -> str:
|
||||||
|
base_path = (cfg.get("responses_path") or "").rstrip("/")
|
||||||
|
if not base_path:
|
||||||
|
return f"/ai-request/{ai_request_id}/status"
|
||||||
|
if not base_path.endswith("/ai-request"):
|
||||||
|
base_path = f"{base_path}/ai-request"
|
||||||
|
return f"{base_path}/{ai_request_id}/status"
|
||||||
|
|
||||||
|
|
||||||
|
def _http_request(url: str, method: str, body: Optional[bytes], headers: Dict[str, str],
|
||||||
|
timeout: int, verify_tls: bool) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Shared HTTP helper for GET/POST requests.
|
||||||
|
"""
|
||||||
|
req = urlrequest.Request(url, data=body, method=method.upper())
|
||||||
|
for name, value in headers.items():
|
||||||
|
req.add_header(name, value)
|
||||||
|
|
||||||
|
context = None
|
||||||
|
if not verify_tls:
|
||||||
|
context = ssl.create_default_context()
|
||||||
|
context.check_hostname = False
|
||||||
|
context.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
|
try:
|
||||||
|
with urlrequest.urlopen(req, timeout=timeout, context=context) as resp:
|
||||||
|
status = resp.getcode()
|
||||||
|
response_body = resp.read().decode("utf-8", errors="replace")
|
||||||
|
except urlerror.HTTPError as exc:
|
||||||
|
status = exc.getcode()
|
||||||
|
response_body = exc.read().decode("utf-8", errors="replace")
|
||||||
|
except Exception as exc: # pylint: disable=broad-except
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"error": "request_failed",
|
||||||
|
"message": str(exc),
|
||||||
|
}
|
||||||
|
|
||||||
|
decoded = None
|
||||||
|
if response_body:
|
||||||
|
try:
|
||||||
|
decoded = json.loads(response_body)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
decoded = None
|
||||||
|
|
||||||
|
if 200 <= status < 300:
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"status": status,
|
||||||
|
"data": decoded if decoded is not None else response_body,
|
||||||
|
}
|
||||||
|
|
||||||
|
error_message = "AI proxy request failed"
|
||||||
|
if isinstance(decoded, dict):
|
||||||
|
error_message = decoded.get("error") or decoded.get("message") or error_message
|
||||||
|
elif response_body:
|
||||||
|
error_message = response_body
|
||||||
|
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"status": status,
|
||||||
|
"error": error_message,
|
||||||
|
"response": decoded if decoded is not None else response_body,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _ensure_env_loaded() -> None:
|
||||||
|
"""Populate os.environ from executor/.env if variables are missing."""
|
||||||
|
if os.getenv("PROJECT_UUID") and os.getenv("PROJECT_ID"):
|
||||||
|
return
|
||||||
|
|
||||||
|
env_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".env"))
|
||||||
|
if not os.path.exists(env_path):
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(env_path, "r", encoding="utf-8") as handle:
|
||||||
|
for line in handle:
|
||||||
|
stripped = line.strip()
|
||||||
|
if not stripped or stripped.startswith("#") or "=" not in stripped:
|
||||||
|
continue
|
||||||
|
key, value = stripped.split("=", 1)
|
||||||
|
key = key.strip()
|
||||||
|
value = value.strip().strip('\'"')
|
||||||
|
if key and not os.getenv(key):
|
||||||
|
os.environ[key] = value
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -126,9 +126,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'es-es'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'Europe/Madrid'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
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,8 +1,20 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Ticket
|
from .models import MachineModel, SparePart, ServiceIntervention
|
||||||
|
|
||||||
@admin.register(Ticket)
|
@admin.register(MachineModel)
|
||||||
class TicketAdmin(admin.ModelAdmin):
|
class MachineModelAdmin(admin.ModelAdmin):
|
||||||
list_display = ('subject', 'status', 'priority', 'requester_email', 'created_at')
|
list_display = ('name', 'brand')
|
||||||
list_filter = ('status', 'priority')
|
search_fields = ('name', 'brand')
|
||||||
search_fields = ('subject', 'requester_email', 'description')
|
|
||||||
|
@admin.register(SparePart)
|
||||||
|
class SparePartAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('name', 'reference_code', 'stock_quantity')
|
||||||
|
search_fields = ('name', 'reference_code')
|
||||||
|
list_filter = ('stock_quantity',)
|
||||||
|
|
||||||
|
@admin.register(ServiceIntervention)
|
||||||
|
class ServiceInterventionAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('machine', 'technician', 'status', 'created_at')
|
||||||
|
list_filter = ('status', 'technician', 'created_at')
|
||||||
|
search_fields = ('machine__name', 'description')
|
||||||
|
autocomplete_fields = ('machine', 'technician')
|
||||||
13
core/context_processors.py
Normal file
13
core/context_processors.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
def project_context(request):
|
||||||
|
"""
|
||||||
|
Adds project-specific environment variables to the template context globally.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
|
||||||
|
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
||||||
|
# Used for cache-busting static assets
|
||||||
|
"deployment_timestamp": int(time.time()),
|
||||||
|
}
|
||||||
@ -1,7 +1 @@
|
|||||||
from django import forms
|
# No forms yet.
|
||||||
from .models import Ticket
|
|
||||||
|
|
||||||
class TicketForm(forms.ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = Ticket
|
|
||||||
fields = ['subject', 'requester_email', 'priority', 'description']
|
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2025-11-27 07:45
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0001_initial'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MachineModel',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('brand', models.CharField(max_length=100)),
|
||||||
|
('manual_pdf', models.FileField(blank=True, null=True, upload_to='manuals/')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ServiceIntervention',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('status', models.CharField(choices=[('PENDING', 'Pending'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('CANCELLED', 'Cancelled')], default='PENDING', max_length=20)),
|
||||||
|
('description', models.TextField()),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('resolved_at', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('machine', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='interventions', to='core.machinemodel')),
|
||||||
|
('technician', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='interventions', to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SparePart',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('reference_code', models.CharField(max_length=100, unique=True)),
|
||||||
|
('name', models.CharField(max_length=200)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
('stock_quantity', models.PositiveIntegerField(default=0)),
|
||||||
|
('low_stock_threshold', models.PositiveIntegerField(default=10)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Ticket',
|
||||||
|
),
|
||||||
|
]
|
||||||
98
core/migrations/0003_alter_machinemodel_options_and_more.py
Normal file
98
core/migrations/0003_alter_machinemodel_options_and_more.py
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2025-11-27 07:49
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0002_machinemodel_serviceintervention_sparepart_and_more'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='machinemodel',
|
||||||
|
options={'verbose_name': 'Modelo de Máquina', 'verbose_name_plural': 'Modelos de Máquinas'},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='serviceintervention',
|
||||||
|
options={'verbose_name': 'Intervención de Servicio', 'verbose_name_plural': 'Intervenciones de Servicio'},
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='sparepart',
|
||||||
|
options={'verbose_name': 'Repuesto', 'verbose_name_plural': 'Repuestos'},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='machinemodel',
|
||||||
|
name='brand',
|
||||||
|
field=models.CharField(max_length=100, verbose_name='Marca'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='machinemodel',
|
||||||
|
name='manual_pdf',
|
||||||
|
field=models.FileField(blank=True, null=True, upload_to='manuals/', verbose_name='Manual (PDF)'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='machinemodel',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=200, verbose_name='Nombre'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='created_at',
|
||||||
|
field=models.DateTimeField(auto_now_add=True, verbose_name='Fecha de Creación'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(verbose_name='Descripción'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='machine',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='interventions', to='core.machinemodel', verbose_name='Máquina'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='resolved_at',
|
||||||
|
field=models.DateTimeField(blank=True, null=True, verbose_name='Fecha de Resolución'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='status',
|
||||||
|
field=models.CharField(choices=[('PENDING', 'Pendiente'), ('IN_PROGRESS', 'En Progreso'), ('COMPLETED', 'Completada'), ('CANCELLED', 'Cancelada')], default='PENDING', max_length=20, verbose_name='Estado'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='serviceintervention',
|
||||||
|
name='technician',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='interventions', to=settings.AUTH_USER_MODEL, verbose_name='Técnico'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sparepart',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(blank=True, verbose_name='Descripción'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sparepart',
|
||||||
|
name='low_stock_threshold',
|
||||||
|
field=models.PositiveIntegerField(default=10, verbose_name='Umbral de Stock Bajo'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sparepart',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=200, verbose_name='Nombre'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sparepart',
|
||||||
|
name='reference_code',
|
||||||
|
field=models.CharField(max_length=100, unique=True, verbose_name='Código de Referencia'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sparepart',
|
||||||
|
name='stock_quantity',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='Cantidad en Stock'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,25 +1,50 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
class Ticket(models.Model):
|
class MachineModel(models.Model):
|
||||||
STATUS_CHOICES = [
|
name = models.CharField("Nombre", max_length=200)
|
||||||
('open', 'Open'),
|
brand = models.CharField("Marca", max_length=100)
|
||||||
('in_progress', 'In Progress'),
|
manual_pdf = models.FileField("Manual (PDF)", upload_to='manuals/', blank=True, null=True)
|
||||||
('closed', 'Closed'),
|
|
||||||
]
|
|
||||||
|
|
||||||
PRIORITY_CHOICES = [
|
class Meta:
|
||||||
('low', 'Low'),
|
verbose_name = "Modelo de Máquina"
|
||||||
('medium', 'Medium'),
|
verbose_name_plural = "Modelos de Máquinas"
|
||||||
('high', 'High'),
|
|
||||||
]
|
|
||||||
|
|
||||||
subject = models.CharField(max_length=255)
|
|
||||||
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='open')
|
|
||||||
priority = models.CharField(max_length=20, choices=PRIORITY_CHOICES, default='medium')
|
|
||||||
requester_email = models.EmailField()
|
|
||||||
description = models.TextField()
|
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.subject
|
return f"{self.brand} {self.name}"
|
||||||
|
|
||||||
|
class SparePart(models.Model):
|
||||||
|
reference_code = models.CharField("Código de Referencia", max_length=100, unique=True)
|
||||||
|
name = models.CharField("Nombre", max_length=200)
|
||||||
|
description = models.TextField("Descripción", blank=True)
|
||||||
|
stock_quantity = models.PositiveIntegerField("Cantidad en Stock", default=0)
|
||||||
|
low_stock_threshold = models.PositiveIntegerField("Umbral de Stock Bajo", default=10)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Repuesto"
|
||||||
|
verbose_name_plural = "Repuestos"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class ServiceIntervention(models.Model):
|
||||||
|
STATUS_CHOICES = [
|
||||||
|
('PENDING', 'Pendiente'),
|
||||||
|
('IN_PROGRESS', 'En Progreso'),
|
||||||
|
('COMPLETED', 'Completada'),
|
||||||
|
('CANCELLED', 'Cancelada'),
|
||||||
|
]
|
||||||
|
|
||||||
|
machine = models.ForeignKey(MachineModel, on_delete=models.CASCADE, related_name='interventions', verbose_name="Máquina")
|
||||||
|
technician = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='interventions', verbose_name="Técnico")
|
||||||
|
status = models.CharField("Estado", max_length=20, choices=STATUS_CHOICES, default='PENDING')
|
||||||
|
description = models.TextField("Descripción")
|
||||||
|
created_at = models.DateTimeField("Fecha de Creación", auto_now_add=True)
|
||||||
|
resolved_at = models.DateTimeField("Fecha de Resolución", null=True, blank=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Intervención de Servicio"
|
||||||
|
verbose_name_plural = "Intervenciones de Servicio"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Intervención para {self.machine} el {self.created_at.strftime('%d-%m-%Y')}"
|
||||||
30
core/templates/base.html
Normal file
30
core/templates/base.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>{% block title %}Knowledge Base{% endblock %}</title>
|
||||||
|
{% if project_description %}
|
||||||
|
<meta name="description" content="{{ project_description }}">
|
||||||
|
<meta property="og:description" content="{{ project_description }}">
|
||||||
|
<meta property="twitter:description" content="{{ project_description }}">
|
||||||
|
{% endif %}
|
||||||
|
{% if project_image_url %}
|
||||||
|
<meta property="og:image" content="{{ project_image_url }}">
|
||||||
|
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||||
|
{% endif %}
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
{% load static %}
|
||||||
|
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
|
||||||
|
{% block head %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
14
core/templates/core/article_detail.html
Normal file
14
core/templates/core/article_detail.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}{{ article.title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container mt-5">
|
||||||
|
<h1>{{ article.title }}</h1>
|
||||||
|
<p class="text-muted">Published on {{ article.created_at|date:"F d, Y" }}</p>
|
||||||
|
<hr>
|
||||||
|
<div>
|
||||||
|
{{ article.content|safe }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@ -1,157 +1,74 @@
|
|||||||
<!doctype html>
|
{% extends 'base.html' %}
|
||||||
<html lang="en">
|
{% load static %}
|
||||||
|
|
||||||
<head>
|
{% block title %}{{ project_name }} - Panel de Control{% endblock %}
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>{{ project_name }}</title>
|
|
||||||
{% if project_description %}
|
|
||||||
<meta name="description" content="{{ project_description }}">
|
|
||||||
<meta property="og:description" content="{{ project_description }}">
|
|
||||||
<meta property="twitter:description" content="{{ project_description }}">
|
|
||||||
{% endif %}
|
|
||||||
{% if project_image_url %}
|
|
||||||
<meta property="og:image" content="{{ project_image_url }}">
|
|
||||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
|
||||||
{% endif %}
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--bg-color-start: #6a11cb;
|
|
||||||
--bg-color-end: #2575fc;
|
|
||||||
--text-color: #ffffff;
|
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.08);
|
|
||||||
--card-border-color: rgba(255, 255, 255, 0.18);
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
{% block content %}
|
||||||
box-sizing: border-box;
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
||||||
}
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="#">{{ project_name }}</a>
|
||||||
body {
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
margin: 0;
|
<span class="navbar-toggler-icon"></span>
|
||||||
font-family: 'Inter', sans-serif;
|
</button>
|
||||||
background: linear-gradient(130deg, var(--bg-color-start), var(--bg-color-end));
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
color: var(--text-color);
|
<ul class="navbar-nav ms-auto">
|
||||||
display: flex;
|
<li class="nav-item">
|
||||||
justify-content: center;
|
<a class="nav-link active" aria-current="page" href="#">Panel de Control</a>
|
||||||
align-items: center;
|
</li>
|
||||||
min-height: 100vh;
|
<li class="nav-item">
|
||||||
text-align: center;
|
<a class="nav-link" href="/admin">Administración</a>
|
||||||
overflow: hidden;
|
</li>
|
||||||
position: relative;
|
</ul>
|
||||||
}
|
|
||||||
|
|
||||||
body::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><path d='M-20 20L160 20M20 -20L20 160' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
|
|
||||||
animation: bg-pan 24s linear infinite;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes bg-pan {
|
|
||||||
0% {
|
|
||||||
transform: translate3d(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
transform: translate3d(-140px, -140px, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
padding: clamp(2rem, 4vw, 3rem);
|
|
||||||
width: min(640px, 92vw);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: var(--card-bg-color);
|
|
||||||
border: 1px solid var(--card-border-color);
|
|
||||||
border-radius: 20px;
|
|
||||||
padding: clamp(2rem, 4vw, 3rem);
|
|
||||||
backdrop-filter: blur(24px);
|
|
||||||
-webkit-backdrop-filter: blur(24px);
|
|
||||||
box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
margin: 0 0 1.2rem;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: clamp(2.2rem, 3vw + 1.3rem, 3rem);
|
|
||||||
letter-spacing: -0.04em;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0.6rem 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
line-height: 1.7;
|
|
||||||
opacity: 0.92;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader {
|
|
||||||
margin: 1.5rem auto;
|
|
||||||
width: 56px;
|
|
||||||
height: 56px;
|
|
||||||
border: 4px solid rgba(255, 255, 255, 0.25);
|
|
||||||
border-top-color: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.sr-only {
|
|
||||||
position: absolute;
|
|
||||||
width: 1px;
|
|
||||||
height: 1px;
|
|
||||||
padding: 0;
|
|
||||||
margin: -1px;
|
|
||||||
overflow: hidden;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
background: rgba(15, 23, 42, 0.35);
|
|
||||||
padding: 0.2rem 0.6rem;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
margin-top: 2.4rem;
|
|
||||||
font-size: 0.86rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<main>
|
|
||||||
<div class="card">
|
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
|
||||||
<span class="sr-only">Loading…</span>
|
|
||||||
</div>
|
</div>
|
||||||
<p>Appwizzy AI is collecting your requirements and applying the first changes.</p>
|
|
||||||
<p>This page will refresh automatically as the plan is implemented.</p>
|
|
||||||
<p>
|
|
||||||
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code> —
|
|
||||||
UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
</nav>
|
||||||
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
|
|
||||||
</footer>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
<div class="hero-section text-center mb-5">
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="display-4">Bienvenido al Asistente de Reparación</h1>
|
||||||
|
<p class="lead">Su guía para diagnosticar y reparar máquinas Nespresso.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row text-center">
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<div class="card stat-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="stat-number">{{ intervention_count }}</div>
|
||||||
|
<div class="card-title">Intervenciones Totales</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<div class="card stat-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="stat-number">{{ pending_interventions }}</div>
|
||||||
|
<div class="card-title">Intervenciones Pendientes</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<div class="card stat-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="stat-number">{{ spare_part_count }}</div>
|
||||||
|
<div class="card-title">Repuestos</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-3 mb-4">
|
||||||
|
<div class="card stat-card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="stat-number">{{ machine_model_count }}</div>
|
||||||
|
<div class="card-title">Modelos de Máquinas</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@ -1,7 +1,9 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import home
|
from django.urls import path
|
||||||
|
|
||||||
|
from .views import index
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", home, name="home"),
|
path("", index, name="index"),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -3,35 +3,33 @@ import platform
|
|||||||
|
|
||||||
from django import get_version as django_version
|
from django import get_version as django_version
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.urls import reverse_lazy
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.views.generic.edit import CreateView
|
|
||||||
|
|
||||||
from .forms import TicketForm
|
from .models import MachineModel, SparePart, ServiceIntervention
|
||||||
from .models import Ticket
|
|
||||||
|
|
||||||
|
|
||||||
def home(request):
|
def index(request):
|
||||||
"""Render the landing screen with loader and environment details."""
|
"""Render the landing screen with dashboard stats."""
|
||||||
host_name = request.get_host().lower()
|
host_name = request.get_host().lower()
|
||||||
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
|
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"project_name": "New Style",
|
"project_name": "Nespresso Repair Assistant",
|
||||||
"agent_brand": agent_brand,
|
"agent_brand": agent_brand,
|
||||||
"django_version": django_version(),
|
"django_version": django_version(),
|
||||||
"python_version": platform.python_version(),
|
"python_version": platform.python_version(),
|
||||||
"current_time": now,
|
"current_time": now,
|
||||||
"host_name": host_name,
|
"host_name": host_name,
|
||||||
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
|
"project_description": os.getenv("PROJECT_DESCRIPTION", "A guided tool for Nespresso machine repairs."),
|
||||||
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
|
||||||
|
"intervention_count": ServiceIntervention.objects.count(),
|
||||||
|
"spare_part_count": SparePart.objects.count(),
|
||||||
|
"machine_model_count": MachineModel.objects.count(),
|
||||||
|
"pending_interventions": ServiceIntervention.objects.filter(status='PENDING').count(),
|
||||||
}
|
}
|
||||||
return render(request, "core/index.html", context)
|
return render(request, "core/index.html", context)
|
||||||
|
|
||||||
|
|
||||||
class TicketCreateView(CreateView):
|
def article_detail(request):
|
||||||
model = Ticket
|
return render(request, "core/article_detail.html")
|
||||||
form_class = TicketForm
|
|
||||||
template_name = "core/ticket_create.html"
|
|
||||||
success_url = reverse_lazy("home")
|
|
||||||
70
static/css/custom.css
Normal file
70
static/css/custom.css
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Custom Styles for Nespresso Repair Assistant
|
||||||
|
*/
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--primary-color: #1A237E;
|
||||||
|
--secondary-color: #FFAB00;
|
||||||
|
--accent-color: #82B1FF;
|
||||||
|
--background-color: #F5F5F5;
|
||||||
|
--text-color: #212121;
|
||||||
|
--font-family-headings: 'Poppins', sans-serif;
|
||||||
|
--font-family-body: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
font-family: var(--font-family-body);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: var(--font-family-headings);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-section {
|
||||||
|
background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
|
||||||
|
color: white;
|
||||||
|
padding: 4rem 2rem;
|
||||||
|
border-radius: 0 0 2rem 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-section h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background-color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 1rem;
|
||||||
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
|
||||||
|
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .card-body {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .stat-number {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .card-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-family: var(--font-family-headings);
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color) !important;
|
||||||
|
}
|
||||||
@ -1,21 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Custom Styles for Nespresso Repair Assistant
|
||||||
|
*/
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--bg-color-start: #6a11cb;
|
--primary-color: #1A237E;
|
||||||
--bg-color-end: #2575fc;
|
--secondary-color: #FFAB00;
|
||||||
--text-color: #ffffff;
|
--accent-color: #82B1FF;
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
--background-color: #F5F5F5;
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
--text-color: #212121;
|
||||||
|
--font-family-headings: 'Poppins', sans-serif;
|
||||||
|
--font-family-body: 'Roboto', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
background-color: var(--background-color);
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: var(--font-family-body);
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
display: flex;
|
}
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
h1, h2, h3, h4, h5, h6 {
|
||||||
min-height: 100vh;
|
font-family: var(--font-family-headings);
|
||||||
text-align: center;
|
font-weight: 600;
|
||||||
overflow: hidden;
|
}
|
||||||
position: relative;
|
|
||||||
|
.hero-section {
|
||||||
|
background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
|
||||||
|
color: white;
|
||||||
|
padding: 4rem 2rem;
|
||||||
|
border-radius: 0 0 2rem 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-section h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background-color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 1rem;
|
||||||
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
|
||||||
|
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .card-body {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .stat-number {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .card-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-family: var(--font-family-headings);
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--primary-color) !important;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user