"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 25.10.21

"""
from django.utils.translation import gettext_lazy as _
from compensation.utils.quality import CompensationQualityChecker


class EmaQualityChecker(CompensationQualityChecker):
    def run_check(self):
        super().run_check()
        self._check_responsible_data()

    def _check_responsible_data(self):
        """ Checks on responsible data quality

        Returns:

        """
        try:
            resp = self.obj.responsible
            if resp.conservation_office is None:
                self._add_missing_attr_name(_("Conservation office"))
            if resp.conservation_file_number is None or len(resp.conservation_file_number) == 0:
                self._add_missing_attr_name(_("Conservation office file number"))
        except AttributeError:
            self._add_missing_attr_name(_("Responsible data"))
