changeset 3627:32cb8d45f330 beta

helpers: show boolean value of value as icon, not just the True and False singletons
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Mar 2013 01:10:45 +0100
parents 0a1417ef1a9c
children c734686b3cf2
files rhodecode/controllers/admin/users.py rhodecode/lib/helpers.py rhodecode/templates/admin/permissions/permissions.html rhodecode/templates/admin/repos/repo_edit.html rhodecode/templates/admin/users/user_edit.html rhodecode/templates/admin/users/user_edit_my_account.html rhodecode/templates/admin/users_groups/users_groups.html
diffstat 7 files changed, 13 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/admin/users.py	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/controllers/admin/users.py	Thu Mar 28 01:10:45 2013 +0100
@@ -99,9 +99,9 @@
                 "lastname": user.lastname,
                 "last_login": h.fmt_date(user.last_login),
                 "last_login_raw": datetime_to_time(user.last_login),
-                "active": h.bool2icon(user.active),
-                "admin": h.bool2icon(user.admin),
-                "ldap": h.bool2icon(bool(user.ldap_dn)),
+                "active": h.boolicon(user.active),
+                "admin": h.boolicon(user.admin),
+                "ldap": h.boolicon(bool(user.ldap_dn)),
                 "action": user_actions(user.user_id, user.username),
             })
 
--- a/rhodecode/lib/helpers.py	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/lib/helpers.py	Thu Mar 28 01:10:45 2013 +0100
@@ -494,23 +494,20 @@
     return value
 
 
-def bool2icon(value):
-    """Returns True/False values represented as small html image of true/false
+def boolicon(value):
+    """Returns boolean value of a value, represented as small html image of true/false
     icons
 
-    :param value: bool value
+    :param value: value
     """
 
-    if value is True:
+    if value:
         return HTML.tag('img', src=url("/images/icons/accept.png"),
                         alt=_('True'))
-
-    if value is False:
+    else:
         return HTML.tag('img', src=url("/images/icons/cancel.png"),
                         alt=_('False'))
 
-    return value
-
 
 def action_parser(user_log, feed=False, parse_cs=False):
     """
--- a/rhodecode/templates/admin/permissions/permissions.html	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/templates/admin/permissions/permissions.html	Thu Mar 28 01:10:45 2013 +0100
@@ -139,7 +139,7 @@
                         </td>
                         <td>
                             %if section == 'global':
-                             ${h.bool2icon(k.split('.')[-1] != 'none')}
+                             ${h.boolicon(k.split('.')[-1] != 'none')}
                             %else:
                              <span class="perm_tag ${_perm}">${section_perm}</span>
                             %endif
--- a/rhodecode/templates/admin/repos/repo_edit.html	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/templates/admin/repos/repo_edit.html	Thu Mar 28 01:10:45 2013 +0100
@@ -221,7 +221,7 @@
                   <tr>
                     <td>${cache.get_prefix() or '-'}</td>
                     <td>${cache.cache_key}</td>
-                    <td>${h.bool2icon(cache.cache_active)}</td>
+                    <td>${h.boolicon(cache.cache_active)}</td>
                   </tr>
               %endfor
               </table>
--- a/rhodecode/templates/admin/users/user_edit.html	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/templates/admin/users/user_edit.html	Thu Mar 28 01:10:45 2013 +0100
@@ -225,7 +225,7 @@
                         </td>
                         <td>
                             %if section == 'global':
-                             ${h.bool2icon(k.split('.')[-1] != 'none')}
+                             ${h.boolicon(k.split('.')[-1] != 'none')}
                             %else:
                              <span class="perm_tag ${_perm}">${section_perm}</span>
                             %endif
--- a/rhodecode/templates/admin/users/user_edit_my_account.html	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/templates/admin/users/user_edit_my_account.html	Thu Mar 28 01:10:45 2013 +0100
@@ -77,7 +77,7 @@
                     </td>
                     <td>
                         %if section == 'global':
-                         ${h.bool2icon(True)}
+                         ${h.boolicon(True)}
                         %else:
                         <span class="perm_tag ${_perm}">${section_perm}</span>
                         %endif
--- a/rhodecode/templates/admin/users_groups/users_groups.html	Thu Mar 28 01:10:45 2013 +0100
+++ b/rhodecode/templates/admin/users_groups/users_groups.html	Thu Mar 28 01:10:45 2013 +0100
@@ -40,7 +40,7 @@
                 <tr class="parity${cnt%2}">
                     <td>${h.link_to(u_group.users_group_name,h.url('edit_users_group', id=u_group.users_group_id))}</td>
                     <td><span class="tooltip" title="${h.tooltip(', '.join(map(h.safe_unicode,[x.user.username for x in u_group.members[:50]])))}">${len(u_group.members)}</span></td>
-                    <td>${h.bool2icon(u_group.users_group_active)}</td>
+                    <td>${h.boolicon(u_group.users_group_active)}</td>
                     <td>
                         ${h.form(url('users_group', id=u_group.users_group_id),method='delete')}
                             ${h.submit('remove_',_('delete'),id="remove_group_%s" % u_group.users_group_id,