(self)
return cleaned_data
Raise a validation error if there are already 5 data sources and this
        report won't be able to use one of the existing ones.
Raise a validation error if there are already 5 data sources and this
        report won't be able to use one of the existing ones.
Raise a validation error if there are already 5 data sources and this report won t be able to use one of the existing ones .
def clean(self):
        """
        Raise a validation error if there are already 5 data sources and this
        report won't be able to use one of the existing ones.
        """
        cleaned_data = super(DataSourceForm, self).clean()

        existing_reports = ReportConfiguration.by_domain(self.domain)
        builder_reports = [report for report in existing_reports if report.report_meta.created_by_builder]
        if has_report_builder_access(self.domain) and len(builder_reports) >= self.max_allowed_reports:
            # Don't show the warning when domain does not have report buidler access, because this is just a
            # preview and the report will not be saved.
            raise forms.ValidationError(_(
                "Too many reports!\n"
                "Creating this report would cause you to go over the maximum "
                "number of report builder reports allowed in this domain. Your "
                "limit is {number}. "
                "To continue, delete another report and try again. "
            ).format(number=self.max_allowed_reports))

        return cleaned_data
def clean ( self ) : cleaned_data = super ( DataSourceForm , self ) . clean ( ) existing_reports = ReportConfiguration . by_domain ( self . domain ) builder_reports = [ report for report in existing_reports if report . report_meta . created_by_builder ] if has_report_builder_access ( self . domain ) and len ( builder_reports ) >= self . max_allowed_reports : # Don't show the warning when domain does not have report buidler access, because this is just a # preview and the report will not be saved. raise forms . ValidationError ( _ ( "Too many reports!\n" "Creating this report would cause you to go over the maximum " "number of report builder reports allowed in this domain. Your " "limit is {number}. " "To continue, delete another report and try again. " ) . format ( number = self . max_allowed_reports ) ) return cleaned_data