##// END OF EJS Templates
changes for #56
marcink -
r1171:2ab211e0 beta
parent child Browse files
Show More
@@ -0,0 +1,52 b''
1 import logging
2
3 from pylons import request, response, session, tmpl_context as c, url
4 from pylons.controllers.util import abort, redirect
5
6 from rhodecode.lib.base import BaseController, render
7
8 log = logging.getLogger(__name__)
9
10 class ReposGroupsController(BaseController):
11 """REST Controller styled on the Atom Publishing Protocol"""
12 # To properly map this controller, ensure your config/routing.py
13 # file has a resource setup:
14 # map.resource('repos_group', 'repos_groups')
15
16 def index(self, format='html'):
17 """GET /repos_groups: All items in the collection"""
18 # url('repos_groups')
19
20 def create(self):
21 """POST /repos_groups: Create a new item"""
22 # url('repos_groups')
23
24 def new(self, format='html'):
25 """GET /repos_groups/new: Form to create a new item"""
26 # url('new_repos_group')
27
28 def update(self, id):
29 """PUT /repos_groups/id: Update an existing item"""
30 # Forms posted to this method should contain a hidden field:
31 # <input type="hidden" name="_method" value="PUT" />
32 # Or using helpers:
33 # h.form(url('repos_group', id=ID),
34 # method='put')
35 # url('repos_group', id=ID)
36
37 def delete(self, id):
38 """DELETE /repos_groups/id: Delete an existing item"""
39 # Forms posted to this method should contain a hidden field:
40 # <input type="hidden" name="_method" value="DELETE" />
41 # Or using helpers:
42 # h.form(url('repos_group', id=ID),
43 # method='delete')
44 # url('repos_group', id=ID)
45
46 def show(self, id, format='html'):
47 """GET /repos_groups/id: Show a specific item"""
48 # url('repos_group', id=ID)
49
50 def edit(self, id, format='html'):
51 """GET /repos_groups/id/edit: Form to edit an existing item"""
52 # url('edit_repos_group', id=ID)
@@ -0,0 +1,43 b''
1 from rhodecode.tests import *
2
3 class TestReposGroupsController(TestController):
4
5 def test_index(self):
6 response = self.app.get(url('repos_groups'))
7 # Test response...
8
9 def test_index_as_xml(self):
10 response = self.app.get(url('formatted_repos_groups', format='xml'))
11
12 def test_create(self):
13 response = self.app.post(url('repos_groups'))
14
15 def test_new(self):
16 response = self.app.get(url('new_repos_group'))
17
18 def test_new_as_xml(self):
19 response = self.app.get(url('formatted_new_repos_group', format='xml'))
20
21 def test_update(self):
22 response = self.app.put(url('repos_group', id=1))
23
24 def test_update_browser_fakeout(self):
25 response = self.app.post(url('repos_group', id=1), params=dict(_method='put'))
26
27 def test_delete(self):
28 response = self.app.delete(url('repos_group', id=1))
29
30 def test_delete_browser_fakeout(self):
31 response = self.app.post(url('repos_group', id=1), params=dict(_method='delete'))
32
33 def test_show(self):
34 response = self.app.get(url('repos_group', id=1))
35
36 def test_show_as_xml(self):
37 response = self.app.get(url('formatted_repos_group', id=1, format='xml'))
38
39 def test_edit(self):
40 response = self.app.get(url('edit_repos_group', id=1))
41
42 def test_edit_as_xml(self):
43 response = self.app.get(url('formatted_edit_repos_group', id=1, format='xml'))
@@ -96,11 +96,13 b' def make_map(config):'
96 96 action="repo_pull", conditions=dict(method=["PUT"],
97 97 function=check_repo))
98 98
99 #ADMIN REPOS GROUP REST ROUTES
100 routes_map.resource('repos_group', 'repos_groups', controller='admin/repos_groups', path_prefix='/_admin')
99 101
100 102 #ADMIN USER REST ROUTES
101 103 routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
102 104
103 #ADMIN USER REST ROUTES
105 #ADMIN USERS REST ROUTES
104 106 routes_map.resource('users_group', 'users_groups', controller='admin/users_groups', path_prefix='/_admin')
105 107
106 108 #ADMIN GROUP REST ROUTES
@@ -35,7 +35,8 b' from vcs.exceptions import ChangesetErro'
35 35 from pylons import tmpl_context as c, request, url
36 36 from pylons.i18n.translation import _
37 37
38 from rhodecode.model.db import Statistics
38 from rhodecode.model.db import Statistics, Repository
39 from rhodecode.model.repo import RepoModel
39 40
40 41 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
41 42 from rhodecode.lib.base import BaseRepoController, render
@@ -60,19 +61,20 b' class SummaryController(BaseRepoControll'
60 61 def __before__(self):
61 62 super(SummaryController, self).__before__()
62 63
63 def index(self):
64 c.repo, dbrepo = self.scm_model.get(c.repo_name)
65 c.dbrepo = dbrepo
64 def index(self, repo_name):
65
66 e = request.environ
67 c.dbrepo = dbrepo = Repository.by_repo_name(repo_name)
66 68
67 c.following = self.scm_model.is_following_repo(c.repo_name,
68 self.rhodecode_user.user_id)
69 c.following = self.scm_model.is_following_repo(repo_name,
70 self.rhodecode_user.user_id)
69 71 def url_generator(**kw):
70 return url('shortlog_home', repo_name=c.repo_name, **kw)
72 return url('shortlog_home', repo_name=repo_name, **kw)
71 73
72 c.repo_changesets = RepoPage(c.repo, page=1, items_per_page=10,
74 c.repo_changesets = RepoPage(c.rhodecode_repo, page=1, items_per_page=10,
73 75 url=url_generator)
74 76
75 e = request.environ
77
76 78
77 79 if self.rhodecode_user.username == 'default':
78 80 #for default(anonymous) user we don't need to pass credentials
@@ -88,19 +90,19 b' class SummaryController(BaseRepoControll'
88 90 'password':password,
89 91 'host':e.get('HTTP_HOST'),
90 92 'prefix':e.get('SCRIPT_NAME'),
91 'repo_name':c.repo_name, }
93 'repo_name':repo_name, }
92 94 c.clone_repo_url = uri
93 95 c.repo_tags = OrderedDict()
94 for name, hash in c.repo.tags.items()[:10]:
96 for name, hash in c.rhodecode_repo.tags.items()[:10]:
95 97 try:
96 c.repo_tags[name] = c.repo.get_changeset(hash)
98 c.repo_tags[name] = c.rhodecode_repo.get_changeset(hash)
97 99 except ChangesetError:
98 100 c.repo_tags[name] = EmptyChangeset(hash)
99 101
100 102 c.repo_branches = OrderedDict()
101 for name, hash in c.repo.branches.items()[:10]:
103 for name, hash in c.rhodecode_repo.branches.items()[:10]:
102 104 try:
103 c.repo_branches[name] = c.repo.get_changeset(hash)
105 c.repo_branches[name] = c.rhodecode_repo.get_changeset(hash)
104 106 except ChangesetError:
105 107 c.repo_branches[name] = EmptyChangeset(hash)
106 108
@@ -114,7 +116,7 b' class SummaryController(BaseRepoControll'
114 116
115 117 if dbrepo.enable_statistics:
116 118 c.no_data_msg = _('No data loaded yet')
117 run_task(get_commits_stats, c.repo.name, ts_min_y, ts_max_y)
119 run_task(get_commits_stats, c.dbrepo.repo_name, ts_min_y, ts_max_y)
118 120 else:
119 121 c.no_data_msg = _('Statistics are disabled for this repository')
120 122 c.ts_min = ts_min_m
@@ -143,7 +145,7 b' class SummaryController(BaseRepoControll'
143 145
144 146 c.enable_downloads = dbrepo.enable_downloads
145 147 if c.enable_downloads:
146 c.download_options = self._get_download_links(c.repo)
148 c.download_options = self._get_download_links(c.rhodecode_repo)
147 149
148 150 return render('summary/summary.html')
149 151
@@ -293,7 +293,7 b' def pygmentize(filenode, **kwargs):'
293 293 return literal(code_highlight(filenode.content,
294 294 filenode.lexer, CodeHtmlFormatter(**kwargs)))
295 295
296 def pygmentize_annotation(filenode, **kwargs):
296 def pygmentize_annotation(repo_name, filenode, **kwargs):
297 297 """pygmentize function for annotation
298 298
299 299 :param filenode:
@@ -326,27 +326,30 b' def pygmentize_annotation(filenode, **kw'
326 326 col = color_dict[cs] = cgenerator.next()
327 327 return "color: rgb(%s)! important;" % (', '.join(col))
328 328
329 def url_func(changeset):
330 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \
331 " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>"
329 def url_func(repo_name):
330 def _url_func(changeset):
331 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b>" + \
332 " %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>"
332 333
333 tooltip_html = tooltip_html % (changeset.author,
334 changeset.date,
335 tooltip(changeset.message))
336 lnk_format = '%5s:%s' % ('r%s' % changeset.revision,
337 short_id(changeset.raw_id))
338 uri = link_to(
339 lnk_format,
340 url('changeset_home', repo_name=changeset.repository.name,
341 revision=changeset.raw_id),
342 style=get_color_string(changeset.raw_id),
343 class_='tooltip',
344 title=tooltip_html
345 )
334 tooltip_html = tooltip_html % (changeset.author,
335 changeset.date,
336 tooltip(changeset.message))
337 lnk_format = '%5s:%s' % ('r%s' % changeset.revision,
338 short_id(changeset.raw_id))
339 uri = link_to(
340 lnk_format,
341 url('changeset_home', repo_name=repo_name,
342 revision=changeset.raw_id),
343 style=get_color_string(changeset.raw_id),
344 class_='tooltip',
345 title=tooltip_html
346 )
346 347
347 uri += '\n'
348 return uri
349 return literal(annotate_highlight(filenode, url_func, **kwargs))
348 uri += '\n'
349 return uri
350 return _url_func
351
352 return literal(annotate_highlight(filenode, url_func(repo_name), **kwargs))
350 353
351 354 def get_changeset_safe(repo, rev):
352 355 from vcs.backends.base import BaseRepository
@@ -690,7 +693,7 b' def repo_link(groups_and_repos):'
690 693 return repo_name
691 694 else:
692 695 def make_link(group):
693 return link_to(group.group_name, url('/', group.group_id))
696 return link_to(group.group_name, url('repos_group', id=group.group_id))
694 697 return literal(' &raquo; '.join(map(make_link, groups)) + \
695 698 " &raquo; " + repo_name)
696 699
@@ -91,7 +91,7 b' class WhooshIndexingDaemon(object):'
91 91 filtered_repo_paths = {}
92 92 for repo_name, repo in self.repo_paths.items():
93 93 if repo_name in repo_list:
94 filtered_repo_paths[repo.name] = repo
94 filtered_repo_paths[repo_name] = repo
95 95
96 96 self.repo_paths = filtered_repo_paths
97 97
@@ -130,7 +130,7 b' class WhooshIndexingDaemon(object):'
130 130 def get_node_mtime(self, node):
131 131 return mktime(node.last_changeset.date.timetuple())
132 132
133 def add_doc(self, writer, path, repo):
133 def add_doc(self, writer, path, repo, repo_name):
134 134 """Adding doc to writer this function itself fetches data from
135 135 the instance of vcs backend"""
136 136 node = self.get_node(repo, path)
@@ -152,7 +152,7 b' class WhooshIndexingDaemon(object):'
152 152 u_content = u''
153 153
154 154 writer.add_document(owner=unicode(repo.contact),
155 repository=safe_unicode(repo.name),
155 repository=safe_unicode(repo_name),
156 156 path=safe_unicode(path),
157 157 content=u_content,
158 158 modtime=self.get_node_mtime(node),
@@ -170,11 +170,11 b' class WhooshIndexingDaemon(object):'
170 170 idx = create_in(self.index_location, SCHEMA, indexname=IDX_NAME)
171 171 writer = idx.writer()
172 172
173 for repo in self.repo_paths.values():
173 for repo_name, repo in self.repo_paths.items():
174 174 log.debug('building index @ %s' % repo.path)
175 175
176 176 for idx_path in self.get_paths(repo):
177 self.add_doc(writer, idx_path, repo)
177 self.add_doc(writer, idx_path, repo, repo_name)
178 178
179 179 log.debug('>> COMMITING CHANGES <<')
180 180 writer.commit(merge=True)
@@ -221,12 +221,12 b' class WhooshIndexingDaemon(object):'
221 221 # Loop over the files in the filesystem
222 222 # Assume we have a function that gathers the filenames of the
223 223 # documents to be indexed
224 for repo in self.repo_paths.values():
224 for repo_name, repo in self.repo_paths.items():
225 225 for path in self.get_paths(repo):
226 226 if path in to_index or path not in indexed_paths:
227 227 # This is either a file that's changed, or a new file
228 228 # that wasn't indexed before. So index it!
229 self.add_doc(writer, path, repo)
229 self.add_doc(writer, path, repo, repo_name)
230 230 log.debug('re indexing %s' % path)
231 231
232 232 log.debug('>> COMMITING CHANGES <<')
@@ -136,7 +136,7 b''
136 136 <img class="icon" alt="${_('public')}" src="${h.url("/images/icons/lock_open.png")}"/>
137 137 %endif
138 138
139 ${h.link_to(repo['repo'].name, h.url('summary_home',repo_name=repo['repo'].name),class_="repo_name")}
139 ${h.link_to(repo['name'], h.url('summary_home',repo_name=repo['name']),class_="repo_name")}
140 140 %if repo['dbrepo_fork']:
141 141 <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}">
142 142 <img class="icon" alt="${_('public')}"
@@ -145,10 +145,10 b''
145 145 %endif
146 146 </td>
147 147 <td><span class="tooltip" title="${repo['repo'].last_change}">${("r%s:%s") % (h.get_changeset_safe(repo['repo'],'tip').revision,h.short_id(h.get_changeset_safe(repo['repo'],'tip').raw_id))}</span></td>
148 <td><a href="${h.url('repo_settings_home',repo_name=repo['repo'].name)}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url("/images/icons/application_form_edit.png")}"/></a></td>
148 <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url("/images/icons/application_form_edit.png")}"/></a></td>
149 149 <td>
150 ${h.form(url('repo_settings_delete', repo_name=repo['repo'].name),method='delete')}
151 ${h.submit('remove_%s' % repo['repo'].name,'',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
150 ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')}
151 ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
152 152 ${h.end_form()}
153 153 </td>
154 154 </tr>
@@ -67,7 +67,7 b''
67 67 ${_('Binary file')}
68 68 %else:
69 69 % if c.file.size < c.cut_off_limit:
70 ${h.pygmentize_annotation(c.file,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")}
70 ${h.pygmentize_annotation(c.repo_name,c.file,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")}
71 71 %else:
72 72 ${_('File is to big to display')} ${h.link_to(_('show as raw'),
73 73 h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.revision,f_path=c.f_path))}
@@ -4,7 +4,7 b''
4 4 %if repo['dbrepo']['private']:
5 5 <li>
6 6 <img src="${h.url("/images/icons/lock.png")}" alt="${_('Private repository')}" class="repo_switcher_type"/>
7 ${h.link_to(repo['name'].name,h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
7 ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
8 8 </li>
9 9 %else:
10 10 <li>
@@ -7,7 +7,7 b''
7 7 <%def name="breadcrumbs_links()">
8 8 ${h.link_to(u'Home',h.url('/'))}
9 9 &raquo;
10 ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))}
10 ${h.link_to(c.dbrepo.just_name,h.url('summary_home',repo_name=c.repo_name))}
11 11 &raquo;
12 12 ${_('summary')}
13 13 </%def>
@@ -31,6 +31,17 b''
31 31 <label>${_('Name')}:</label>
32 32 </div>
33 33 <div class="input-short">
34 %if c.rhodecode_user.username != 'default':
35 %if c.following:
36 <span id="follow_toggle" class="following" title="${_('Stop following this repository')}"
37 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
38 </span>
39 %else:
40 <span id="follow_toggle" class="follow" title="${_('Start following this repository')}"
41 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
42 </span>
43 %endif
44 %endif:
34 45 %if c.dbrepo.repo_type =='hg':
35 46 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url("/images/icons/hgicon.png")}"/>
36 47 %endif
@@ -43,19 +54,8 b''
43 54 %else:
44 55 <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url("/images/icons/lock_open.png")}"/>
45 56 %endif
46 <span style="font-size: 1.6em;font-weight: bold;vertical-align: baseline;">${c.repo.name}</span>
47 %if c.rhodecode_user.username != 'default':
48 %if c.following:
49 <span id="follow_toggle" class="following" title="${_('Stop following this repository')}"
50 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
51 </span>
52 %else:
53 <span id="follow_toggle" class="follow" title="${_('Start following this repository')}"
54 onclick="javascript:toggleFollowingRepo(this,${c.dbrepo.repo_id},'${str(h.get_token())}')">
55 </span>
56 %endif
57 %endif:
58 <br/>
57 <span style="font-size: 1.6em;font-weight: bold;vertical-align: baseline;">${h.repo_link(c.dbrepo.groups_and_repo)}</span>
58
59 59 %if c.dbrepo.fork:
60 60 <span style="margin-top:5px">
61 61 <a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}">
@@ -109,8 +109,11 b''
109 109 <label>${_('Last change')}:</label>
110 110 </div>
111 111 <div class="input-short">
112 ${h.age(c.repo.last_change)} - ${c.repo.last_change}
113 ${_('by')} ${h.get_changeset_safe(c.repo,'tip').author}
112 <b>${'r%s:%s' % (h.get_changeset_safe(c.rhodecode_repo,'tip').revision,
113 h.get_changeset_safe(c.rhodecode_repo,'tip').short_id)}</b> -
114 <span class="tooltip" title="${c.rhodecode_repo.last_change}">
115 ${h.age(c.rhodecode_repo.last_change)}</span><br/>
116 ${_('by')} ${h.get_changeset_safe(c.rhodecode_repo,'tip').author}
114 117
115 118 </div>
116 119 </div>
@@ -138,7 +141,7 b''
138 141 <label>${_('Download')}:</label>
139 142 </div>
140 143 <div class="input-short">
141 %if len(c.repo.revisions) == 0:
144 %if len(c.rhodecode_repo.revisions) == 0:
142 145 ${_('There are no downloads yet')}
143 146 %elif c.enable_downloads is False:
144 147 ${_('Downloads are disabled for this repository')}
@@ -146,14 +149,14 b''
146 149 [${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
147 150 %endif
148 151 %else:
149 ${h.select('download_options',c.repo.get_changeset().raw_id,c.download_options)}
150 %for cnt,archive in enumerate(c.repo._get_archives()):
152 ${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)}
153 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
151 154 %if cnt >=1:
152 155 |
153 156 %endif
154 157 <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}"
155 158 id="${archive['type']+'_link'}">${h.link_to(archive['type'],
156 h.url('files_archive_home',repo_name=c.repo.name,
159 h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
157 160 fname='tip'+archive['extension']),class_="archive_icon")}</span>
158 161 %endfor
159 162 %endif
@@ -166,11 +169,11 b''
166 169 </div>
167 170 <div class="input-short">
168 171 %if c.rhodecode_user.username != 'default':
169 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo.name,api_key=c.rhodecode_user.api_key),class_='rss_icon')}
170 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo.name,api_key=c.rhodecode_user.api_key),class_='atom_icon')}
172 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='rss_icon')}
173 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='atom_icon')}
171 174 %else:
172 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo.name),class_='rss_icon')}
173 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo.name),class_='atom_icon')}
175 ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name),class_='rss_icon')}
176 ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name),class_='atom_icon')}
174 177 %endif
175 178 </div>
176 179 </div>
@@ -265,9 +268,9 b''
265 268 YUE.on('download_options','change',function(e){
266 269 var new_cs = e.target.options[e.target.selectedIndex];
267 270 var tmpl_links = {}
268 %for cnt,archive in enumerate(c.repo._get_archives()):
271 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
269 272 tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'],
270 h.url('files_archive_home',repo_name=c.repo.name,
273 h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
271 274 fname='__CS__'+archive['extension']),class_="archive_icon")}';
272 275 %endfor
273 276
General Comments 0
You need to be logged in to leave comments. Login now