diff --git a/GestionaleITS/Readme.md b/GestionaleITS/Readme.md
index d4b69a9..15d5f52 100644
--- a/GestionaleITS/Readme.md
+++ b/GestionaleITS/Readme.md
@@ -76,7 +76,9 @@ networks:
```
# TODO
-
+- Una schermata di associazione per corso
+- lunedí serve un foglio con il codice del corso
+- Visualizzo l'elenco degli studenti
- Default value of association "Pagamento effettuato"
- import of storage, computers, courses.
- Tables Sorting with filters
diff --git a/GestionaleITS/gestionale/forms.py b/GestionaleITS/gestionale/forms.py
index e18f7a8..c9f723c 100644
--- a/GestionaleITS/gestionale/forms.py
+++ b/GestionaleITS/gestionale/forms.py
@@ -107,6 +107,9 @@ class ComputerForm(forms.ModelForm):
"serial": "Seriale"
}
+class CespiteForm(forms.Form):
+ cespite = forms.CharField(label="Cespite")
+ seriale = forms.CharField(label="Seriale")
class AccessoryForm(forms.ModelForm):
class Meta:
@@ -208,7 +211,6 @@ class AssignmentComputerForm(forms.Form):
)
course_code = forms.CharField(label="Codice Corso", max_length=255)
codice_fiscale = forms.CharField(label="Codice Fiscale", max_length=255)
- cespite = forms.CharField(label="Cespite", max_length=255)
serial = forms.CharField(label="Seriale", max_length=255)
assignment_date = forms.DateField(widget=SelectDateWidget(), label="Data di assegnazione", initial=datetime.now().date)
assignment_motivation = forms.ChoiceField(choices=choice)
diff --git a/GestionaleITS/gestionale/migrations/0003_remove_student_id_student_course.py b/GestionaleITS/gestionale/migrations/0003_remove_student_id_student_course.py
new file mode 100644
index 0000000..50d9565
--- /dev/null
+++ b/GestionaleITS/gestionale/migrations/0003_remove_student_id_student_course.py
@@ -0,0 +1,17 @@
+# Generated by Django 4.2.16 on 2024-10-24 14:51
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('gestionale', '0002_supplier_is_deleted'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='student',
+ name='id_student_course',
+ ),
+ ]
diff --git a/GestionaleITS/gestionale/models.py b/GestionaleITS/gestionale/models.py
index 8a37599..7cebe93 100644
--- a/GestionaleITS/gestionale/models.py
+++ b/GestionaleITS/gestionale/models.py
@@ -87,7 +87,6 @@ class Student(models.Model):
birth_date = models.DateField()
codice_fiscale = models.CharField(max_length=255)
gender = models.CharField(max_length=255)
- id_student_course = models.IntegerField(blank= True, null=True)
course_acronym = models.CharField(max_length=255)
email_user = models.EmailField(max_length=255)
phone_number = models.CharField(max_length=255)
diff --git a/GestionaleITS/gestionale/templates/gestionale/assignment/assignment.html b/GestionaleITS/gestionale/templates/gestionale/assignment/assignment.html
index aec17e9..6c2f6e9 100644
--- a/GestionaleITS/gestionale/templates/gestionale/assignment/assignment.html
+++ b/GestionaleITS/gestionale/templates/gestionale/assignment/assignment.html
@@ -21,24 +21,35 @@
viewBox="0 0 16 16">
- Computer
+
Computer
-
+
+
+
+
- Accessorio
+
Accessorio
+
+
+
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/GestionaleITS/gestionale/templates/gestionale/assignment/cespite.html b/GestionaleITS/gestionale/templates/gestionale/assignment/cespite.html
new file mode 100644
index 0000000..ea2b0f5
--- /dev/null
+++ b/GestionaleITS/gestionale/templates/gestionale/assignment/cespite.html
@@ -0,0 +1,31 @@
+
+
+
+{% extends "gestionale/base.html" %}
+{% load static %}
+{% block content %}
+{% if user.is_authenticated %}
+{% if success == True %}
+
+
Cespite assegnato con successo!
+
+{% endif %}
+{% if err == True %}
+
+{% endif %}
+
+{% endif %}
+{% endblock %}
diff --git a/GestionaleITS/gestionale/templates/gestionale/assignment/cespite.html~ b/GestionaleITS/gestionale/templates/gestionale/assignment/cespite.html~
new file mode 100644
index 0000000..e69de29
diff --git a/GestionaleITS/gestionale/urls.py b/GestionaleITS/gestionale/urls.py
index 0beb6ac..42b827e 100644
--- a/GestionaleITS/gestionale/urls.py
+++ b/GestionaleITS/gestionale/urls.py
@@ -24,7 +24,7 @@ urlpatterns = [
path("assignment", views_assignment.assignment, name="assignment"),
path("assignment/computer", views_assignment.assignment_computer, name="assignment_computer"),
path("assignment/accessory", views_assignment.assignment_accessory, name="assignment_accessory"),
-
+ path("assignment/cespite", views_assignment.assignment_cespite, name="assignment_cespite"),
path("add/bundle", views_add.add_bundle, name="add_bundle"),
path("add/supplier", views_add.add_supplier, name="add_supplier"),
path("add/serial", views_add.add_serial, name="add_serial"),
diff --git a/GestionaleITS/gestionale/views/views.py b/GestionaleITS/gestionale/views/views.py
index f307283..1890ec9 100644
--- a/GestionaleITS/gestionale/views/views.py
+++ b/GestionaleITS/gestionale/views/views.py
@@ -58,15 +58,14 @@ def import_students(request):
csv_data = csv_file.read().decode("utf-8").splitlines()
reader = csv.DictReader(csv_data)
for row in reader:
- course = get_object_or_404(Course, course_code=row["Codice Corso"])
- birth_date = datetime.strptime(row["DataNascita"], "%d/%m/%Y")
+ course = get_object_or_404(Course, course_code=row[""])
+ birth_date = datetime.strptime(row["DataNascita"], "%m/%d/%Y")
student = Student()
- student.id_student_course = row["IDAllievoCorso"]
student.codice_fiscale = row["CodiceFiscale"]
- student.course_acronym = row["SiglaCorso"]
+ student.course_acronym = row[""]
student.last_name = row["Cognome"]
student.first_name = row["Nome"]
- student.email_user = row["EmailUser"]
+ student.email_user = row["EmailGSuite"]
student.phone_number = row["Tel"]
student.municipality_residence = row["ComuneRes"]
student.province_residence = row["ProvRes"]
@@ -75,7 +74,7 @@ def import_students(request):
student.municipality_birth = row["ComuneNascita"]
student.province_birth = row["ProvNascita"]
student.resignation_date = None if row["DataDimissioni"]=="" else row["DataDimissioni"]
- student.gender = row["Genere"]
+ student.gender = row["Sex"]
student.nation_birth = row["NazioneNasc"]
student.course_id = course
student.save()
diff --git a/GestionaleITS/gestionale/views/views_assignment.py b/GestionaleITS/gestionale/views/views_assignment.py
index 4b42f3d..6e9a2e7 100644
--- a/GestionaleITS/gestionale/views/views_assignment.py
+++ b/GestionaleITS/gestionale/views/views_assignment.py
@@ -11,7 +11,7 @@ from django.http import Http404
from django.shortcuts import render, get_object_or_404, redirect
from django.views.defaults import bad_request
-from ..forms import AssignmentComputerForm, AssignmentAccessoryForm
+from ..forms import AssignmentComputerForm, AssignmentAccessoryForm, CespiteForm
from ..models import Computer, Accessory, Student, Course, Record
@user_passes_test(lambda u: u.is_superuser or u.is_staff)
@@ -35,7 +35,6 @@ def assignment_computer(request):
computer_copy = copy.deepcopy(computer)
record.prev_product_detail = computer_copy
eol_date = (form["assignment_date"] + timedelta(days=1460))
- computer.cespite = form["cespite"]
computer.status = "assigned"
computer.id_student = student
computer.assignment_date = form["assignment_date"]
@@ -121,3 +120,44 @@ def assignment_accessory(request):
return render(request, "gestionale/assignment/assignment_accessory.html", {
"form": form, "err": err, "err_str": err_str
})
+
+@user_passes_test(lambda u: u.is_superuser or u.is_staff)
+def assignment_cespite(request):
+ if request.method == "POST":
+ form = CespiteForm(request.POST)
+ if form.is_valid():
+ form = form.cleaned_data
+ try:
+ record = Record()
+ computer = get_object_or_404(Computer, serial=form["serial"])
+ computer_copy = copy.deepcopy(computer)
+ computer.cespite = form["cespite"]
+ computer.save
+
+ record.date = datetime.now().date()
+ record.action = "assignment"
+ record.product = "cespite"
+ record.product_detail = computer
+ record.prev_product_detail = computer_copy
+ record.user = request.user
+ record.save()
+ except Http404:
+ form = CespiteForm()
+ err = True
+ err_str = "Uno o più dei valori inseriti non é stato trovato"
+ return render(request, "gestionale/assignment/cespite.html", {
+ "err": err, "err_str": err_str, "form": form
+ })
+ return redirect("assignment_cespite")
+ else:
+ form = CespiteForm()
+ err = True
+ err_str = "L'inserimento é incompleto o errato!"
+ return render(request, "gestionale/assignment/cespite.html", {
+ "form": form, "err": err, "err_str": err_str})
+
+ else:
+ form = CespiteForm()
+ return render(request, "gestionale/assignment/cespite.html", {
+ "form": form})
+