##// END OF EJS Templates
refs: refactored references code to remove any pylons elements....
marcink -
r1898:981cb51c default
parent child Browse files
Show More
@@ -26,7 +26,6 b' from pyramid.httpexceptions import HTTPF'
26 from rhodecode.lib import helpers as h
26 from rhodecode.lib import helpers as h
27 from rhodecode.lib.utils2 import StrictAttributeDict, safe_int, datetime_to_time
27 from rhodecode.lib.utils2 import StrictAttributeDict, safe_int, datetime_to_time
28 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
28 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
29 from rhodecode.lib.ext_json import json
30 from rhodecode.model import repo
29 from rhodecode.model import repo
31 from rhodecode.model import repo_group
30 from rhodecode.model import repo_group
32 from rhodecode.model.db import User
31 from rhodecode.model.db import User
@@ -218,28 +217,35 b' class BaseReferencesView(RepoAppView):'
218 return c
217 return c
219
218
220 def load_refs_context(self, ref_items, partials_template):
219 def load_refs_context(self, ref_items, partials_template):
221 _data = []
222 _render = self.request.get_partial_renderer(partials_template)
220 _render = self.request.get_partial_renderer(partials_template)
223 pre_load = ["author", "date", "message"]
221 pre_load = ["author", "date", "message"]
224
222
225 is_svn = h.is_svn(self.rhodecode_vcs_repo)
223 is_svn = h.is_svn(self.rhodecode_vcs_repo)
224 is_hg = h.is_hg(self.rhodecode_vcs_repo)
225
226 format_ref_id = get_format_ref_id(self.rhodecode_vcs_repo)
226 format_ref_id = get_format_ref_id(self.rhodecode_vcs_repo)
227
227
228 closed_refs = {}
229 if is_hg:
230 closed_refs = self.rhodecode_vcs_repo.branches_closed
231
232 data = []
228 for ref_name, commit_id in ref_items:
233 for ref_name, commit_id in ref_items:
229 commit = self.rhodecode_vcs_repo.get_commit(
234 commit = self.rhodecode_vcs_repo.get_commit(
230 commit_id=commit_id, pre_load=pre_load)
235 commit_id=commit_id, pre_load=pre_load)
236 closed = ref_name in closed_refs
231
237
232 # TODO: johbo: Unify generation of reference links
238 # TODO: johbo: Unify generation of reference links
233 use_commit_id = '/' in ref_name or is_svn
239 use_commit_id = '/' in ref_name or is_svn
234 files_url = h.url(
240 files_url = h.url(
235 'files_home',
241 'files_home',
236 repo_name=c.repo_name,
242 repo_name=self.db_repo_name,
237 f_path=ref_name if is_svn else '',
243 f_path=ref_name if is_svn else '',
238 revision=commit_id if use_commit_id else ref_name,
244 revision=commit_id if use_commit_id else ref_name,
239 at=ref_name)
245 at=ref_name)
240
246
241 _data.append({
247 data.append({
242 "name": _render('name', ref_name, files_url),
248 "name": _render('name', ref_name, files_url, closed),
243 "name_raw": ref_name,
249 "name_raw": ref_name,
244 "date": _render('date', commit.date),
250 "date": _render('date', commit.date),
245 "date_raw": datetime_to_time(commit.date),
251 "date_raw": datetime_to_time(commit.date),
@@ -250,8 +256,8 b' class BaseReferencesView(RepoAppView):'
250 "compare": _render(
256 "compare": _render(
251 'compare', format_ref_id(ref_name, commit.raw_id)),
257 'compare', format_ref_id(ref_name, commit.raw_id)),
252 })
258 })
253 c.has_references = bool(_data)
259
254 c.data = json.dumps(_data)
260 return data
255
261
256
262
257 class RepoRoutePredicate(object):
263 class RepoRoutePredicate(object):
@@ -23,8 +23,10 b' from pyramid.httpexceptions import HTTPN'
23 from pyramid.view import view_config
23 from pyramid.view import view_config
24
24
25 from rhodecode.apps._base import BaseReferencesView
25 from rhodecode.apps._base import BaseReferencesView
26 from rhodecode.lib.ext_json import json
27 from rhodecode.lib import helpers as h
26 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
28 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
27 from rhodecode.lib import helpers as h
29
28
30
29 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
30
32
@@ -44,7 +46,9 b' class RepoBookmarksView(BaseReferencesVi'
44 raise HTTPNotFound()
46 raise HTTPNotFound()
45
47
46 ref_items = self.rhodecode_vcs_repo.bookmarks.items()
48 ref_items = self.rhodecode_vcs_repo.bookmarks.items()
47 self.load_refs_context(
49 data = self.load_refs_context(
48 ref_items=ref_items, partials_template='bookmarks/bookmarks_data.mako')
50 ref_items=ref_items, partials_template='bookmarks/bookmarks_data.mako')
49
51
52 c.has_references = bool(data)
53 c.data = json.dumps(data)
50 return self._get_template_context(c)
54 return self._get_template_context(c)
@@ -22,6 +22,7 b' import logging'
22 from pyramid.view import view_config
22 from pyramid.view import view_config
23
23
24 from rhodecode.apps._base import BaseReferencesView
24 from rhodecode.apps._base import BaseReferencesView
25 from rhodecode.lib.ext_json import json
25 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
26 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
26
27
27
28
@@ -38,14 +39,11 b' class RepoBranchesView(BaseReferencesVie'
38 renderer='rhodecode:templates/branches/branches.mako')
39 renderer='rhodecode:templates/branches/branches.mako')
39 def branches(self):
40 def branches(self):
40 c = self.load_default_context()
41 c = self.load_default_context()
41 c.closed_branches = self.rhodecode_vcs_repo.branches_closed
42 # NOTE(marcink):
43 # we need this trick because of PartialRenderer still uses the
44 # global 'c', we might not need this after full pylons migration
45 self._register_global_c(c)
46
42
47 ref_items = self.rhodecode_vcs_repo.branches_all.items()
43 ref_items = self.rhodecode_vcs_repo.branches_all.items()
48 self.load_refs_context(
44 data = self.load_refs_context(
49 ref_items=ref_items, partials_template='branches/branches_data.mako')
45 ref_items=ref_items, partials_template='branches/branches_data.mako')
50
46
47 c.has_references = bool(data)
48 c.data = json.dumps(data)
51 return self._get_template_context(c)
49 return self._get_template_context(c)
@@ -22,6 +22,7 b' import logging'
22 from pyramid.view import view_config
22 from pyramid.view import view_config
23
23
24 from rhodecode.apps._base import BaseReferencesView
24 from rhodecode.apps._base import BaseReferencesView
25 from rhodecode.lib.ext_json import json
25 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
26 from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator)
26
27
27 log = logging.getLogger(__name__)
28 log = logging.getLogger(__name__)
@@ -39,7 +40,9 b' class RepoTagsView(BaseReferencesView):'
39 c = self.load_default_context()
40 c = self.load_default_context()
40
41
41 ref_items = self.rhodecode_vcs_repo.tags.items()
42 ref_items = self.rhodecode_vcs_repo.tags.items()
42 self.load_refs_context(
43 data = self.load_refs_context(
43 ref_items=ref_items, partials_template='tags/tags_data.mako')
44 ref_items=ref_items, partials_template='tags/tags_data.mako')
44
45
46 c.has_references = bool(data)
47 c.data = json.dumps(data)
45 return self._get_template_context(c)
48 return self._get_template_context(c)
@@ -9,7 +9,7 b''
9 </%def>
9 </%def>
10
10
11
11
12 <%def name="name(name, files_url)">
12 <%def name="name(name, files_url, closed)">
13 <span class="tag booktag" title="${h.tooltip(_('Bookmark %s') % (name,))}">
13 <span class="tag booktag" title="${h.tooltip(_('Bookmark %s') % (name,))}">
14 <a href="${files_url}">
14 <a href="${files_url}">
15 <i class="icon-bookmark"></i>
15 <i class="icon-bookmark"></i>
@@ -8,10 +8,10 b''
8 <input class="compare-radio-button" type="radio" name="compare_target" value="${commit_id}"/>
8 <input class="compare-radio-button" type="radio" name="compare_target" value="${commit_id}"/>
9 </%def>
9 </%def>
10
10
11 <%def name="name(name, files_url)">
11 <%def name="name(name, files_url, closed)">
12 <span class="tag branchtag" title="${h.tooltip(_('Branch %s') % (name,))}">
12 <span class="tag branchtag" title="${h.tooltip(_('Branch %s') % (name,))}">
13 <a href="${files_url}"><i class="icon-code-fork"></i>${name}
13 <a href="${files_url}"><i class="icon-code-fork"></i>${name}
14 %if name in c.closed_branches:
14 %if closed:
15 [closed]
15 [closed]
16 %endif
16 %endif
17 </a>
17 </a>
@@ -8,7 +8,7 b''
8 <input class="compare-radio-button" type="radio" name="compare_target" value="${commit_id}"/>
8 <input class="compare-radio-button" type="radio" name="compare_target" value="${commit_id}"/>
9 </%def>
9 </%def>
10
10
11 <%def name="name(name, files_url)">
11 <%def name="name(name, files_url, closed)">
12 <span class="tagtag tag" title="${h.tooltip(_('Tag %s') % (name,))}">
12 <span class="tagtag tag" title="${h.tooltip(_('Tag %s') % (name,))}">
13 <a href="${files_url}"><i class="icon-tag"></i>${name}</a>
13 <a href="${files_url}"><i class="icon-tag"></i>${name}</a>
14 </span>
14 </span>
General Comments 0
You need to be logged in to leave comments. Login now