Mercurial > kallithea
annotate rhodecode/controllers/admin/repos_groups.py @ 1193:523382549c45 beta
Added repo group page showing what reposiories are inside a group
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 01 Apr 2011 18:46:24 +0200 |
parents | 2ab211e0aecd |
children | 5f2fbab7c429 |
rev | line source |
---|---|
1171 | 1 import logging |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
2 from operator import itemgetter |
1171 | 3 |
4 from pylons import request, response, session, tmpl_context as c, url | |
5 from pylons.controllers.util import abort, redirect | |
6 | |
7 from rhodecode.lib.base import BaseController, render | |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
8 from rhodecode.model.db import Group |
1171 | 9 |
10 log = logging.getLogger(__name__) | |
11 | |
12 class ReposGroupsController(BaseController): | |
13 """REST Controller styled on the Atom Publishing Protocol""" | |
14 # To properly map this controller, ensure your config/routing.py | |
15 # file has a resource setup: | |
16 # map.resource('repos_group', 'repos_groups') | |
17 | |
18 def index(self, format='html'): | |
19 """GET /repos_groups: All items in the collection""" | |
20 # url('repos_groups') | |
21 | |
22 def create(self): | |
23 """POST /repos_groups: Create a new item""" | |
24 # url('repos_groups') | |
25 | |
26 def new(self, format='html'): | |
27 """GET /repos_groups/new: Form to create a new item""" | |
28 # url('new_repos_group') | |
29 | |
30 def update(self, id): | |
31 """PUT /repos_groups/id: Update an existing item""" | |
32 # Forms posted to this method should contain a hidden field: | |
33 # <input type="hidden" name="_method" value="PUT" /> | |
34 # Or using helpers: | |
35 # h.form(url('repos_group', id=ID), | |
36 # method='put') | |
37 # url('repos_group', id=ID) | |
38 | |
39 def delete(self, id): | |
40 """DELETE /repos_groups/id: Delete an existing item""" | |
41 # Forms posted to this method should contain a hidden field: | |
42 # <input type="hidden" name="_method" value="DELETE" /> | |
43 # Or using helpers: | |
44 # h.form(url('repos_group', id=ID), | |
45 # method='delete') | |
46 # url('repos_group', id=ID) | |
47 | |
48 def show(self, id, format='html'): | |
49 """GET /repos_groups/id: Show a specific item""" | |
50 # url('repos_group', id=ID) | |
51 | |
1193
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
52 c.group = Group.get(id) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
53 if c.group: |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
54 c.group_repos = c.group.repositories |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
55 else: |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
56 return redirect(url('repos_group')) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
57 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
58 sortables = ['name', 'description', 'last_change', 'tip', 'owner'] |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
59 current_sort = request.GET.get('sort', 'name') |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
60 current_sort_slug = current_sort.replace('-', '') |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
61 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
62 if current_sort_slug not in sortables: |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
63 c.sort_by = 'name' |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
64 current_sort_slug = c.sort_by |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
65 else: |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
66 c.sort_by = current_sort |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
67 c.sort_slug = current_sort_slug |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
68 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
69 sort_key = current_sort_slug + '_sort' |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
70 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
71 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
72 #overwrite our cached list with current filter |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
73 gr_filter = [r.repo_name for r in c.group_repos] |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
74 c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
75 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
76 if c.sort_by.startswith('-'): |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
77 c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
78 reverse=True) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
79 else: |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
80 c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key), |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
81 reverse=False) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
82 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
83 c.repo_cnt = len(c.repos_list) |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
84 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
85 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
86 return render('admin/repos_groups/repos_groups.html') |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
87 |
523382549c45
Added repo group page showing what reposiories are inside a group
Marcin Kuzminski <marcin@python-works.com>
parents:
1171
diff
changeset
|
88 |
1171 | 89 def edit(self, id, format='html'): |
90 """GET /repos_groups/id/edit: Form to edit an existing item""" | |
91 # url('edit_repos_group', id=ID) |