Reviewed-on: SGD-Nord/konova#60
This commit is contained in:
		
						commit
						552559c118
					
				@ -58,8 +58,20 @@ class EcoAccountQualityChecker(CompensationQualityChecker):
 | 
			
		||||
        self._check_deductable_surface()
 | 
			
		||||
        self._check_responsible_data()
 | 
			
		||||
        self._check_legal_data()
 | 
			
		||||
        self._check_record_state()
 | 
			
		||||
        super().run_check()
 | 
			
		||||
 | 
			
		||||
    def _check_record_state(self):
 | 
			
		||||
        """ Checks the data quality for recorded state
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        if self.obj.recorded is None:
 | 
			
		||||
            self.messages.append(
 | 
			
		||||
                _("Not recorded")
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
    def _check_legal_data(self):
 | 
			
		||||
        """ Checks the data quality for Legal
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -189,27 +189,43 @@ class CheckModalForm(BaseModalForm):
 | 
			
		||||
        widget=forms.CheckboxInput(),
 | 
			
		||||
        required=True
 | 
			
		||||
    )
 | 
			
		||||
    valid = None
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        self.form_title = _("Run check")
 | 
			
		||||
        self.form_caption = _("I, {} {}, confirm that all necessary control steps have been performed by myself.").format(self.user.first_name, self.user.last_name)
 | 
			
		||||
        self.valid = False
 | 
			
		||||
 | 
			
		||||
    def is_valid(self) -> bool:
 | 
			
		||||
        """ Perform a validity check based on quality_check() logic
 | 
			
		||||
    def _are_deductions_valid(self):
 | 
			
		||||
        """ Performs validity checks on deductions and their eco-account
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            result (bool)
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        deductions = self.instance.deductions.all()
 | 
			
		||||
        for deduction in deductions:
 | 
			
		||||
            checker = deduction.account.quality_check()
 | 
			
		||||
            for msg in checker.messages:
 | 
			
		||||
                self.add_error(
 | 
			
		||||
                    "checked_comps",
 | 
			
		||||
                    f"{deduction.account.identifier}: {msg}"
 | 
			
		||||
                )
 | 
			
		||||
            return checker.valid
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def _are_comps_valid(self):
 | 
			
		||||
        """ Performs validity checks on all types of compensations
 | 
			
		||||
 | 
			
		||||
        Types of compensations are
 | 
			
		||||
            * regular Compensations
 | 
			
		||||
            * deductions from EcoAccounts
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        super_result = super().is_valid()
 | 
			
		||||
        # Perform check
 | 
			
		||||
        checker = self.instance.quality_check()
 | 
			
		||||
        for msg in checker.messages:
 | 
			
		||||
            self.add_error(
 | 
			
		||||
                "checked_intervention",
 | 
			
		||||
                msg
 | 
			
		||||
            )
 | 
			
		||||
        comps = self.instance.compensations.all()
 | 
			
		||||
        comps_valid = True
 | 
			
		||||
        for comp in comps:
 | 
			
		||||
            checker = comp.quality_check()
 | 
			
		||||
            for msg in checker.messages:
 | 
			
		||||
@ -217,7 +233,28 @@ class CheckModalForm(BaseModalForm):
 | 
			
		||||
                    "checked_comps",
 | 
			
		||||
                    f"{comp.identifier}: {msg}"
 | 
			
		||||
                )
 | 
			
		||||
        return super_result and checker.valid
 | 
			
		||||
            comps_valid = checker.valid
 | 
			
		||||
        deductions_valid = self._are_deductions_valid()
 | 
			
		||||
        return deductions_valid and comps_valid
 | 
			
		||||
 | 
			
		||||
    def is_valid(self) -> bool:
 | 
			
		||||
        """ Perform a validity check based on quality_check() logic
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            result (bool)
 | 
			
		||||
        """
 | 
			
		||||
        super_valid = super().is_valid()
 | 
			
		||||
        # Perform check
 | 
			
		||||
        checker = self.instance.quality_check()
 | 
			
		||||
        for msg in checker.messages:
 | 
			
		||||
            self.add_error(
 | 
			
		||||
                "checked_intervention",
 | 
			
		||||
                msg
 | 
			
		||||
            )
 | 
			
		||||
        all_comps_valid = self._are_comps_valid()
 | 
			
		||||
        intervention_valid = checker.valid
 | 
			
		||||
 | 
			
		||||
        return super_valid and intervention_valid and all_comps_valid
 | 
			
		||||
 | 
			
		||||
    def save(self):
 | 
			
		||||
        """ Saving logic
 | 
			
		||||
 | 
			
		||||
