def clean(self):
    cleaned_data = super(CommonQuotaAction, self).clean()
    usages = quotas.tenant_quota_usages(self.request, tenant_id=self.initial['project_id'], targets=tuple(self._quota_fields))
    bad_values = []
    for (key, value) in cleaned_data.items():
        used = usages[key].get('used', 0)
        if ((value is not None) and (0 <= value < used)):
            bad_values.append((_('%(used)s %(key)s used') % {'used': used, 'key': quotas.QUOTA_NAMES.get(key, key)}))
    if bad_values:
        value_str = ', '.join(bad_values)
        msg = (_('Quota value(s) cannot be less than the current usage value(s): %s.') % value_str)
        raise forms.ValidationError(msg)
    return cleaned_data
def clean(self):
    cleaned_data = super(CommonQuotaAction, self).clean()
    usages = quotas.tenant_quota_usages(self.request, tenant_id=self.initial['project_id'], targets=tuple(self._quota_fields))
    bad_values = []
    for (key, value) in cleaned_data.items():
        used = usages[key].get('used', 0)
        if ((value is not None) and (0 <= value < used)):
            bad_values.append((_('%(used)s %(key)s used') % {'used': used, 'key': quotas.QUOTA_NAMES.get(key, key)}))
    if bad_values:
        value_str = ', '.join(bad_values)
        msg = (_('Quota value(s) cannot be less than the current usage value(s): %s.') % value_str)
        raise forms.ValidationError(msg)
    return cleaned_data