diff options
Diffstat (limited to '')
-rw-r--r-- | client/migrations/0018_alter_usercode_branca.py | 20 | ||||
-rw-r--r-- | client/migrations/0019_alter_document_usercode.py | 19 | ||||
-rw-r--r-- | client/models.py | 4 | ||||
-rw-r--r-- | client/templates/client/index.html | 3 | ||||
-rw-r--r-- | client/views.py | 13 |
5 files changed, 54 insertions, 5 deletions
diff --git a/client/migrations/0018_alter_usercode_branca.py b/client/migrations/0018_alter_usercode_branca.py new file mode 100644 index 0000000..2e43506 --- /dev/null +++ b/client/migrations/0018_alter_usercode_branca.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.5 on 2023-07-25 09:58 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ('client', '0017_document_usercode'), + ] + + operations = [ + migrations.AlterField( + model_name='usercode', + name='branca', + field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='auth.group'), + ), + ] diff --git a/client/migrations/0019_alter_document_usercode.py b/client/migrations/0019_alter_document_usercode.py new file mode 100644 index 0000000..04f030a --- /dev/null +++ b/client/migrations/0019_alter_document_usercode.py @@ -0,0 +1,19 @@ +# Generated by Django 4.1.5 on 2023-07-25 09:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0018_alter_usercode_branca'), + ] + + operations = [ + migrations.AlterField( + model_name='document', + name='usercode', + field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='client.usercode'), + ), + ] diff --git a/client/models.py b/client/models.py index 1548893..c39a5ea 100644 --- a/client/models.py +++ b/client/models.py @@ -77,7 +77,7 @@ class UserCode(models.Model): user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
medic = models.ForeignKey(MedicalData, default=None, on_delete=models.PROTECT)
code = models.IntegerField(default=0)
- branca = models.ForeignKey(Group, default=1, on_delete=models.PROTECT)
+ branca = models.ForeignKey(Group, default=None, on_delete=models.PROTECT, null=True)
first_name = models.CharField(default="", max_length=250)
last_name = models.CharField(default="", max_length=250)
email = models.CharField(default="", max_length=250)
@@ -97,7 +97,7 @@ class UserCode(models.Model): class Document(models.Model):
- usercode = models.ForeignKey(UserCode, default=1, on_delete=models.CASCADE)
+ usercode = models.ForeignKey(UserCode, default=None, on_delete=models.CASCADE, null=True)
user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
code = models.IntegerField(default=0)
diff --git a/client/templates/client/index.html b/client/templates/client/index.html index ef9b67d..8bb2d41 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -35,8 +35,7 @@ <div class="card"> <div class="card-content"> <span class="card-title"> - {{data.0.first_name}} {{data.0.last_name}} - <a href="{% url "edit_user" code=data.0.code %}" class="btn-flat"><i class="material-icons">edit</i></a> + <p style="text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: {{data.2}};">{{data.0.first_name}} {{data.0.last_name}}<a href="{% url "edit_user" code=data.0.code %}" class="btn-flat"><i class="material-icons">edit</i></a></p> <div style="font-size: 0.5em; line-height: normal;">{{data.0.born_date}}</div> </span> <a id="add" class="btn-floating halfway-fab btn-large {{color}}" href="{% url 'create'%}"><i class="material-icons">add</i></a> diff --git a/client/views.py b/client/views.py index dfb5dbf..5160927 100644 --- a/client/views.py +++ b/client/views.py @@ -95,7 +95,18 @@ def index(request): for uc in ucs: documents = Document.objects.filter( Q(usercode=uc) & ~Q(status='archive')).select_related("personal_data", "medical_data", "document_type", "user") - docs.append([uc, documents]) + color_mapping = { + "diga": "#ffeb3b", + "muta": "#03a9f4", + "reparto": "#795548", + "posto": "#f44336", + "clan": "#4caf50" + } + if uc.branca == None: + color = "black" + else: + color = color_mapping[uc.branca.name] + docs.append([uc, documents, color]) # show only docs of the user and non archived vac_file = ["/server/media/", "/vac_certificate/doc"] |