Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions infra/helm/qmra/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ spec:
- name: qmra-default
mountPath: {{ .Values.qmra_default.mount_path }}
command: [ python, manage.py, migrate, --database, qmra ]
- name: export-default
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
envFrom:
- configMapRef:
name: {{ .Values.configmap_name }}
volumeMounts:
- name: qmra-default
mountPath: {{ .Values.qmra_default.mount_path }}
command: [ python, manage.py, export_default ]
- name: move-static
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
envFrom:
Expand Down
3 changes: 0 additions & 3 deletions qmra/risk_assessment/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ class QMRATreatmentAdmin(admin.ModelAdmin):
fields = [
("name", "group"),
("bacteria_min", "bacteria_max"),
"bacteria_reference",
"bacteria_references",
("viruses_min", "viruses_max"),
"viruses_reference",
"viruses_references",
("protozoa_min", "protozoa_max"),
"protozoa_reference",
"protozoa_references"
]
filter_horizontal = ["bacteria_references", "viruses_references", "protozoa_references"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2026-01-22 09:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('risk_assessment', '0009_auto_20260121_1454'),
]

operations = [
migrations.RemoveField(
model_name='qmratreatment',
name='bacteria_reference',
),
migrations.RemoveField(
model_name='qmratreatment',
name='protozoa_reference',
),
migrations.RemoveField(
model_name='qmratreatment',
name='viruses_reference',
),
]
34 changes: 17 additions & 17 deletions qmra/risk_assessment/qmra_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,54 +268,54 @@ class QMRATreatment(models.Model):
description: str = models.CharField(max_length=512)
bacteria_min: Optional[float] = models.FloatField(blank=True, null=True)
bacteria_max: Optional[float] = models.FloatField(blank=True, null=True)
bacteria_reference = models.ForeignKey(QMRAReference, blank=True, null=True, on_delete=models.CASCADE,
related_name="bacteria_lrv")
bacteria_references = models.ManyToManyField(QMRAReference, related_name="bacteria_lrvs")
_bacteria_references_tmp: list[str]

viruses_min: Optional[float] = models.FloatField(blank=True, null=True)
viruses_max: Optional[float] = models.FloatField(blank=True, null=True)
viruses_reference = models.ForeignKey(QMRAReference, blank=True, null=True, on_delete=models.CASCADE,
related_name="viruses_lrv")
viruses_references = models.ManyToManyField(QMRAReference, related_name="viruses_lrvs")
_viruses_references_tmp: list[str]

protozoa_min: Optional[float] = models.FloatField(blank=True, null=True)
protozoa_max: Optional[float] = models.FloatField(blank=True, null=True)
protozoa_reference = models.ForeignKey(QMRAReference, blank=True, null=True, on_delete=models.CASCADE,
related_name="protozoa_lrv")
protozoa_references = models.ManyToManyField(QMRAReference, related_name="protozoa_lrvs")
_protozoa_references_tmp: list[str]

@classmethod
def from_dict(cls, data):
return QMRATreatment(
t = QMRATreatment(
pk=data["id"],
name=data['name'],
group=data['group'],
description=data['description'],
bacteria_min=data['bacteria_min'],
bacteria_max=data['bacteria_max'],
# TODO: *_referenceS (m2m fields...)
bacteria_reference_id=int(data["bacteria_reference"]) \
if data["bacteria_reference"] is not None else None,
viruses_min=data['viruses_min'],
viruses_max=data['viruses_max'],
viruses_reference_id=int(data["viruses_reference"]) \
if data["viruses_reference"] is not None else None,
protozoa_min=data['protozoa_min'],
protozoa_max=data['protozoa_max'],
protozoa_reference_id=int(data["protozoa_reference"]) \
if data["protozoa_reference"] is not None else None,
)
t._bacteria_references_tmp = data.get("bacteria_references", [])
t._viruses_references_tmp = data.get("viruses_references", [])
t._protozoa_references_tmp = data.get("protozoa_references", [])
return t

def to_dict(self):
data = model_to_dict(self)
data["bacteria_reference"] = str(self.bacteria_reference.pk) if self.bacteria_reference is not None else None
data["bacteria_references"] = [str(ref.pk) for ref in self.bacteria_references.all()]
data["viruses_reference"] = str(self.viruses_reference.pk) if self.viruses_reference is not None else None
data["viruses_references"] = [str(ref.pk) for ref in self.viruses_references.all()]
data["protozoa_reference"] = str(self.protozoa_reference.pk) if self.protozoa_reference is not None else None
data["protozoa_references"] = [str(ref.pk) for ref in self.protozoa_references.all()]
return data

def save(
self, force_insert=False, force_update=False, using=None, update_fields=None
):
super().save(force_insert, force_update, using, update_fields)
self.bacteria_references.set(self._bacteria_references_tmp)
self.viruses_references.set(self._viruses_references_tmp)
self.protozoa_references.set(self._protozoa_references_tmp)
return self


class QMRATreatments(StaticEntity):
source = "qmra/static/data/default-treatments.json"
Expand Down
2 changes: 1 addition & 1 deletion qmra/risk_assessment/templates/treatments-form-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
for (const treatment of this.treatments){
if (!uniques.has(treatment.name)){
const all_refs_id = new Set();
for (const r of [...treatment.viruses_references, ...treatment.bacteria_references, ...treatment.protozoa_references]){
for (const r of [...treatment?.viruses_references, ...treatment?.bacteria_references, ...treatment?.protozoa_references]){
all_refs_id.add(r);
}
const superscripts = [...all_refs_id].map((r, i) => { return `<sup>[${i+1}]</sup>` }).join('');
Expand Down
Loading
Loading