@ -145,7 +145,8 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
 | 
			
		||||
 | 
			
		||||
    def set_checked(self, user: User) -> UserActionLogEntry:
 | 
			
		||||
        log_entry = super().set_checked(user)
 | 
			
		||||
        self.add_log_entry_to_compensations(log_entry)
 | 
			
		||||
        if log_entry is not None:
 | 
			
		||||
            self.add_log_entry_to_compensations(log_entry)
 | 
			
		||||
        return log_entry
 | 
			
		||||
 | 
			
		||||
    def set_unrecorded(self, user: User):
 | 
			
		||||
 | 
			
		||||
@ -492,6 +492,23 @@ class RecordModalForm(BaseModalForm):
 | 
			
		||||
            valid = valid and comps_valid
 | 
			
		||||
        return super_val and valid
 | 
			
		||||
 | 
			
		||||
    def _are_deductions_valid(self):
 | 
			
		||||
        """ Performs validity checks on deductions and their eco-account
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        deductions = self.instance.deductions.all()
 | 
			
		||||
        for deduction in deductions:
 | 
			
		||||
            checker = deduction.account.quality_check()
 | 
			
		||||
            for msg in checker.messages:
 | 
			
		||||
                self.add_error(
 | 
			
		||||
                    "confirm",
 | 
			
		||||
                    f"{deduction.account.identifier}: {msg}"
 | 
			
		||||
                )
 | 
			
		||||
            return checker.valid
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def _are_compensations_valid(self):
 | 
			
		||||
        """ Runs a special case for intervention-compensations validity
 | 
			
		||||
 | 
			
		||||
@ -508,7 +525,10 @@ class RecordModalForm(BaseModalForm):
 | 
			
		||||
                    "confirm",
 | 
			
		||||
                    f"{comp.identifier}: {msg}"
 | 
			
		||||
                )
 | 
			
		||||
        return comps_valid
 | 
			
		||||
 | 
			
		||||
        deductions_valid = self._are_deductions_valid()
 | 
			
		||||
 | 
			
		||||
        return comps_valid and deductions_valid
 | 
			
		||||
 | 
			
		||||
    def save(self):
 | 
			
		||||
        with transaction.atomic():
 | 
			
		||||
 | 
			
		||||
@ -119,18 +119,8 @@
 | 
			
		||||
                                    <button class="btn btn-default">{% fa5_icon 'eye' %} {% trans 'Show' %}</button>
 | 
			
		||||
                                </a>
 | 
			
		||||
                            </div>
 | 
			
		||||
 | 
			
		||||
                        </div>
 | 
			
		||||
 | 
			
		||||
                        </div>
 | 
			
		||||
                    <div class="col-sm-12 col-lg">
 | 
			
		||||
                        <div class="col-sm">
 | 
			
		||||
                            <div class="row my-1">
 | 
			
		||||
                                <a href="{% url 'home' %}">
 | 
			
		||||
                                    <button class="btn btn-default">{% fa5_icon 'magic' %} {% trans 'Deduct' %}</button>
 | 
			
		||||
                                </a>
 | 
			
		||||
                            </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <hr>
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@ -19,7 +19,7 @@ msgid ""
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Project-Id-Version: PACKAGE VERSION\n"
 | 
			
		||||
"Report-Msgid-Bugs-To: \n"
 | 
			
		||||
"POT-Creation-Date: 2022-01-06 12:04+0100\n"
 | 
			
		||||
"POT-Creation-Date: 2022-01-07 15:32+0100\n"
 | 
			
		||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 | 
			
		||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 | 
			
		||||
"Language-Team: LANGUAGE <LL@li.org>\n"
 | 
			
		||||
@ -40,7 +40,7 @@ msgstr "Bis"
 | 
			
		||||
#: analysis/forms.py:47 compensation/forms/forms.py:77
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/view.html:58
 | 
			
		||||
#: compensation/templates/compensation/report/eco_account/report.html:16
 | 
			
		||||
#: compensation/utils/quality.py:100 ema/templates/ema/detail/view.html:49
 | 
			
		||||
#: compensation/utils/quality.py:112 ema/templates/ema/detail/view.html:49
 | 
			
		||||
#: ema/templates/ema/report/report.html:16 ema/utils/quality.py:26
 | 
			
		||||
#: intervention/forms/forms.py:100
 | 
			
		||||
#: intervention/templates/intervention/detail/view.html:56
 | 
			
		||||
@ -212,7 +212,7 @@ msgstr "Abbuchungen"
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:36
 | 
			
		||||
#: ema/templates/ema/detail/includes/states-after.html:36
 | 
			
		||||
#: ema/templates/ema/detail/includes/states-before.html:36
 | 
			
		||||
#: intervention/forms/modalForms.py:258
 | 
			
		||||
