Skip to content

Commit

Permalink
Minor display update
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Diacquenod committed Feb 7, 2023
1 parent 63af006 commit eedf178
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 75 deletions.
29 changes: 10 additions & 19 deletions conformity/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,57 @@
from django.contrib import admin
from import_export import resources
from import_export.admin import ImportExportModelAdmin
from .models import Organization, Policy, Measure, Conformity, Audit, Finding
from .models import Organization, Policy, Measure, Conformity, Audit, Finding, Action

# Organization


class OrganizationResources(resources.ModelResource):
class Meta:
model = Organization


class OrganizationAdmin(ImportExportModelAdmin):
ressource_class = Organization


admin.site.register(Organization, OrganizationAdmin)


# Policy


class PolicyResources(resources.ModelResource):
class Meta:
model = Policy


class PolicyAdmin(ImportExportModelAdmin):
ressource_class = Policy


admin.site.register(Policy, PolicyAdmin)


# Measure

class MeasureResources(resources.ModelResource):
class Meta:
model = Measure


class MeasureAdmin(ImportExportModelAdmin):
ressource_class = Measure


admin.site.register(Measure, MeasureAdmin)


# Conformity


class ConformityResources(resources.ModelResource):
class Meta:
model = Conformity


class ConformityAdmin(ImportExportModelAdmin):
ressource_class = Conformity


admin.site.register(Conformity, ConformityAdmin)

# Action
class ActionResources(resources.ModelResource):
class Meta:
model = Action

class ActionAdmin(ImportExportModelAdmin):
ressource_class = Action

admin.site.register(Action, ActionAdmin)
###
admin.site.register(Audit)
admin.site.register(Finding)
Expand Down
23 changes: 23 additions & 0 deletions conformity/migrations/0024_action_active_alter_action_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1.5 on 2023-02-07 05:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('conformity', '0023_alter_action_organization'),
]

operations = [
migrations.AddField(
model_name='action',
name='active',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='action',
name='status',
field=models.CharField(choices=[('1', 'Analysing'), ('2', 'Planning'), ('3', 'Implementing'), ('4', 'Controlling'), ('5', 'Closed'), ('7', 'Frozen'), ('9', 'Canceled')], default='1', max_length=5),
),
]
5 changes: 5 additions & 0 deletions conformity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ class Status(models.TextChoices):
default=Status.ANALYSING,
)
status_comment = models.CharField(max_length=4096, blank=True)
active = models.BooleanField(default=True)

' Analyse Phase'
description = models.CharField(max_length=4096, blank=True)
Expand Down Expand Up @@ -449,4 +450,8 @@ def save(self, *args, **kwargs):
if not self.id:
self.create_date = timezone.now()
self.update_date = timezone.now()

if self.status in [Action.Status.FROZEN, Action.Status.ENDED, Action.Status.CANCELED]:
self.active = False

return super(Action, self).save(*args, **kwargs)
102 changes: 47 additions & 55 deletions conformity/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,6 @@ <h1 class="h2 bi bi-house-door"> Welcome {{request.user.first_name}} !</h1>

{% block content %}
<div class="row d-flex justify-content-evenly">
<div class="col-lg-4">
<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-card-checklist"></i> Policy</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:policy_index'%}">{{policy_list|length}} policies</a>
</div>
<ul class="list-group list-group-flush">
{% for policy in policy_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:policy_detail' policy.id %}"> {{policy}}</a>
{% endfor %}
</ul>
</div>

<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-building"></i> Organization</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:organization_index'%}" >{{organization_list|length}} organizations</a>
</div>
<ul class="list-group list-group-flush">
{% for organization in organization_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:organization_form' organization.id %}"> {{organization}}</a>
{% endfor %}
</ul>
</div>

<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-ui-checks-grid"></i> Audit</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:audit_index'%}" >{{audit_list|length}} audits</a>
</div>
<ul class="list-group list-group-flush">
{% for audit in audit_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:audit_detail' audit.id %}"> {{audit}}</a>
{% endfor %}
</ul>
</div>
</div>

<div class="col-lg-8">
<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
Expand All @@ -73,9 +29,9 @@ <h5 class="my-0"><i class="bi bi-shield-shaded"></i> My Conformities</h5>
</ul>
</div>

<div class="card shadow-sm my-3">
<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-arrow-repeat"></i> My Actions</h5>
<h5 class="my-0"><i class="bi bi-arrow-repeat"></i> My actives actions</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:action_index'%}" >{{my_action|length}} actions</a>
</div>
Expand All @@ -95,21 +51,57 @@ <h5 class="my-0"><i class="bi bi-arrow-repeat"></i> My Actions</h5>
{% if action.status == "4" %}
<span class="badge rounded-pill text-bg-success position-absolute top-50 end-0 translate-middle-y me-3 col-2">
{% endif %}
{% if action.status == "7" %}
<span class="badge rounded-pill border text-bg-light position-absolute top-50 end-0 translate-middle-y me-3 col-2">
{% endif %}
{% if action.status == "8" %}
<span class="badge rounded-pill text-bg-dark position-absolute top-50 end-0 translate-middle-y me-3 col-2">
{% endif %}
{% if action.status == "9" %}
<span class="badge rounded-pill text-bg-danger position-absolute top-50 end-0 translate-middle-y me-3 col-2">
{% endif %}
{{action.get_status_display}}
</span>
</a>
{% endfor %}
</ul>
</div>
</div>


<div class="col-lg-4">
<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-card-checklist"></i> Policy</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:policy_index'%}">{{policy_list|length}} policies</a>
</div>
<ul class="list-group list-group-flush">
{% for policy in policy_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:policy_detail' policy.id %}"> {{policy}}</a>
{% endfor %}
</ul>
</div>

<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-building"></i> Organization</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:organization_index'%}" >{{organization_list|length}} organizations</a>
</div>
<ul class="list-group list-group-flush">
{% for organization in organization_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:organization_form' organization.id %}"> {{organization}}</a>
{% endfor %}
</ul>
</div>

<div class="card shadow-sm my-3">
<div class="card-header d-flex justify-content-between align-items-start bg-gradient">
<h5 class="my-0"><i class="bi bi-ui-checks-grid"></i> Audit</h5>
<a class="btn btn-outline-info btn-sm"
href="{%url 'conformity:audit_index'%}" >{{audit_list|length}} audits</a>
</div>
<ul class="list-group list-group-flush">
{% for audit in audit_list %}
<a class="list-group-item list-group-item-action"
href="{%url 'conformity:audit_detail' audit.id %}"> {{audit}}</a>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion conformity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_context_data(self, **kwargs):
conformity_list = Conformity.objects.filter(measure__level=0)
audit_list = Audit.objects.all()
action_list = Action.objects.all()
my_action = Action.objects.filter(owner=user).order_by('status')[:50]
my_action = Action.objects.filter(owner=user).filter(active=True).order_by('status')[:50]
my_conformity = Conformity.objects.filter(responsible=user).order_by('status')[:50]

context = {
Expand Down

0 comments on commit eedf178

Please sign in to comment.