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 )
[docs] class TreatmentLCCValueForm(LCCValueForm):
[docs] class Meta(LCCValueForm.Meta): model = TreatmentLCCValue fields = LCCValueForm.Meta.fields + ["treatment"] widgets = { "treatment": forms.HiddenInput(), }
[docs] class TransportLCCValueForm(LCCValueForm):
[docs] class Meta(LCCValueForm.Meta): model = TransportLCCValue fields = LCCValueForm.Meta.fields + ["chain"] widgets = { "chain": forms.HiddenInput(), }