# HG changeset patch # User Marcin Kuzminski # Date 2019-01-08 17:54:53 # Node ID 27e2bdc51c3d85490fc038dbb2cf6d7701c92692 # Parent 7adf2b03d09d88f4c7640efd0171f83a5ca5de2b search: show all results for super-admin, and get repo type from index it if exists. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -736,6 +736,7 @@ class _RepoChecker(object): _type = repository return _type == self._backend_alias + is_git = _RepoChecker('git') is_hg = _RepoChecker('hg') is_svn = _RepoChecker('svn') @@ -743,7 +744,8 @@ is_svn = _RepoChecker('svn') def get_repo_type_by_name(repo_name): repo = Repository.get_by_repo_name(repo_name) - return repo.repo_type + if repo: + return repo.repo_type def is_svn_without_proxy(repository): diff --git a/rhodecode/templates/search/search_commit.mako b/rhodecode/templates/search/search_commit.mako --- a/rhodecode/templates/search/search_commit.mako +++ b/rhodecode/templates/search/search_commit.mako @@ -19,14 +19,15 @@ %for entry in c.formatted_results: ## search results are additionally filtered, and this check is just a safe gate - % if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results commit check'): + % if c.rhodecode_user.is_admin or h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results commit check'): - %if h.get_repo_type_by_name(entry.get('repository')) == 'hg': + <% repo_type = entry.get('repo_type') or h.get_repo_type_by_name(entry.get('repository')) %> + %if repo_type == 'hg': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'git': + %elif repo_type == 'git': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'svn': + %elif repo_type == 'svn': %endif ${h.link_to(entry['repository'], h.route_path('repo_summary',repo_name=entry['repository']))} @@ -77,13 +78,13 @@ var cid = target_expand.data('commit-id'); if (target_expand.hasClass('open')){ - $('#c-'+cid).css({'height': '1.5em', 'white-space': 'nowrap', 'text-overflow': 'ellipsis', 'overflow':'hidden'}) - $('#t-'+cid).css({'height': 'auto', 'line-height': '.9em', 'text-overflow': 'ellipsis', 'overflow':'hidden'}) + $('#c-'+cid).css({'height': '1.5em', 'white-space': 'nowrap', 'text-overflow': 'ellipsis', 'overflow':'hidden'}); + $('#t-'+cid).css({'height': 'auto', 'line-height': '.9em', 'text-overflow': 'ellipsis', 'overflow':'hidden'}); target_expand.removeClass('open'); } else { - $('#c-'+cid).css({'height': 'auto', 'white-space': 'normal', 'text-overflow': 'initial', 'overflow':'visible'}) - $('#t-'+cid).css({'height': 'auto', 'max-height': 'none', 'text-overflow': 'initial', 'overflow':'visible'}) + $('#c-'+cid).css({'height': 'auto', 'white-space': 'normal', 'text-overflow': 'initial', 'overflow':'visible'}); + $('#t-'+cid).css({'height': 'auto', 'max-height': 'none', 'text-overflow': 'initial', 'overflow':'visible'}); target_expand.addClass('open'); } }); diff --git a/rhodecode/templates/search/search_content.mako b/rhodecode/templates/search/search_content.mako --- a/rhodecode/templates/search/search_content.mako +++ b/rhodecode/templates/search/search_content.mako @@ -56,15 +56,16 @@ %> ## search results are additionally filtered, and this check is just a safe gate - % if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results content check'): + % if c.rhodecode_user.is_admin or h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results content check'):

- %if h.get_repo_type_by_name(entry.get('repository')) == 'hg': + <% repo_type = entry.get('repo_type') or h.get_repo_type_by_name(entry.get('repository')) %> + %if repo_type == 'hg': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'git': + %elif repo_type == 'git': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'svn': + %elif repo_type == 'svn': %endif ${h.link_to(entry['repository'], h.route_path('repo_summary',repo_name=entry['repository']))} diff --git a/rhodecode/templates/search/search_path.mako b/rhodecode/templates/search/search_path.mako --- a/rhodecode/templates/search/search_path.mako +++ b/rhodecode/templates/search/search_path.mako @@ -9,14 +9,15 @@ %for entry in c.formatted_results: ## search results are additionally filtered, and this check is just a safe gate - % if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results path check'): + % if c.rhodecode_user.is_admin or h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results path check'): - %if h.get_repo_type_by_name(entry.get('repository')) == 'hg': + <% repo_type = entry.get('repo_type') or h.get_repo_type_by_name(entry.get('repository')) %> + %if repo_type == 'hg': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'git': + %elif repo_type == 'git': - %elif h.get_repo_type_by_name(entry.get('repository')) == 'svn': + %elif repo_type == 'svn': %endif ${h.link_to(entry['repository'], h.route_path('repo_summary',repo_name=entry['repository']))}