Просмотр исходного кода

HUE-2875 [useradmin] Disable Edit Profile page details when backend is LDAP

krish 10 лет назад
Родитель
Сommit
55d0912306

+ 6 - 0
apps/useradmin/src/useradmin/forms.py

@@ -103,6 +103,12 @@ class UserChangeForm(django.contrib.auth.forms.UserChangeForm):
       self.fields['first_name'].widget.attrs['readonly'] = True
       self.fields['last_name'].widget.attrs['readonly'] = True
       self.fields['email'].widget.attrs['readonly'] = True
+      if 'is_active' in self.fields:
+        self.fields['is_active'].widget.attrs['readonly'] = True
+      if 'is_superuser' in self.fields:
+        self.fields['is_superuser'].widget.attrs['readonly'] = True
+      if 'groups' in self.fields:
+        self.fields['groups'].widget.attrs['readonly'] = True
 
   def clean_password(self):
     return self.cleaned_data["password"]

+ 9 - 1
desktop/core/src/desktop/templates/common_header.mako

@@ -373,7 +373,15 @@ from django.utils.translation import ugettext as _
     <li class="dropdown">
       <a title="${ _('Administration') }" rel="navigator-tooltip" href="index.html#" data-toggle="dropdown" class="dropdown-toggle"><i class="fa fa-cogs"></i>&nbsp;<span class="hideable">${user.username}&nbsp;</span><b class="caret"></b></a>
       <ul class="dropdown-menu">
-        <li><a href="${ url('useradmin.views.edit_user', username=user.username) }"><i class="fa fa-key"></i>&nbsp;&nbsp;${_('Edit Profile')}</a></li>
+        <li>
+          <a href="${ url('useradmin.views.edit_user', username=user.username) }"><i class="fa fa-key"></i>&nbsp;&nbsp;
+            % if is_ldap_setup:
+              ${_('View Profile')}
+            % else:
+              ${_('Edit Profile')}
+            % endif
+          </a>
+        </li>
         % if user.is_superuser:
           <li><a href="${ url('useradmin.views.list_users') }"><i class="fa fa-group"></i>&nbsp;&nbsp;${_('Manage Users')}</a></li>
         % endif

+ 2 - 1
desktop/core/src/desktop/views.py

@@ -380,7 +380,8 @@ def commonheader(title, section, user, padding="90px"):
     'section': section,
     'padding': padding,
     'user': user,
-    'is_demo': desktop.conf.DEMO_ENABLED.get()
+    'is_demo': desktop.conf.DEMO_ENABLED.get(),
+    'is_ldap_setup': 'desktop.auth.backend.LdapBackend' in desktop.conf.AUTH.BACKEND.get()
   })
 
 def commonshare():