Versiunea funcțională EUMI

This commit is contained in:
2026-08-31 16:10:46 +03:00
parent 75bcef3095
commit ce5028a27f
58 changed files with 4271 additions and 98 deletions
@@ -0,0 +1,32 @@
{% extends 'base.html' %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="fw-bold">Intervenții (Helpdesk)</h2>
<!-- HTMX Live Search Input -->
<input class="form-control w-25" type="search"
name="search" placeholder="Caută tichet..."
hx-get="{% url 'interventions:intervention_list' %}"
hx-trigger="input changed delay:400ms, search"
hx-target="#ticket-table-body">
</div>
<div class="card shadow-sm">
<table class="table table-striped table-hover mb-0">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Subiect & Descriere</th>
<th>Raportat de</th>
<th>Status</th>
<th>Prioritate</th>
<th>Data Raportării</th>
</tr>
</thead>
<tbody id="ticket-table-body">
{% include 'interventions/partials/ticket_table.html' %}
</tbody>
</table>
</div>
{% endblock %}
@@ -0,0 +1,41 @@
{% for ticket in tickets %}
<tr>
<td class="align-middle fw-medium">#{{ ticket.id }}</td>
<td class="align-middle">
<strong>{{ ticket.title }}</strong><br>
<small class="text-muted text-truncate d-inline-block" style="max-width: 300px;">
{{ ticket.description }}
</small>
</td>
<td class="align-middle">{{ ticket.reported_by.name }}</td>
<td class="align-middle">
{% if ticket.status == 'nou' %}
<span class="badge bg-info text-dark">Nou (Deschis)</span>
{% elif ticket.status == 'in_lucru' %}
<span class="badge bg-warning text-dark">În lucru</span>
{% elif ticket.status == 'in_asteptare' %}
<span class="badge bg-secondary">În așteptare</span>
{% elif ticket.status == 'solutionat' %}
<span class="badge bg-success">Soluționat</span>
{% else %}
<span class="badge bg-dark">Închis</span>
{% endif %}
</td>
<td class="align-middle">
{% if ticket.priority == 'scazuta' %}
<span class="badge bg-secondary">Scăzută</span>
{% elif ticket.priority == 'medie' %}
<span class="badge bg-primary">Medie</span>
{% elif ticket.priority == 'ridicata' %}
<span class="badge bg-warning text-dark">Ridicată</span>
{% else %}
<span class="badge bg-danger">Critică</span>
{% endif %}
</td>
<td class="align-middle">{{ ticket.created_at|date:"d.m.Y H:i" }}</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="text-center text-muted py-4">Nu au fost găsite tichete de suport.</td>
</tr>
{% endfor %}
+25 -1
View File
@@ -1,3 +1,27 @@
from django.test import TestCase
from users.models import Employee
from .models import Intervention
# Create your tests here.
class InterventionModelTests(TestCase):
def setUp(self):
self.emp = Employee.objects.create(
name="Angajat Test",
username="angajat.test",
role="Consilier",
office_number="10",
email="test@primariaroman.ro",
)
def test_intervention_defaults(self):
# Create a ticket providing only the required fields
ticket = Intervention.objects.create(
title="Problemă Rețea",
description="Nu mă pot conecta la internet.",
reported_by=self.emp,
)
# Verify default values are correctly applied
self.assertEqual(ticket.status, "nou")
self.assertEqual(ticket.priority, "medie")
self.assertIsNone(ticket.assigned_to_it)
+8
View File
@@ -0,0 +1,8 @@
from django.urls import path
from . import views
app_name = "interventions"
urlpatterns = [
path("", views.intervention_list, name="intervention_list"),
]
+21 -1
View File
@@ -1,3 +1,23 @@
from django.shortcuts import render
from django.db.models import Q
from .models import Intervention
# Create your views here.
def intervention_list(request):
query = request.GET.get("search", "")
tickets = Intervention.objects.all().order_by("-created_at")
if query:
tickets = tickets.filter(
Q(title__icontains=query)
| Q(description__icontains=query)
| Q(reported_by__name__icontains=query)
| Q(assigned_to_it__icontains=query)
)
context = {"tickets": tickets}
if request.headers.get("HX-Request"):
return render(request, "interventions/partials/ticket_table.html", context)
return render(request, "interventions/intervention_list.html", context)