浏览代码

[useradmin] Hide LDAP sync buttons when LDAP is not configured

Romain Rigaux 11 年之前
父节点
当前提交
05774d2

+ 6 - 0
apps/useradmin/src/useradmin/templates/list_groups.mako

@@ -42,10 +42,16 @@ ${layout.menubar(section='groups')}
       </%def>
       <%def name="creation()">
         %if user.is_superuser:
+          % if is_ldap_setup:
             <a id="addGroupBtn" href="${url('useradmin.views.edit_group')}" class="btn"><i
                 class="fa fa-plus-circle"></i> ${_('Add group')}</a>
             <a id="addLdapGroupBtn" href="${url('useradmin.views.add_ldap_groups')}" class="btn"><i
                 class="fa fa-refresh"></i> ${_('Add/Sync LDAP group')}</a>
+          % endif
+          <a href="http://gethue.tumblr.com/post/75499679342/making-hadoop-accessible-to-your-employees-with-ldap" class="btn"
+            title="${ ('Learn how to integrate Hue with your company') }" target="_blank">
+            <i class="fa fa-question-circle"> LDAP</i>
+          </a>
         %endif
       </%def>
     </%actionbar:render>

+ 8 - 0
apps/useradmin/src/useradmin/templates/list_users.mako

@@ -43,11 +43,19 @@ ${layout.menubar(section='users')}
       <%def name="creation()">
         %if user.is_superuser:
             <a href="${ url('useradmin.views.edit_user') }" class="btn"><i class="fa fa-user"></i> ${_('Add user')}</a>
+
+            % if is_ldap_setup:
             <a href="${ url('useradmin.views.add_ldap_users') }" class="btn"><i
                 class="fa fa-briefcase"></i> ${_('Add/Sync LDAP user')}</a>
             <a href="javascript:void(0)" class="btn confirmationModal"
                data-confirmation-url="${ url('useradmin.views.sync_ldap_users_groups') }"><i
                 class="fa fa-refresh"></i> ${_('Sync LDAP users/groups')}</a>
+            % endif
+
+            <a href="http://gethue.tumblr.com/post/75499679342/making-hadoop-accessible-to-your-employees-with-ldap" class="btn"
+              title="${ ('Learn how to integrate Hue with your company') }" target="_blank">
+              <i class="fa fa-question-circle"> LDAP</i>
+            </a>
         %endif
       </%def>
     </%actionbar:render>

+ 8 - 6
apps/useradmin/src/useradmin/views.py

@@ -15,10 +15,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-User management application.
-"""
-
 import pwd
 import grp
 import logging
@@ -39,6 +35,7 @@ from django.shortcuts import redirect
 from django.http import HttpResponse
 
 import desktop.conf
+from desktop.conf import LDAP
 from hadoop.fs.exceptions import WebHdfsException
 from useradmin.models import HuePermission, UserProfile, LdapGroup
 from useradmin.models import get_profile, get_default_user_group
@@ -47,6 +44,7 @@ from useradmin.forms import SyncLdapUsersGroupsForm, AddLdapGroupsForm,\
   UserChangeForm
 
 
+
 LOG = logging.getLogger(__name__)
 
 __users_lock = threading.Lock()
@@ -57,12 +55,16 @@ def list_users(request):
   return render("list_users.mako", request, {
       'users': User.objects.all(),
       'users_json': json.dumps(list(User.objects.values_list('id', flat=True))),
-      'request': request
+      'request': request,
+      'is_ldap_setup': LDAP.LDAP_URL.get() is not None
   })
 
 
 def list_groups(request):
-  return render("list_groups.mako", request, dict(groups=Group.objects.all()))
+  return render("list_groups.mako", request, {
+      'groups': Group.objects.all(),
+      'is_ldap_setup': LDAP.LDAP_URL.get() is not None
+  })
 
 
 def list_permissions(request):