Passed
Push — 2.x ( 7dea5e...a4b1ed )
by Jordi
05:39
created

senaite.core.browser.form.adapters.analysisprofile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 18
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A EditForm.initialized() 0 3 1
A EditForm.toggle_price_vat_fields() 0 7 2
A EditForm.modified() 0 6 2
1
# -*- coding: utf-8 -*-
2
3
from senaite.core.browser.form.adapters import EditFormAdapterBase
4
5
6
class EditForm(EditFormAdapterBase):
7
    """Edit form adapter for Analysis Profiles
8
    """
9
10
    def initialized(self, data):
11
        self.toggle_price_vat_fields(False)
12
        return self.data
13
14
    def modified(self, data):
15
        name = data.get("name")
16
        value = data.get("value")
17
        if name == "UseAnalysisProfilePrice":
18
            self.toggle_price_vat_fields(value)
19
        return self.data
20
21
    def toggle_price_vat_fields(self, toggle=False):
22
        if toggle:
23
            self.add_show_field("AnalysisProfilePrice")
24
            self.add_show_field("AnalysisProfileVAT")
25
        else:
26
            self.add_hide_field("AnalysisProfilePrice")
27
            self.add_hide_field("AnalysisProfileVAT")
28