#: intervention/forms/modalForms.py:295
 | 
			
		||||
msgid "Surface"
 | 
			
		||||
msgstr "Fläche"
 | 
			
		||||
 | 
			
		||||
@ -275,7 +275,7 @@ msgid "Type"
 | 
			
		||||
msgstr "Typ"
 | 
			
		||||
 | 
			
		||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:24
 | 
			
		||||
#: intervention/forms/modalForms.py:269 intervention/forms/modalForms.py:276
 | 
			
		||||
#: intervention/forms/modalForms.py:306 intervention/forms/modalForms.py:313
 | 
			
		||||
#: intervention/tables.py:88
 | 
			
		||||
#: intervention/templates/intervention/detail/view.html:19
 | 
			
		||||
#: konova/templates/konova/home.html:11 templates/navbars/navbar.html:22
 | 
			
		||||
@ -285,7 +285,7 @@ msgstr "Eingriff"
 | 
			
		||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:34
 | 
			
		||||
#: compensation/tables.py:224
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/view.html:19
 | 
			
		||||
#: intervention/forms/modalForms.py:242 intervention/forms/modalForms.py:249
 | 
			
		||||
#: intervention/forms/modalForms.py:279 intervention/forms/modalForms.py:286
 | 
			
		||||
#: konova/templates/konova/home.html:88 templates/navbars/navbar.html:34
 | 
			
		||||
msgid "Eco-account"
 | 
			
		||||
msgstr "Ökokonto"
 | 
			
		||||
@ -367,7 +367,7 @@ msgstr "Zusätzlicher Kommentar"
 | 
			
		||||
#: compensation/forms/forms.py:93
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/view.html:62
 | 
			
		||||
#: compensation/templates/compensation/report/eco_account/report.html:20
 | 
			
		||||
#: compensation/utils/quality.py:102 ema/templates/ema/detail/view.html:53
 | 
			
		||||
#: compensation/utils/quality.py:114 ema/templates/ema/detail/view.html:53
 | 
			
		||||
#: ema/templates/ema/report/report.html:20 ema/utils/quality.py:28
 | 
			
		||||
#: intervention/forms/forms.py:128
 | 
			
		||||
#: intervention/templates/intervention/detail/view.html:60
 | 
			
		||||
@ -427,7 +427,7 @@ msgstr "Neue Kompensation"
 | 
			
		||||
msgid "Edit compensation"
 | 
			
		||||
msgstr "Bearbeite Kompensation"
 | 
			
		||||
 | 
			
		||||
#: compensation/forms/forms.py:302 compensation/utils/quality.py:84
 | 
			
		||||
#: compensation/forms/forms.py:302 compensation/utils/quality.py:96
 | 
			
		||||
msgid "Available Surface"
 | 
			
		||||
msgstr "Verfügbare Fläche"
 | 
			
		||||
 | 
			
		||||
@ -437,7 +437,7 @@ msgstr "Die für Abbuchungen zur Verfügung stehende Menge"
 | 
			
		||||
 | 
			
		||||
#: compensation/forms/forms.py:314
 | 
			
		||||
#: compensation/templates/compensation/detail/eco_account/view.html:66
 | 
			
		||||
#: compensation/utils/quality.py:72
 | 
			
		||||
#: compensation/utils/quality.py:84
 | 
			
		||||
msgid "Agreement date"
 | 
			
		||||
msgstr "Vereinbarungsdatum"
 | 
			
		||||
 | 
			
		||||
@ -492,7 +492,7 @@ msgstr "Biotoptyp"
 | 
			
		||||
msgid "Select the biotope type"
 | 
			
		||||
msgstr "Biotoptyp wählen"
 | 
			
		||||
 | 
			
		||||
#: compensation/forms/modalForms.py:136 intervention/forms/modalForms.py:260
 | 
			
		||||
#: compensation/forms/modalForms.py:136 intervention/forms/modalForms.py:297
 | 
			
		||||
msgid "in m²"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
@ -1033,17 +1033,21 @@ msgstr "-"
 | 
			
		||||
msgid "States unequal"
 | 
			
		||||
msgstr "Ungleiche Zustandsflächenmengen"
 | 
			
		||||
 | 
			
		||||
#: compensation/utils/quality.py:74 intervention/utils/quality.py:84
 | 
			
		||||
#: compensation/utils/quality.py:72
 | 
			
		||||
msgid "Not recorded"
 | 
			
		||||
msgstr "Noch nicht verzeichnet"
 | 
			
		||||
 | 
			
		||||
#: compensation/utils/quality.py:86 intervention/utils/quality.py:84
 | 
			
		||||
msgid "Legal data"
 | 
			
		||||
msgstr "Rechtliche Daten"
 | 
			
		||||
 | 
			
		||||
