On 07/01/2015 05:39 PM, Tomas Babej wrote:
Hi Thierry,

I think it would be better to use:

error=_('Entry has no \'%s\'') % attr

or even better, use named substitution:

error=_('Entry has no \'%(attribute)s\'') % dict(attribute=attr)

This way will generate a more readable strings for translators.

Tomas
Hi Tomas,

Thanks for reviewing.. you are right this is the common way of adding values in the such error messages.
I followed your recommendations

thanks
thierry
From d1d6295d5c12746f1f1d6c3865386dd0f6c4e111 Mon Sep 17 00:00:00 2001
From: Thierry Bordaz <tbor...@redhat.com>
Date: Wed, 1 Jul 2015 14:46:22 +0200
Subject: [PATCH] Display the wrong attribute name when mandatory attribute is
 missing

	When activating a stageuser, if 'sn' or 'cn' or 'uid' is missing
	it displays an error with 'cn'
---
 ipalib/plugins/stageuser.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
index 7c714f627f000f7b013b60b096e72587cf935022..b3d7c4392586d48cd27aedc4f369f6575e7eea46 100644
--- a/ipalib/plugins/stageuser.py
+++ b/ipalib/plugins/stageuser.py
@@ -514,7 +514,7 @@ class stageuser_activate(LDAPQuery):
             if attr not in entry:
                 raise errors.ValidationError(
                             name=self.obj.primary_key.cli_name,
-                            error=_('Entry has no \'cn\''),
+                            error=_('Entry has no \'%(attribute)s\'') % dict(attribute=attr),
                             )
 
     def _build_new_entry(self, ldap, dn, entry_from, entry_to):
-- 
1.7.11.7

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to