Code Duplication    Length = 22-22 lines in 2 locations

bika/lims/validators.py 2 locations

@@ 53-74 (lines=22) @@
50
validation.register(IdentifierTypeAttributesValidator())
51
52
53
class IdentifierValidator:
54
    """some actual validation should go here.
55
    I'm leaving this stub registered, but adding no extra validation.
56
    """
57
58
    implements(IValidator)
59
    name = "identifiervalidator"
60
61
    def __call__(self, value, *args, **kwargs):
62
        instance = kwargs['instance']
63
        request = instance.REQUEST
64
        form = request.get('form', {})
65
        fieldname = kwargs['field'].getName()
66
        form_value = form.get(fieldname, False)
67
        if form_value is False:
68
            # not required...
69
            return True
70
        if value == instance.get(fieldname):
71
            # no change.
72
            return True
73
74
        return True
75
76
77
validation.register(IdentifierValidator())
@@ 26-47 (lines=22) @@
23
from bika.lims import logger
24
25
26
class IdentifierTypeAttributesValidator:
27
    """Validate IdentifierTypeAttributes to ensure that attributes are
28
    not duplicated.
29
    """
30
31
    implements(IValidator)
32
    name = "identifiertypeattributesvalidator"
33
34
    def __call__(self, value, *args, **kwargs):
35
        instance = kwargs['instance']
36
        request = instance.REQUEST
37
        form = request.get('form', {})
38
        fieldname = kwargs['field'].getName()
39
        form_value = form.get(fieldname, False)
40
        if form_value is False:
41
            # not required...
42
            return True
43
        if value == instance.get(fieldname):
44
            # no change.
45
            return True
46
47
        return True
48
49
50
validation.register(IdentifierTypeAttributesValidator())