Source code for ferrosoft.apps.emiflow.forms.lifecycle
# Copyright (c) 2025 Ferrosoft GmbH. All rights reserved.
from django import forms
from ferrosoft.apps.emiflow.models import (
TreatmentLCCValue,
LifecycleCategory,
LCCValue,
TransportLCCValue,
)
from ferrosoft.apps.ferrobase.forms import UnitChoiceField
from ferrosoft.apps.ferrobase.models import UnitCollection, UnitCursor
[docs]
class LCCValueForm(forms.ModelForm):
[docs]
class Meta:
model = LCCValue
fields = [
"lifecycle_category",
"emission_unit",
"operation_emission_value",
"total_emission_value",
]
emission_unit = UnitChoiceField(
units=UnitCollection.EMISSION,
initial=UnitCursor("gCO2e"),
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["lifecycle_category"].queryset = LifecycleCategory.objects.filter(
predefined=False
)