#: compensation/utils/quality.py:88
 | 
			
		||||
#: compensation/utils/quality.py:100
 | 
			
		||||
msgid "Deductable surface can not be larger than state surface"
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht "
 | 
			
		||||
"überschreiten"
 | 
			
		||||
 | 
			
		||||
#: compensation/utils/quality.py:104 ema/utils/quality.py:30
 | 
			
		||||
#: compensation/utils/quality.py:116 ema/utils/quality.py:30
 | 
			
		||||
#: intervention/utils/quality.py:55
 | 
			
		||||
msgid "Responsible data"
 | 
			
		||||
msgstr "Daten zu den verantwortlichen Stellen"
 | 
			
		||||
@ -1328,12 +1332,12 @@ msgstr "Eingriffsdaten geprüft"
 | 
			
		||||
msgid "Checked compensations data and payments"
 | 
			
		||||
msgstr "Kompensationen und Zahlungen geprüft"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:195
 | 
			
		||||
#: intervention/forms/modalForms.py:196
 | 
			
		||||
#: intervention/templates/intervention/detail/includes/controls.html:19
 | 
			
		||||
msgid "Run check"
 | 
			
		||||
msgstr "Prüfung vornehmen"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:196 konova/forms.py:457
 | 
			
		||||
#: intervention/forms/modalForms.py:197 konova/forms.py:457
 | 
			
		||||
msgid ""
 | 
			
		||||
"I, {} {}, confirm that all necessary control steps have been performed by "
 | 
			
		||||
"myself."
 | 
			
		||||
@ -1341,23 +1345,23 @@ msgstr ""
 | 
			
		||||
"Ich, {} {}, bestätige, dass die notwendigen Kontrollschritte durchgeführt "
 | 
			
		||||
"wurden:"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:244
 | 
			
		||||
#: intervention/forms/modalForms.py:281
 | 
			
		||||
msgid "Only recorded accounts can be selected for deductions"
 | 
			
		||||
msgstr "Nur verzeichnete Ökokonten können für Abbuchungen verwendet werden."
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:271
 | 
			
		||||
#: intervention/forms/modalForms.py:308
 | 
			
		||||
msgid "Only shared interventions can be selected"
 | 
			
		||||
msgstr "Nur freigegebene Eingriffe können gewählt werden"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:284
 | 
			
		||||
#: intervention/forms/modalForms.py:321
 | 
			
		||||
msgid "New Deduction"
 | 
			
		||||
msgstr "Neue Abbuchung"
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:285
 | 
			
		||||
#: intervention/forms/modalForms.py:322
 | 
			
		||||
msgid "Enter the information for a new deduction from a chosen eco-account"
 | 
			
		||||
msgstr "Geben Sie die Informationen für eine neue Abbuchung ein."
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:313
 | 
			
		||||
#: intervention/forms/modalForms.py:350
 | 
			
		||||
msgid ""
 | 
			
		||||
"Eco-account {} is not recorded yet. You can only deduct from recorded "
 | 
			
		||||
"accounts."
 | 
			
		||||
@ -1365,7 +1369,7 @@ msgstr ""
 | 
			
		||||
"Ökokonto {} ist noch nicht verzeichnet. Abbuchungen können nur von "
 | 
			
		||||
"verzeichneten Ökokonten erfolgen."
 | 
			
		||||
 | 
			
		||||
#: intervention/forms/modalForms.py:326
 | 
			
		||||
#: intervention/forms/modalForms.py:363
 | 
			
		||||
msgid ""
 | 
			
		||||
"The account {} has not enough surface for a deduction of {} m². There are "
 | 
			
		||||
"only {} m² left"
 | 
			
		||||
@ -1659,10 +1663,6 @@ msgstr "Neu"
 | 
			
		||||
msgid "Show"
 | 
			
		||||
msgstr "Anzeigen"
 | 
			
		||||
 | 
			
		||||
#: konova/templates/konova/home.html:130
 | 
			
		||||
msgid "Deduct"
 | 
			
		||||
msgstr "Abbuchen"
 | 
			
		||||
 | 
			
		||||
#: konova/templates/konova/includes/parcels.html:3
 | 
			
		||||
msgid "Spatial reference"
 | 
			
		||||
msgstr "Raumreferenz"
 | 
			
		||||
@ -3560,6 +3560,9 @@ msgstr ""
 | 
			
		||||
msgid "Unable to connect to qpid with SASL mechanism %s"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#~ msgid "Deduct"
 | 
			
		||||
#~ msgstr "Abbuchen"
 | 
			
		||||
 | 
			
		||||
#~ msgid "No file given!"
 | 
			
		||||
#~ msgstr "Keine Datei angegeben!"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user