paperwork: Use default names for certification-related models
This commit is contained in:
parent
bb6577f3bb
commit
35f812d2c6
@ -80,9 +80,9 @@ class CertificationVersionInline(admin.TabularInline):
|
|||||||
|
|
||||||
@admin.register(CertificationDefinition)
|
@admin.register(CertificationDefinition)
|
||||||
class CertificationDefinitionAdmin(admin.ModelAdmin):
|
class CertificationDefinitionAdmin(admin.ModelAdmin):
|
||||||
search_fields = ["certification_name"]
|
search_fields = ["name"]
|
||||||
list_display = [
|
list_display = [
|
||||||
"certification_name",
|
"name",
|
||||||
"department",
|
"department",
|
||||||
"latest_semantic_version",
|
"latest_semantic_version",
|
||||||
]
|
]
|
||||||
@ -103,7 +103,7 @@ class CertificationAdmin(admin.ModelAdmin):
|
|||||||
form = CertificationForm
|
form = CertificationForm
|
||||||
search_fields = [
|
search_fields = [
|
||||||
"name",
|
"name",
|
||||||
"certification_version__definition__certification_name",
|
"certification_version__definition__name",
|
||||||
"certification_version__definition__department__name",
|
"certification_version__definition__department__name",
|
||||||
]
|
]
|
||||||
autocomplete_fields = ["member"]
|
autocomplete_fields = ["member"]
|
||||||
@ -116,10 +116,10 @@ class CertificationAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.display(
|
@admin.display(
|
||||||
description="Certification Name",
|
description="Certification Name",
|
||||||
ordering="certification_version__definition__certification_name",
|
ordering="certification_version__definition__name",
|
||||||
)
|
)
|
||||||
def certification_name(self, obj: Certification) -> str:
|
def name(self, obj: Certification) -> str:
|
||||||
return obj.certification_version.definition.certification_name
|
return obj.certification_version.definition.name
|
||||||
|
|
||||||
@admin.display(
|
@admin.display(
|
||||||
description="Certification Version",
|
description="Certification Version",
|
||||||
@ -152,7 +152,7 @@ class CertificationAdmin(admin.ModelAdmin):
|
|||||||
return obj.audits.latest()
|
return obj.audits.latest()
|
||||||
|
|
||||||
list_display = [
|
list_display = [
|
||||||
"certification_name",
|
"name",
|
||||||
"name",
|
"name",
|
||||||
"certification_semantic_version",
|
"certification_semantic_version",
|
||||||
"is_current",
|
"is_current",
|
||||||
@ -163,7 +163,7 @@ class CertificationAdmin(admin.ModelAdmin):
|
|||||||
"latest_audit",
|
"latest_audit",
|
||||||
]
|
]
|
||||||
list_display_links = [
|
list_display_links = [
|
||||||
"certification_name",
|
"name",
|
||||||
"name",
|
"name",
|
||||||
]
|
]
|
||||||
list_filter = [
|
list_filter = [
|
||||||
|
@ -104,7 +104,7 @@ class DepartmentViewSet(viewsets.ModelViewSet):
|
|||||||
class CertificationDefinitionSerializer(serializers.HyperlinkedModelSerializer):
|
class CertificationDefinitionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CertificationDefinition
|
model = CertificationDefinition
|
||||||
fields = ["certification_name", "department"]
|
fields = ["name", "department"]
|
||||||
|
|
||||||
|
|
||||||
class CertificationDefinitionViewSet(viewsets.ModelViewSet):
|
class CertificationDefinitionViewSet(viewsets.ModelViewSet):
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
# Generated by Django 4.2 on 2023-04-10 18:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("membershipworks", "0002_alter_flag_options"),
|
||||||
|
("paperwork", "0013_alter_certificationdefinition_certification_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="certificationdefinition",
|
||||||
|
old_name="certification_identifier",
|
||||||
|
new_name="id",
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certificationdefinition",
|
||||||
|
name="id",
|
||||||
|
field=models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="certified_by",
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="date",
|
||||||
|
field=models.DateField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="member",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
db_constraint=False,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
to="membershipworks.member",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="notes",
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="number",
|
||||||
|
field=models.AutoField(primary_key=True, serialize=False),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certification",
|
||||||
|
name="shop_lead_notified",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certificationdefinition",
|
||||||
|
name="certification_name",
|
||||||
|
field=models.CharField(max_length=255),
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="certificationdefinition",
|
||||||
|
old_name="certification_name",
|
||||||
|
new_name="name",
|
||||||
|
),
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="certificationdefinition",
|
||||||
|
options={"ordering": ("name", "department")},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="certificationversion",
|
||||||
|
name="definition",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
to="paperwork.certificationdefinition",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
@ -105,20 +105,15 @@ class Department(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class CertificationDefinition(models.Model):
|
class CertificationDefinition(models.Model):
|
||||||
certification_identifier = models.AutoField(
|
name = models.CharField(max_length=255)
|
||||||
db_column="Certification Identifier", primary_key=True
|
|
||||||
)
|
|
||||||
certification_name = models.CharField(
|
|
||||||
db_column="Certification Name", max_length=255
|
|
||||||
)
|
|
||||||
department = models.ForeignKey(Department, models.PROTECT)
|
department = models.ForeignKey(Department, models.PROTECT)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.certification_name} <{self.department}>"
|
return f"{self.name} <{self.department}>"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "Certification Definitions"
|
db_table = "Certification Definitions"
|
||||||
ordering = ("certification_name", "department")
|
ordering = ("name", "department")
|
||||||
|
|
||||||
def latest_version(self) -> "CertificationVersion":
|
def latest_version(self) -> "CertificationVersion":
|
||||||
return self.certificationversion_set.latest()
|
return self.certificationversion_set.latest()
|
||||||
@ -149,9 +144,7 @@ class CertificationVersionManager(models.Manager["CertificationVersion"]):
|
|||||||
class CertificationVersion(models.Model):
|
class CertificationVersion(models.Model):
|
||||||
objects = CertificationVersionManager()
|
objects = CertificationVersionManager()
|
||||||
|
|
||||||
definition = models.ForeignKey(
|
definition = models.ForeignKey(CertificationDefinition, on_delete=models.PROTECT)
|
||||||
CertificationDefinition, on_delete=models.PROTECT, db_column="Certification"
|
|
||||||
)
|
|
||||||
major = models.PositiveSmallIntegerField()
|
major = models.PositiveSmallIntegerField()
|
||||||
minor = models.PositiveSmallIntegerField()
|
minor = models.PositiveSmallIntegerField()
|
||||||
patch = models.PositiveSmallIntegerField()
|
patch = models.PositiveSmallIntegerField()
|
||||||
@ -198,28 +191,23 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class Certification(models.Model):
|
class Certification(models.Model):
|
||||||
number = models.AutoField(db_column="Number", primary_key=True)
|
number = models.AutoField(primary_key=True)
|
||||||
certification_version = models.ForeignKey(
|
certification_version = models.ForeignKey(
|
||||||
CertificationVersion, on_delete=models.PROTECT
|
CertificationVersion, on_delete=models.PROTECT
|
||||||
)
|
)
|
||||||
name = models.CharField(db_column="Name", max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
member = models.ForeignKey(
|
member = models.ForeignKey(
|
||||||
Member,
|
Member,
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
to_field="uid",
|
to_field="uid",
|
||||||
db_column="uid",
|
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
db_constraint=False,
|
db_constraint=False,
|
||||||
)
|
)
|
||||||
certified_by = models.CharField(
|
certified_by = models.CharField(max_length=255, blank=True, null=True)
|
||||||
db_column="Certified_By", max_length=255, blank=True, null=True
|
date = models.DateField(blank=True, null=True)
|
||||||
)
|
shop_lead_notified = models.DateTimeField(blank=True, null=True)
|
||||||
date = models.DateField(db_column="Date", blank=True, null=True)
|
notes = models.CharField(max_length=255, blank=True, null=True)
|
||||||
shop_lead_notified = models.DateTimeField(
|
|
||||||
db_column="Shop Lead Notified", blank=True, null=True
|
|
||||||
)
|
|
||||||
notes = models.CharField(db_column="Notes", max_length=255, blank=True, null=True)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.name} - {self.certification_version}"
|
return f"{self.name} - {self.certification_version}"
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
{% for certification in certifications %}
|
{% for certification in certifications %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ certification.certification_version.definition.department.name }}</td>
|
<td>{{ certification.certification_version.definition.department.name }}</td>
|
||||||
<td>{{ certification.certification_version.definition.certification_name }}</td>
|
<td>{{ certification.certification_version.definition.name }}</td>
|
||||||
<td>{{ certification.member|default:certification.name }}</td>
|
<td>{{ certification.member|default:certification.name }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if not certification.certification_version.is_current %}[OUTDATED]{% endif %}
|
{% if not certification.certification_version.is_current %}[OUTDATED]{% endif %}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for certification in certifications %}
|
{% for certification in certifications %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ certification.certification_version.definition.certification_name }}</td>
|
<td>{{ certification.certification_version.definition.name }}</td>
|
||||||
<td>{{ certification.certification_version.semantic_version }}</td>
|
<td>{{ certification.certification_version.semantic_version }}</td>
|
||||||
<td>{{ certification.member }}</td>
|
<td>{{ certification.member }}</td>
|
||||||
<td>{{ certification.certification_version.definition.department }}</td>
|
<td>{{ certification.certification_version.definition.department }}</td>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for certification in certifications %}
|
{% for certification in certifications %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ certification.certification_version.definition.certification_name }}</td>
|
<td>{{ certification.certification_version.definition.name }}</td>
|
||||||
<td>{{ certification.certification_version.semantic_version }}</td>
|
<td>{{ certification.certification_version.semantic_version }}</td>
|
||||||
<td>{{ certification.member }}</td>
|
<td>{{ certification.member }}</td>
|
||||||
<td>{{ certification.certified_by }}</td>
|
<td>{{ certification.certified_by }}</td>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for certification in certifications %}
|
{% for certification in certifications %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ certification.certification_version.definition.certification_name }}</td>
|
<td>{{ certification.certification_version.definition.name }}</td>
|
||||||
<td>{{ certification.certification_version.semantic_version }}</td>
|
<td>{{ certification.certification_version.semantic_version }}</td>
|
||||||
<td>{{ certification.certification_version.definition.department }}</td>
|
<td>{{ certification.certification_version.definition.department }}</td>
|
||||||
<td>{{ certification.certified_by }}</td>
|
<td>{{ certification.certified_by }}</td>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
{% if current or show_outdated %}
|
{% if current or show_outdated %}
|
||||||
<tr {% if not current %} class="table-warning"{% endif %}>
|
<tr {% if not current %} class="table-warning"{% endif %}>
|
||||||
<td {% if not current %} class="text-decoration-line-through"{% endif %}>
|
<td {% if not current %} class="text-decoration-line-through"{% endif %}>
|
||||||
{{ certification.certification_version.definition.certification_name }}
|
{{ certification.certification_version.definition.name }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ certification.certification_version.semantic_version }}
|
{{ certification.certification_version.semantic_version }}
|
||||||
|
Loading…
Reference in New Issue
Block a user