changeset 2931:4c7cc3a4c330 beta

fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view. Removed JS code and the logic for that is in python view now. Simpler and less ugly JS callbacks
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 17 Oct 2012 21:13:04 +0200
parents a01c5994015c
children 19ea3e16f65b
files rhodecode/controllers/files.py rhodecode/templates/files/files_source.html
diffstat 2 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/files.py	Wed Oct 17 20:46:54 2012 +0200
+++ b/rhodecode/controllers/files.py	Wed Oct 17 21:13:04 2012 +0200
@@ -37,7 +37,8 @@
 from rhodecode.lib import helpers as h
 
 from rhodecode.lib.compat import OrderedDict
-from rhodecode.lib.utils2 import convert_line_endings, detect_mode, safe_str
+from rhodecode.lib.utils2 import convert_line_endings, detect_mode, safe_str,\
+    str2bool
 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 from rhodecode.lib.base import BaseRepoController, render
 from rhodecode.lib.vcs.backends.base import EmptyChangeset
@@ -430,6 +431,18 @@
         c.context_url = _context_url
         c.changes = OrderedDict()
         c.changes[diff2] = []
+
+        #special case if we want a show rev only, it's impl here
+        #to reduce JS and callbacks
+        if request.GET.get('show_rev'):
+            if str2bool(request.GET.get('annotate', 'False')):
+                _url = url('files_annotate_home', repo_name=c.repo_name,
+                           revision=diff1, f_path=c.f_path)
+            else:
+                _url = url('files_home', repo_name=c.repo_name,
+                           revision=diff1, f_path=c.f_path)
+
+            return redirect(_url)
         try:
             if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
                 c.changeset_1 = c.rhodecode_repo.get_changeset(diff1)
--- a/rhodecode/templates/files/files_source.html	Wed Oct 17 20:46:54 2012 +0200
+++ b/rhodecode/templates/files/files_source.html	Wed Oct 17 21:13:04 2012 +0200
@@ -8,6 +8,7 @@
     		${h.select('diff1',c.file_changeset.raw_id,c.file_history)}
     		${h.submit('diff',_('diff to revision'),class_="ui-btn")}
     		${h.submit('show_rev',_('show at revision'),class_="ui-btn")}
+            ${h.hidden('annotate', c.annotate)}
     		${h.end_form()}
     		</div>
             <div class="file_author">
@@ -111,16 +112,7 @@
     window.location.hash = old_hash;
 
     }
-    YUE.on('show_rev','click',function(e){
-    	YUE.preventDefault(e);
-        var cs = YUD.get('diff1').value;
-        %if c.annotate:
-          var url = "${h.url('files_annotate_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs);
-        %else:
-          var url = "${h.url('files_home',repo_name=c.repo_name,revision='__CS__',f_path=c.f_path)}".replace('__CS__',cs);
-        %endif
-        window.location = url;
-    });
+
     YUE.on('hlcode','mouseup',getSelectionLink("${_('Selection link')}"))
    });
 </script>