final final final version (version 1.3)

This commit is contained in:
2024-10-24 16:51:42 +02:00
parent b762b57ec3
commit dc623fdb52
10 changed files with 117 additions and 16 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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',
),
]

View File

@@ -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)

View File

@@ -21,10 +21,18 @@
viewBox="0 0 16 16">
<path d="M13.5 3a.5.5 0 0 1 .5.5V11H2V3.5a.5.5 0 0 1 .5-.5zm-11-1A1.5 1.5 0 0 0 1 3.5V12h14V3.5A1.5 1.5 0 0 0 13.5 2zM0 12.5h16a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 12.5"/>
</svg>
Computer
<p>Computer</p>
</div>
</a>
<a href="/assignment/cespite">
<div class="link-card">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-123" viewBox="0 0 16 16">
<path d="M2.873 11.297V4.142H1.699L0 5.379v1.137l1.64-1.18h.06v5.961zm3.213-5.09v-.063c0-.618.44-1.169 1.196-1.169.676 0 1.174.44 1.174 1.106 0 .624-.42 1.101-.807 1.526L4.99 10.553v.744h4.78v-.99H6.643v-.069L8.41 8.252c.65-.724 1.237-1.332 1.237-2.27C9.646 4.849 8.723 4 7.308 4c-1.573 0-2.36 1.064-2.36 2.15v.057zm6.559 1.883h.786c.823 0 1.374.481 1.379 1.179.01.707-.55 1.216-1.421 1.21-.77-.005-1.326-.419-1.379-.953h-1.095c.042 1.053.938 1.918 2.464 1.918 1.478 0 2.642-.839 2.62-2.144-.02-1.143-.922-1.651-1.551-1.714v-.063c.535-.09 1.347-.66 1.326-1.678-.026-1.053-.933-1.855-2.359-1.845-1.5.005-2.317.88-2.348 1.898h1.116c.032-.498.498-.944 1.206-.944.703 0 1.206.435 1.206 1.07.005.64-.504 1.106-1.2 1.106h-.75z"/>
</svg>
<p>Cespite</p>
</div>
</a>
<a href="/assignment/accessory">
<div class="link-card">
@@ -32,10 +40,13 @@
viewBox="0 0 16 16">
<path d="M7 0q-.891.002-1.527.463c-.418.302-.717.726-.93 1.208C4.123 2.619 4 3.879 4 5.187v.504L3.382 6A2.5 2.5 0 0 0 2 8.236v2.576C2 13.659 4.22 16 7 16h2c2.78 0 5-2.342 5-5.188V5.186c0-1.13-.272-2.044-.748-2.772-.474-.726-1.13-1.235-1.849-1.59C9.981.123 8.26 0 7 0m2.5 6.099V1.232c.51.11 1.008.267 1.46.49.596.293 1.099.694 1.455 1.24.355.543.585 1.262.585 2.225v1.69zm-1-5.025v4.803L5 5.099c.006-1.242.134-2.293.457-3.024.162-.366.363-.63.602-.801C6.292 1.105 6.593 1 7 1c.468 0 .98.018 1.5.074M5 6.124 13 7.9v2.912C13 13.145 11.19 15 9 15H7c-2.19 0-4-1.855-4-4.188V8.236a1.5 1.5 0 0 1 .83-1.342l.187-.093c.01.265.024.58.047.92.062.938.19 2.12.462 2.937a.5.5 0 1 0 .948-.316c-.227-.683-.35-1.75-.413-2.688a29 29 0 0 1-.06-1.528v-.002z"/>
</svg>
Accessorio
<p>Accessorio</p>
</div>
</a>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,31 @@
<!-- Copyright (C) 2024 Nastro_ -->
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
{% extends "gestionale/base.html" %}
{% load static %}
{% block content %}
{% if user.is_authenticated %}
{% if success == True %}
<div>
<p>Cespite assegnato con successo!</p>
</div>
{% endif %}
{% if err == True %}
<div>
<p>{{ err_str }}</p>
</div>
{% endif %}
<form action="/assignment/computer" method="post" class="pure-form pure-form-2 pure-form-stacked">
{% csrf_token %}
<div class="form-content width-100">
{{ form }}
</div>
<div class="form-buttons">
<button type="submit" class="pure-button pure-button-primary">Assegna</button>
<button type="reset" class="pure-button button-warning">Reset</button>
</div>
</form>
{% endif %}
{% endblock %}

View File

@@ -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"),

View File

@@ -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()

View File

@@ -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})