Show More
@@ -1,238 +1,223 | |||||
1 | import logging |
|
1 | import logging | |
2 | import traceback |
|
2 | import traceback | |
3 | import formencode |
|
3 | import formencode | |
4 |
|
4 | |||
5 | from formencode import htmlfill |
|
5 | from formencode import htmlfill | |
6 | from operator import itemgetter |
|
6 | from operator import itemgetter | |
7 |
|
7 | |||
8 | from pylons import request, response, session, tmpl_context as c, url |
|
8 | from pylons import request, response, session, tmpl_context as c, url | |
9 | from pylons.controllers.util import abort, redirect |
|
9 | from pylons.controllers.util import abort, redirect | |
10 | from pylons.i18n.translation import _ |
|
10 | from pylons.i18n.translation import _ | |
11 |
|
11 | |||
12 | from rhodecode.lib import helpers as h |
|
12 | from rhodecode.lib import helpers as h | |
13 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
|
13 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ | |
14 | HasPermissionAnyDecorator |
|
14 | HasPermissionAnyDecorator | |
15 | from rhodecode.lib.base import BaseController, render |
|
15 | from rhodecode.lib.base import BaseController, render | |
16 | from rhodecode.model.db import Group |
|
16 | from rhodecode.model.db import Group | |
17 | from rhodecode.model.repos_group import ReposGroupModel |
|
17 | from rhodecode.model.repos_group import ReposGroupModel | |
18 | from rhodecode.model.forms import ReposGroupForm |
|
18 | from rhodecode.model.forms import ReposGroupForm | |
19 |
|
19 | |||
20 | log = logging.getLogger(__name__) |
|
20 | log = logging.getLogger(__name__) | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | class ReposGroupsController(BaseController): |
|
23 | class ReposGroupsController(BaseController): | |
24 | """REST Controller styled on the Atom Publishing Protocol""" |
|
24 | """REST Controller styled on the Atom Publishing Protocol""" | |
25 | # To properly map this controller, ensure your config/routing.py |
|
25 | # To properly map this controller, ensure your config/routing.py | |
26 | # file has a resource setup: |
|
26 | # file has a resource setup: | |
27 | # map.resource('repos_group', 'repos_groups') |
|
27 | # map.resource('repos_group', 'repos_groups') | |
28 |
|
28 | |||
29 | @LoginRequired() |
|
29 | @LoginRequired() | |
30 | def __before__(self): |
|
30 | def __before__(self): | |
31 | super(ReposGroupsController, self).__before__() |
|
31 | super(ReposGroupsController, self).__before__() | |
32 |
|
32 | |||
33 | def __load_defaults(self): |
|
33 | def __load_defaults(self): | |
34 |
|
34 | |||
35 | c.repo_groups = [('', '')] |
|
35 | c.repo_groups = [('', '')] | |
36 | parents_link = lambda k: h.literal('»'.join( |
|
36 | parents_link = lambda k: h.literal('»'.join( | |
37 | map(lambda k: k.group_name, |
|
37 | map(lambda k: k.group_name, | |
38 | k.parents + [k]) |
|
38 | k.parents + [k]) | |
39 | ) |
|
39 | ) | |
40 | ) |
|
40 | ) | |
41 |
|
41 | |||
42 | c.repo_groups.extend([(x.group_id, parents_link(x)) for \ |
|
42 | c.repo_groups.extend([(x.group_id, parents_link(x)) for \ | |
43 | x in self.sa.query(Group).all()]) |
|
43 | x in self.sa.query(Group).all()]) | |
44 |
|
44 | |||
45 | c.repo_groups = sorted(c.repo_groups, |
|
45 | c.repo_groups = sorted(c.repo_groups, | |
46 | key=lambda t: t[1].split('»')[0]) |
|
46 | key=lambda t: t[1].split('»')[0]) | |
47 | c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
|
47 | c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) | |
48 |
|
48 | |||
49 | def __load_data(self, group_id): |
|
49 | def __load_data(self, group_id): | |
50 | """ |
|
50 | """ | |
51 | Load defaults settings for edit, and update |
|
51 | Load defaults settings for edit, and update | |
52 |
|
52 | |||
53 | :param group_id: |
|
53 | :param group_id: | |
54 | """ |
|
54 | """ | |
55 | self.__load_defaults() |
|
55 | self.__load_defaults() | |
56 |
|
56 | |||
57 | repo_group = Group.get(group_id) |
|
57 | repo_group = Group.get(group_id) | |
58 |
|
58 | |||
59 | data = repo_group.get_dict() |
|
59 | data = repo_group.get_dict() | |
60 |
|
60 | |||
61 | return data |
|
61 | return data | |
62 |
|
62 | |||
63 | @HasPermissionAnyDecorator('hg.admin') |
|
63 | @HasPermissionAnyDecorator('hg.admin') | |
64 | def index(self, format='html'): |
|
64 | def index(self, format='html'): | |
65 | """GET /repos_groups: All items in the collection""" |
|
65 | """GET /repos_groups: All items in the collection""" | |
66 | # url('repos_groups') |
|
66 | # url('repos_groups') | |
67 |
|
67 | |||
68 | sk = lambda g:g.parents[0].group_name if g.parents else g.group_name |
|
68 | sk = lambda g:g.parents[0].group_name if g.parents else g.group_name | |
69 | c.groups = sorted(Group.query().all(), key=sk) |
|
69 | c.groups = sorted(Group.query().all(), key=sk) | |
70 | return render('admin/repos_groups/repos_groups_show.html') |
|
70 | return render('admin/repos_groups/repos_groups_show.html') | |
71 |
|
71 | |||
72 | @HasPermissionAnyDecorator('hg.admin') |
|
72 | @HasPermissionAnyDecorator('hg.admin') | |
73 | def create(self): |
|
73 | def create(self): | |
74 | """POST /repos_groups: Create a new item""" |
|
74 | """POST /repos_groups: Create a new item""" | |
75 | # url('repos_groups') |
|
75 | # url('repos_groups') | |
76 | self.__load_defaults() |
|
76 | self.__load_defaults() | |
77 | repos_group_model = ReposGroupModel() |
|
77 | repos_group_model = ReposGroupModel() | |
78 | repos_group_form = ReposGroupForm(available_groups= |
|
78 | repos_group_form = ReposGroupForm(available_groups= | |
79 | c.repo_groups_choices)() |
|
79 | c.repo_groups_choices)() | |
80 | try: |
|
80 | try: | |
81 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
81 | form_result = repos_group_form.to_python(dict(request.POST)) | |
82 | repos_group_model.create(form_result) |
|
82 | repos_group_model.create(form_result) | |
83 | h.flash(_('created repos group %s') \ |
|
83 | h.flash(_('created repos group %s') \ | |
84 | % form_result['group_name'], category='success') |
|
84 | % form_result['group_name'], category='success') | |
85 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
85 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
86 | except formencode.Invalid, errors: |
|
86 | except formencode.Invalid, errors: | |
87 |
|
87 | |||
88 | return htmlfill.render( |
|
88 | return htmlfill.render( | |
89 | render('admin/repos_groups/repos_groups_add.html'), |
|
89 | render('admin/repos_groups/repos_groups_add.html'), | |
90 | defaults=errors.value, |
|
90 | defaults=errors.value, | |
91 | errors=errors.error_dict or {}, |
|
91 | errors=errors.error_dict or {}, | |
92 | prefix_error=False, |
|
92 | prefix_error=False, | |
93 | encoding="UTF-8") |
|
93 | encoding="UTF-8") | |
94 | except Exception: |
|
94 | except Exception: | |
95 | log.error(traceback.format_exc()) |
|
95 | log.error(traceback.format_exc()) | |
96 | h.flash(_('error occurred during creation of repos group %s') \ |
|
96 | h.flash(_('error occurred during creation of repos group %s') \ | |
97 | % request.POST.get('group_name'), category='error') |
|
97 | % request.POST.get('group_name'), category='error') | |
98 |
|
98 | |||
99 | return redirect(url('repos_groups')) |
|
99 | return redirect(url('repos_groups')) | |
100 |
|
100 | |||
101 |
|
101 | |||
102 | @HasPermissionAnyDecorator('hg.admin') |
|
102 | @HasPermissionAnyDecorator('hg.admin') | |
103 | def new(self, format='html'): |
|
103 | def new(self, format='html'): | |
104 | """GET /repos_groups/new: Form to create a new item""" |
|
104 | """GET /repos_groups/new: Form to create a new item""" | |
105 | # url('new_repos_group') |
|
105 | # url('new_repos_group') | |
106 | self.__load_defaults() |
|
106 | self.__load_defaults() | |
107 | return render('admin/repos_groups/repos_groups_add.html') |
|
107 | return render('admin/repos_groups/repos_groups_add.html') | |
108 |
|
108 | |||
109 | @HasPermissionAnyDecorator('hg.admin') |
|
109 | @HasPermissionAnyDecorator('hg.admin') | |
110 | def update(self, id): |
|
110 | def update(self, id): | |
111 | """PUT /repos_groups/id: Update an existing item""" |
|
111 | """PUT /repos_groups/id: Update an existing item""" | |
112 | # Forms posted to this method should contain a hidden field: |
|
112 | # Forms posted to this method should contain a hidden field: | |
113 | # <input type="hidden" name="_method" value="PUT" /> |
|
113 | # <input type="hidden" name="_method" value="PUT" /> | |
114 | # Or using helpers: |
|
114 | # Or using helpers: | |
115 | # h.form(url('repos_group', id=ID), |
|
115 | # h.form(url('repos_group', id=ID), | |
116 | # method='put') |
|
116 | # method='put') | |
117 | # url('repos_group', id=ID) |
|
117 | # url('repos_group', id=ID) | |
118 |
|
118 | |||
119 | self.__load_defaults() |
|
119 | self.__load_defaults() | |
120 | c.repos_group = Group.get(id) |
|
120 | c.repos_group = Group.get(id) | |
121 |
|
121 | |||
122 | repos_group_model = ReposGroupModel() |
|
122 | repos_group_model = ReposGroupModel() | |
123 | repos_group_form = ReposGroupForm(edit=True, |
|
123 | repos_group_form = ReposGroupForm(edit=True, | |
124 | old_data=c.repos_group.get_dict(), |
|
124 | old_data=c.repos_group.get_dict(), | |
125 | available_groups= |
|
125 | available_groups= | |
126 | c.repo_groups_choices)() |
|
126 | c.repo_groups_choices)() | |
127 | try: |
|
127 | try: | |
128 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
128 | form_result = repos_group_form.to_python(dict(request.POST)) | |
129 | repos_group_model.update(id, form_result) |
|
129 | repos_group_model.update(id, form_result) | |
130 | h.flash(_('updated repos group %s') \ |
|
130 | h.flash(_('updated repos group %s') \ | |
131 | % form_result['group_name'], category='success') |
|
131 | % form_result['group_name'], category='success') | |
132 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
132 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
133 | except formencode.Invalid, errors: |
|
133 | except formencode.Invalid, errors: | |
134 |
|
134 | |||
135 | return htmlfill.render( |
|
135 | return htmlfill.render( | |
136 | render('admin/repos_groups/repos_groups_edit.html'), |
|
136 | render('admin/repos_groups/repos_groups_edit.html'), | |
137 | defaults=errors.value, |
|
137 | defaults=errors.value, | |
138 | errors=errors.error_dict or {}, |
|
138 | errors=errors.error_dict or {}, | |
139 | prefix_error=False, |
|
139 | prefix_error=False, | |
140 | encoding="UTF-8") |
|
140 | encoding="UTF-8") | |
141 | except Exception: |
|
141 | except Exception: | |
142 | log.error(traceback.format_exc()) |
|
142 | log.error(traceback.format_exc()) | |
143 | h.flash(_('error occurred during update of repos group %s') \ |
|
143 | h.flash(_('error occurred during update of repos group %s') \ | |
144 | % request.POST.get('group_name'), category='error') |
|
144 | % request.POST.get('group_name'), category='error') | |
145 |
|
145 | |||
146 | return redirect(url('repos_groups')) |
|
146 | return redirect(url('repos_groups')) | |
147 |
|
147 | |||
148 |
|
148 | |||
149 | @HasPermissionAnyDecorator('hg.admin') |
|
149 | @HasPermissionAnyDecorator('hg.admin') | |
150 | def delete(self, id): |
|
150 | def delete(self, id): | |
151 | """DELETE /repos_groups/id: Delete an existing item""" |
|
151 | """DELETE /repos_groups/id: Delete an existing item""" | |
152 | # Forms posted to this method should contain a hidden field: |
|
152 | # Forms posted to this method should contain a hidden field: | |
153 | # <input type="hidden" name="_method" value="DELETE" /> |
|
153 | # <input type="hidden" name="_method" value="DELETE" /> | |
154 | # Or using helpers: |
|
154 | # Or using helpers: | |
155 | # h.form(url('repos_group', id=ID), |
|
155 | # h.form(url('repos_group', id=ID), | |
156 | # method='delete') |
|
156 | # method='delete') | |
157 | # url('repos_group', id=ID) |
|
157 | # url('repos_group', id=ID) | |
158 |
|
158 | |||
159 | repos_group_model = ReposGroupModel() |
|
159 | repos_group_model = ReposGroupModel() | |
160 | gr = Group.get(id) |
|
160 | gr = Group.get(id) | |
161 | repos = gr.repositories.all() |
|
161 | repos = gr.repositories.all() | |
162 | if repos: |
|
162 | if repos: | |
163 | h.flash(_('This group contains %s repositores and cannot be ' |
|
163 | h.flash(_('This group contains %s repositores and cannot be ' | |
164 | 'deleted' % len(repos)), |
|
164 | 'deleted' % len(repos)), | |
165 | category='error') |
|
165 | category='error') | |
166 | return redirect(url('repos_groups')) |
|
166 | return redirect(url('repos_groups')) | |
167 |
|
167 | |||
168 |
|
||||
169 | try: |
|
168 | try: | |
170 | repos_group_model.delete(id) |
|
169 | repos_group_model.delete(id) | |
171 | h.flash(_('removed repos group %s' % gr.group_name), category='success') |
|
170 | h.flash(_('removed repos group %s' % gr.group_name), category='success') | |
172 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
171 | #TODO: in future action_logger(, '', '', '', self.sa) | |
173 | except Exception: |
|
172 | except Exception: | |
174 | log.error(traceback.format_exc()) |
|
173 | log.error(traceback.format_exc()) | |
175 | h.flash(_('error occurred during deletion of repos group %s' % gr.group_name), |
|
174 | h.flash(_('error occurred during deletion of repos group %s' % gr.group_name), | |
176 | category='error') |
|
175 | category='error') | |
177 |
|
176 | |||
178 | return redirect(url('repos_groups')) |
|
177 | return redirect(url('repos_groups')) | |
179 |
|
178 | |||
180 | def show(self, id, format='html'): |
|
179 | def show(self, id, format='html'): | |
181 | """GET /repos_groups/id: Show a specific item""" |
|
180 | """GET /repos_groups/id: Show a specific item""" | |
182 | # url('repos_group', id=ID) |
|
181 | # url('repos_group', id=ID) | |
183 |
|
182 | |||
184 |
|
|
183 | c.group = Group.get(id) | |
185 |
|
184 | |||
186 | if c.group: |
|
185 | if c.group: | |
187 | c.group_repos = c.group.repositories.all() |
|
186 | c.group_repos = c.group.repositories.all() | |
188 | else: |
|
187 | else: | |
189 | return redirect(url('home')) |
|
188 | return redirect(url('home')) | |
190 |
|
189 | |||
191 |
|
||||
192 | sortables = ['name', 'description', 'last_change', 'tip', 'owner'] |
|
|||
193 | current_sort = request.GET.get('sort', 'name') |
|
|||
194 | current_sort_slug = current_sort.replace('-', '') |
|
|||
195 |
|
||||
196 | if current_sort_slug not in sortables: |
|
|||
197 | c.sort_by = 'name' |
|
|||
198 | current_sort_slug = c.sort_by |
|
|||
199 | else: |
|
|||
200 | c.sort_by = current_sort |
|
|||
201 | c.sort_slug = current_sort_slug |
|
|||
202 |
|
||||
203 | sort_key = current_sort_slug + '_sort' |
|
|||
204 |
|
||||
205 | #overwrite our cached list with current filter |
|
190 | #overwrite our cached list with current filter | |
206 | gr_filter = c.group_repos |
|
191 | gr_filter = c.group_repos | |
207 | c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) |
|
192 | c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) | |
208 |
|
193 | |||
209 | c.repos_list = c.cached_repo_list |
|
194 | c.repos_list = c.cached_repo_list | |
210 |
|
195 | |||
211 | c.repo_cnt = 0 |
|
196 | c.repo_cnt = 0 | |
212 |
|
197 | |||
213 | c.groups = self.sa.query(Group).order_by(Group.group_name)\ |
|
198 | c.groups = self.sa.query(Group).order_by(Group.group_name)\ | |
214 | .filter(Group.group_parent_id == id).all() |
|
199 | .filter(Group.group_parent_id == id).all() | |
215 |
|
200 | |||
216 | return render('admin/repos_groups/repos_groups.html') |
|
201 | return render('admin/repos_groups/repos_groups.html') | |
217 |
|
202 | |||
218 | @HasPermissionAnyDecorator('hg.admin') |
|
203 | @HasPermissionAnyDecorator('hg.admin') | |
219 | def edit(self, id, format='html'): |
|
204 | def edit(self, id, format='html'): | |
220 | """GET /repos_groups/id/edit: Form to edit an existing item""" |
|
205 | """GET /repos_groups/id/edit: Form to edit an existing item""" | |
221 | # url('edit_repos_group', id=ID) |
|
206 | # url('edit_repos_group', id=ID) | |
222 |
|
207 | |||
223 | id = int(id) |
|
208 | id_ = int(id) | |
224 |
|
209 | |||
225 | c.repos_group = Group.get(id) |
|
210 | c.repos_group = Group.get(id_) | |
226 | defaults = self.__load_data(id) |
|
211 | defaults = self.__load_data(id_) | |
227 |
|
212 | |||
228 | # we need to exclude this group from the group list for editing |
|
213 | # we need to exclude this group from the group list for editing | |
229 | c.repo_groups = filter(lambda x:x[0] != id, c.repo_groups) |
|
214 | c.repo_groups = filter(lambda x:x[0] != id_, c.repo_groups) | |
230 |
|
215 | |||
231 | return htmlfill.render( |
|
216 | return htmlfill.render( | |
232 | render('admin/repos_groups/repos_groups_edit.html'), |
|
217 | render('admin/repos_groups/repos_groups_edit.html'), | |
233 | defaults=defaults, |
|
218 | defaults=defaults, | |
234 | encoding="UTF-8", |
|
219 | encoding="UTF-8", | |
235 | force_defaults=False |
|
220 | force_defaults=False | |
236 | ) |
|
221 | ) | |
237 |
|
222 | |||
238 |
|
223 |
@@ -1,72 +1,60 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.home |
|
3 | rhodecode.controllers.home | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | Home controller for Rhodecode |
|
6 | Home controller for Rhodecode | |
7 |
|
7 | |||
8 | :created_on: Feb 18, 2010 |
|
8 | :created_on: Feb 18, 2010 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software: you can redistribute it and/or modify |
|
13 | # This program is free software: you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by |
|
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation, either version 3 of the License, or |
|
15 | # the Free Software Foundation, either version 3 of the License, or | |
16 | # (at your option) any later version. |
|
16 | # (at your option) any later version. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 |
|
25 | |||
26 | import logging |
|
26 | import logging | |
27 | from operator import itemgetter |
|
27 | from operator import itemgetter | |
28 |
|
28 | |||
29 | from pylons import tmpl_context as c, request |
|
29 | from pylons import tmpl_context as c, request | |
30 | from paste.httpexceptions import HTTPBadRequest |
|
30 | from paste.httpexceptions import HTTPBadRequest | |
31 |
|
31 | |||
32 | from rhodecode.lib.auth import LoginRequired |
|
32 | from rhodecode.lib.auth import LoginRequired | |
33 | from rhodecode.lib.base import BaseController, render |
|
33 | from rhodecode.lib.base import BaseController, render | |
34 | from rhodecode.model.db import Group, Repository |
|
34 | from rhodecode.model.db import Group, Repository | |
35 |
|
35 | |||
36 | log = logging.getLogger(__name__) |
|
36 | log = logging.getLogger(__name__) | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | class HomeController(BaseController): |
|
39 | class HomeController(BaseController): | |
40 |
|
40 | |||
41 | @LoginRequired() |
|
41 | @LoginRequired() | |
42 | def __before__(self): |
|
42 | def __before__(self): | |
43 | super(HomeController, self).__before__() |
|
43 | super(HomeController, self).__before__() | |
44 |
|
44 | |||
45 | def index(self): |
|
45 | def index(self): | |
46 | sortables = ['name', 'description', 'last_change', 'tip', 'owner'] |
|
|||
47 | current_sort = request.GET.get('sort', 'name') |
|
|||
48 | current_sort_slug = current_sort.replace('-', '') |
|
|||
49 |
|
46 | |||
50 | if current_sort_slug not in sortables: |
|
47 | c.repos_list = self.scm_model.get_repos() | |
51 | c.sort_by = 'name' |
|
|||
52 | current_sort_slug = c.sort_by |
|
|||
53 | else: |
|
|||
54 | c.sort_by = current_sort |
|
|||
55 | c.sort_slug = current_sort_slug |
|
|||
56 |
|
||||
57 | sort_key = current_sort_slug + '_sort' |
|
|||
58 |
|
||||
59 | c.repos_list = self.scm_model.get_repos(sort_key=sort_key) |
|
|||
60 |
|
48 | |||
61 | c.groups = Group.query().filter(Group.group_parent_id == None).all() |
|
49 | c.groups = Group.query().filter(Group.group_parent_id == None).all() | |
62 |
|
50 | |||
63 | return render('/index.html') |
|
51 | return render('/index.html') | |
64 |
|
52 | |||
65 | def repo_switcher(self): |
|
53 | def repo_switcher(self): | |
66 | if request.is_xhr: |
|
54 | if request.is_xhr: | |
67 | all_repos = Repository.query().order_by(Repository.repo_name).all() |
|
55 | all_repos = Repository.query().order_by(Repository.repo_name).all() | |
68 | c.repos_list = self.scm_model.get_repos(all_repos, |
|
56 | c.repos_list = self.scm_model.get_repos(all_repos, | |
69 | sort_key='name_sort') |
|
57 | sort_key='name_sort') | |
70 | return render('/repo_switcher_list.html') |
|
58 | return render('/repo_switcher_list.html') | |
71 | else: |
|
59 | else: | |
72 | return HTTPBadRequest() |
|
60 | return HTTPBadRequest() |
@@ -1,244 +1,226 | |||||
1 | <%page args="parent" /> |
|
1 | <%page args="parent" /> | |
2 | <%def name="get_sort(name)"> |
|
|||
3 | <%name_slug = name.lower().replace(' ','_') %> |
|
|||
4 |
|
||||
5 | %if name_slug == c.sort_slug: |
|
|||
6 | %if c.sort_by.startswith('-'): |
|
|||
7 | <a href="?sort=${name_slug}">${name}↑</a> |
|
|||
8 | %else: |
|
|||
9 | <a href="?sort=-${name_slug}">${name}↓</a> |
|
|||
10 | %endif: |
|
|||
11 | %else: |
|
|||
12 | <a href="?sort=${name_slug}">${name}</a> |
|
|||
13 | %endif |
|
|||
14 | </%def> |
|
|||
15 |
|
||||
16 | <div class="box"> |
|
2 | <div class="box"> | |
17 | <!-- box / title --> |
|
3 | <!-- box / title --> | |
18 | <div class="title"> |
|
4 | <div class="title"> | |
19 | <h5> |
|
5 | <h5> | |
20 | <input class="top-right-rounded-corner top-left-rounded-corner bottom-left-rounded-corner bottom-right-rounded-corner" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> |
|
6 | <input class="top-right-rounded-corner top-left-rounded-corner bottom-left-rounded-corner bottom-right-rounded-corner" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> | |
21 | ${parent.breadcrumbs()} <span id="repo_count"></span> ${_('repositories')} |
|
7 | ${parent.breadcrumbs()} <span id="repo_count"></span> ${_('repositories')} | |
22 | </h5> |
|
8 | </h5> | |
23 | %if c.rhodecode_user.username != 'default': |
|
9 | %if c.rhodecode_user.username != 'default': | |
24 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): |
|
10 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): | |
25 | <ul class="links"> |
|
11 | <ul class="links"> | |
26 | <li> |
|
12 | <li> | |
27 | <span>${h.link_to(_('ADD NEW REPOSITORY'),h.url('admin_settings_create_repository'))}</span> |
|
13 | <span>${h.link_to(_('ADD NEW REPOSITORY'),h.url('admin_settings_create_repository'))}</span> | |
28 | </li> |
|
14 | </li> | |
29 | </ul> |
|
15 | </ul> | |
30 | %endif |
|
16 | %endif | |
31 | %endif |
|
17 | %endif | |
32 | </div> |
|
18 | </div> | |
33 | <!-- end box / title --> |
|
19 | <!-- end box / title --> | |
34 | <div class="table"> |
|
20 | <div class="table"> | |
35 | % if c.groups: |
|
21 | % if c.groups: | |
36 | <table> |
|
22 | <table> | |
37 | <thead> |
|
23 | <thead> | |
38 | <tr> |
|
24 | <tr> | |
39 | <th class="left"><a href="#">${_('Group name')}</a></th> |
|
25 | <th class="left"><a href="#">${_('Group name')}</a></th> | |
40 | <th class="left"><a href="#">${_('Description')}</a></th> |
|
26 | <th class="left"><a href="#">${_('Description')}</a></th> | |
41 | ##<th class="left"><a href="#">${_('Number of repositories')}</a></th> |
|
27 | ##<th class="left"><a href="#">${_('Number of repositories')}</a></th> | |
42 | </tr> |
|
28 | </tr> | |
43 | </thead> |
|
29 | </thead> | |
44 |
|
30 | |||
45 | ## REPO GROUPS |
|
31 | ## REPO GROUPS | |
46 |
|
32 | |||
47 | % for gr in c.groups: |
|
33 | % for gr in c.groups: | |
48 | <tr> |
|
34 | <tr> | |
49 | <td> |
|
35 | <td> | |
50 | <div style="white-space: nowrap"> |
|
36 | <div style="white-space: nowrap"> | |
51 | <img class="icon" alt="${_('Repositories group')}" src="${h.url('/images/icons/database_link.png')}"/> |
|
37 | <img class="icon" alt="${_('Repositories group')}" src="${h.url('/images/icons/database_link.png')}"/> | |
52 | ${h.link_to(gr.group_name,url('repos_group',id=gr.group_id))} |
|
38 | ${h.link_to(gr.group_name,url('repos_group',id=gr.group_id))} | |
53 | </div> |
|
39 | </div> | |
54 | </td> |
|
40 | </td> | |
55 | <td>${gr.group_description}</td> |
|
41 | <td>${gr.group_description}</td> | |
56 | ##<td><b>${gr.repositories.count()}</b></td> |
|
42 | ##<td><b>${gr.repositories.count()}</b></td> | |
57 | </tr> |
|
43 | </tr> | |
58 | % endfor |
|
44 | % endfor | |
59 |
|
45 | |||
60 | </table> |
|
46 | </table> | |
61 | <div style="height: 20px"></div> |
|
47 | <div style="height: 20px"></div> | |
62 | % endif |
|
48 | % endif | |
63 | <div id="welcome" style="display:none;text-align:center"> |
|
49 | <div id="welcome" style="display:none;text-align:center"> | |
64 | <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1> |
|
50 | <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1> | |
65 | </div> |
|
51 | </div> | |
66 | <table id="repos_list"> |
|
52 | <table id="repos_list"> | |
67 | <thead> |
|
53 | <thead> | |
68 | <tr> |
|
54 | <tr> | |
69 | <th class="left"></th> |
|
55 | <th class="left"></th> | |
70 |
<th class="left">${ |
|
56 | <th class="left">${_('Name')}</th> | |
71 |
<th class="left">${ |
|
57 | <th class="left">${_('Description')}</th> | |
72 |
<th class="left">${ |
|
58 | <th class="left">${_('Last change')}</th> | |
73 |
<th class="left">${ |
|
59 | <th class="left">${_('Tip')}</th> | |
74 |
<th class="left">${ |
|
60 | <th class="left">${_('Owner')}</th> | |
75 | <th class="left">${_('RSS')}</th> |
|
61 | <th class="left">${_('RSS')}</th> | |
76 | <th class="left">${_('Atom')}</th> |
|
62 | <th class="left">${_('Atom')}</th> | |
77 | </tr> |
|
63 | </tr> | |
78 | </thead> |
|
64 | </thead> | |
79 | <tbody> |
|
65 | <tbody> | |
80 | %for cnt,repo in enumerate(c.repos_list): |
|
66 | %for cnt,repo in enumerate(c.repos_list): | |
81 | <tr class="parity${cnt%2}"> |
|
67 | <tr class="parity${cnt%2}"> | |
82 | <td class="quick_repo_menu"> |
|
68 | <td class="quick_repo_menu"> | |
83 | <ul class="menu_items hidden"> |
|
69 | <ul class="menu_items hidden"> | |
84 | <li> |
|
70 | <li> | |
85 | <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=repo['name'])}"> |
|
71 | <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=repo['name'])}"> | |
86 | <span class="icon"> |
|
72 | <span class="icon"> | |
87 | <img src="${h.url('/images/icons/clipboard_16.png')}" alt="${_('Summary')}" /> |
|
73 | <img src="${h.url('/images/icons/clipboard_16.png')}" alt="${_('Summary')}" /> | |
88 | </span> |
|
74 | </span> | |
89 | <span>${_('Summary')}</span> |
|
75 | <span>${_('Summary')}</span> | |
90 | </a> |
|
76 | </a> | |
91 | </li> |
|
77 | </li> | |
92 | <li> |
|
78 | <li> | |
93 | <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=repo['name'])}"> |
|
79 | <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=repo['name'])}"> | |
94 | <span class="icon"> |
|
80 | <span class="icon"> | |
95 | <img src="${h.url('/images/icons/time.png')}" alt="${_('Changelog')}" /> |
|
81 | <img src="${h.url('/images/icons/time.png')}" alt="${_('Changelog')}" /> | |
96 | </span> |
|
82 | </span> | |
97 | <span>${_('Changelog')}</span> |
|
83 | <span>${_('Changelog')}</span> | |
98 | </a> |
|
84 | </a> | |
99 | </li> |
|
85 | </li> | |
100 | <li> |
|
86 | <li> | |
101 | <a title="${_('Files')}" href="${h.url('files_home',repo_name=repo['name'])}"> |
|
87 | <a title="${_('Files')}" href="${h.url('files_home',repo_name=repo['name'])}"> | |
102 | <span class="icon"> |
|
88 | <span class="icon"> | |
103 | <img src="${h.url('/images/icons/file.png')}" alt="${_('Files')}" /> |
|
89 | <img src="${h.url('/images/icons/file.png')}" alt="${_('Files')}" /> | |
104 | </span> |
|
90 | </span> | |
105 | <span>${_('Files')}</span> |
|
91 | <span>${_('Files')}</span> | |
106 | </a> |
|
92 | </a> | |
107 | </li> |
|
93 | </li> | |
108 | </ul> |
|
94 | </ul> | |
109 | </td> |
|
95 | </td> | |
110 | <td> |
|
96 | <td> | |
111 | ## TYPE OF REPO |
|
97 | ## TYPE OF REPO | |
112 | <div style="white-space: nowrap"> |
|
98 | <div style="white-space: nowrap"> | |
113 | %if repo['dbrepo']['repo_type'] =='hg': |
|
99 | %if repo['dbrepo']['repo_type'] =='hg': | |
114 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> |
|
100 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> | |
115 | %elif repo['dbrepo']['repo_type'] =='git': |
|
101 | %elif repo['dbrepo']['repo_type'] =='git': | |
116 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> |
|
102 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> | |
117 | %endif |
|
103 | %endif | |
118 |
|
104 | |||
119 | ##PRIVATE/PUBLIC |
|
105 | ##PRIVATE/PUBLIC | |
120 | %if repo['dbrepo']['private']: |
|
106 | %if repo['dbrepo']['private']: | |
121 | <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/> |
|
107 | <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/> | |
122 | %else: |
|
108 | %else: | |
123 | <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/> |
|
109 | <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/> | |
124 | %endif |
|
110 | %endif | |
125 |
|
111 | |||
126 | ##NAME |
|
112 | ##NAME | |
127 | ${h.link_to(repo['name'], |
|
113 | ${h.link_to(repo['name'], | |
128 | h.url('summary_home',repo_name=repo['name']),class_="repo_name")} |
|
114 | h.url('summary_home',repo_name=repo['name']),class_="repo_name")} | |
129 | %if repo['dbrepo_fork']: |
|
115 | %if repo['dbrepo_fork']: | |
130 | <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}"> |
|
116 | <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}"> | |
131 | <img class="icon" alt="${_('fork')}" |
|
117 | <img class="icon" alt="${_('fork')}" | |
132 | title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" |
|
118 | title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" | |
133 | src="${h.url('/images/icons/arrow_divide.png')}"/></a> |
|
119 | src="${h.url('/images/icons/arrow_divide.png')}"/></a> | |
134 | %endif |
|
120 | %endif | |
135 | </div> |
|
121 | </div> | |
136 | </td> |
|
122 | </td> | |
137 | ##DESCRIPTION |
|
123 | ##DESCRIPTION | |
138 | <td><span class="tooltip" title="${h.tooltip(repo['description'])}"> |
|
124 | <td><span class="tooltip" title="${h.tooltip(repo['description'])}"> | |
139 | ${h.truncate(repo['description'],60)}</span> |
|
125 | ${h.truncate(repo['description'],60)}</span> | |
140 | </td> |
|
126 | </td> | |
141 | ##LAST CHANGE |
|
127 | ##LAST CHANGE | |
142 | <td> |
|
128 | <td> | |
143 | <span class="tooltip" title="${repo['last_change']}"> |
|
129 | <span class="tooltip" title="${repo['last_change']}"> | |
144 | ${h.age(repo['last_change'])}</span> |
|
130 | ${h.age(repo['last_change'])}</span> | |
145 | </td> |
|
131 | </td> | |
146 | <td> |
|
132 | <td> | |
147 | %if repo['rev']>=0: |
|
133 | %if repo['rev']>=0: | |
148 | ${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])), |
|
134 | <a title="${h.tooltip('%s\n%s' % (repo['author'],repo['last_msg']))}" class="tooltip" href="${h.url('changeset_home',repo_name=repo['name'],revision=repo['tip'])}">${'r%s:%s' % (repo['rev'],h.short_id(repo['tip']))}</a> | |
149 | h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']), |
|
|||
150 | class_="tooltip", |
|
|||
151 | title=h.tooltip('%s\n%s' % (repo['author'],repo['last_msg'])))} |
|
|||
152 | %else: |
|
135 | %else: | |
153 | ${_('No changesets yet')} |
|
136 | ${_('No changesets yet')} | |
154 | %endif |
|
137 | %endif | |
155 | </td> |
|
138 | </td> | |
156 | <td title="${repo['contact']}">${h.person(repo['contact'])}</td> |
|
139 | <td title="${repo['contact']}">${h.person(repo['contact'])}</td> | |
157 | <td> |
|
140 | <td> | |
158 | %if c.rhodecode_user.username != 'default': |
|
141 | %if c.rhodecode_user.username != 'default': | |
159 | <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_icon" href="${h.url('rss_feed_home',repo_name=repo['name'],api_key=c.rhodecode_user.api_key)}"></a> |
|
142 | <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_icon" href="${h.url('rss_feed_home',repo_name=repo['name'],api_key=c.rhodecode_user.api_key)}"></a> | |
160 | %else: |
|
143 | %else: | |
161 | <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_icon" href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a> |
|
144 | <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_icon" href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a> | |
162 | %endif: |
|
145 | %endif: | |
163 | </td> |
|
146 | </td> | |
164 | <td> |
|
147 | <td> | |
165 | %if c.rhodecode_user.username != 'default': |
|
148 | %if c.rhodecode_user.username != 'default': | |
166 | <a title="${_('Subscribe to %s atom feed')%repo['name']}" class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'],api_key=c.rhodecode_user.api_key)}"></a> |
|
149 | <a title="${_('Subscribe to %s atom feed')%repo['name']}" class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'],api_key=c.rhodecode_user.api_key)}"></a> | |
167 | %else: |
|
150 | %else: | |
168 | <a title="${_('Subscribe to %s atom feed')%repo['name']}" class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a> |
|
151 | <a title="${_('Subscribe to %s atom feed')%repo['name']}" class="atom_icon" href="${h.url('atom_feed_home',repo_name=repo['name'])}"></a> | |
169 | %endif: |
|
152 | %endif: | |
170 | </td> |
|
153 | </td> | |
171 | </tr> |
|
154 | </tr> | |
172 | %endfor |
|
155 | %endfor | |
173 |
|
||||
174 | </tbody> |
|
156 | </tbody> | |
175 | </table> |
|
157 | </table> | |
176 | </div> |
|
158 | </div> | |
177 | </div> |
|
159 | </div> | |
178 |
|
160 | |||
179 |
|
161 | |||
180 | <script type="text/javascript"> |
|
162 | <script type="text/javascript"> | |
181 | var D = YAHOO.util.Dom; |
|
163 | var D = YAHOO.util.Dom; | |
182 | var E = YAHOO.util.Event; |
|
164 | var E = YAHOO.util.Event; | |
183 | var S = YAHOO.util.Selector; |
|
165 | var S = YAHOO.util.Selector; | |
184 |
|
166 | |||
185 | var q_filter = D.get('q_filter'); |
|
167 | var q_filter = D.get('q_filter'); | |
186 | var F = YAHOO.namespace('q_filter'); |
|
168 | var F = YAHOO.namespace('q_filter'); | |
187 |
|
169 | |||
188 | E.on(q_filter,'click',function(){ |
|
170 | E.on(q_filter,'click',function(){ | |
189 | q_filter.value = ''; |
|
171 | q_filter.value = ''; | |
190 | }); |
|
172 | }); | |
191 |
|
173 | |||
192 | F.filterTimeout = null; |
|
174 | F.filterTimeout = null; | |
193 |
|
175 | |||
194 | function set_count(count){ |
|
176 | function set_count(count){ | |
195 |
|
177 | |||
196 | if(count == 0){ |
|
178 | if(count == 0){ | |
197 | YUD.setStyle('repos_list','display','none'); |
|
179 | YUD.setStyle('repos_list','display','none'); | |
198 | YUD.setStyle('welcome','display',''); |
|
180 | YUD.setStyle('welcome','display',''); | |
199 | } |
|
181 | } | |
200 | else{ |
|
182 | else{ | |
201 | YUD.setStyle('repos_list','display',''); |
|
183 | YUD.setStyle('repos_list','display',''); | |
202 | YUD.setStyle('welcome','display','none'); |
|
184 | YUD.setStyle('welcome','display','none'); | |
203 | } |
|
185 | } | |
204 | YUD.get('repo_count').innerHTML = count; |
|
186 | YUD.get('repo_count').innerHTML = count; | |
205 |
|
187 | |||
206 | } |
|
188 | } | |
207 |
|
189 | |||
208 |
|
190 | |||
209 | //set initial count for repos |
|
191 | //set initial count for repos | |
210 | var nodes = S.query('div.table tr td div a.repo_name'); |
|
192 | var nodes = S.query('div.table tr td div a.repo_name'); | |
211 |
|
193 | |||
212 | set_count(nodes.length) |
|
194 | set_count(nodes.length) | |
213 | F.updateFilter = function() { |
|
195 | F.updateFilter = function() { | |
214 | // Reset timeout |
|
196 | // Reset timeout | |
215 | F.filterTimeout = null; |
|
197 | F.filterTimeout = null; | |
216 |
|
198 | |||
217 | var obsolete = []; |
|
199 | var obsolete = []; | |
218 | nodes = S.query('div.table tr td div a.repo_name'); |
|
200 | nodes = S.query('div.table tr td div a.repo_name'); | |
219 | var req = q_filter.value.toLowerCase(); |
|
201 | var req = q_filter.value.toLowerCase(); | |
220 | for (n in nodes){ |
|
202 | for (n in nodes){ | |
221 | D.setStyle(nodes[n].parentNode.parentNode.parentNode,'display','') |
|
203 | D.setStyle(nodes[n].parentNode.parentNode.parentNode,'display','') | |
222 | } |
|
204 | } | |
223 | if (req){ |
|
205 | if (req){ | |
224 | for (n in nodes){ |
|
206 | for (n in nodes){ | |
225 | if (nodes[n].innerHTML.toLowerCase().indexOf(req) == -1) { |
|
207 | if (nodes[n].innerHTML.toLowerCase().indexOf(req) == -1) { | |
226 | obsolete.push(nodes[n]); |
|
208 | obsolete.push(nodes[n]); | |
227 | } |
|
209 | } | |
228 | } |
|
210 | } | |
229 | if(obsolete){ |
|
211 | if(obsolete){ | |
230 | for (n in obsolete){ |
|
212 | for (n in obsolete){ | |
231 | D.setStyle(obsolete[n].parentNode.parentNode.parentNode,'display','none'); |
|
213 | D.setStyle(obsolete[n].parentNode.parentNode.parentNode,'display','none'); | |
232 | } |
|
214 | } | |
233 | } |
|
215 | } | |
234 | } |
|
216 | } | |
235 | // set new count into dashboard |
|
217 | // set new count into dashboard | |
236 | set_count(nodes.length - obsolete.length) |
|
218 | set_count(nodes.length - obsolete.length) | |
237 | } |
|
219 | } | |
238 |
|
220 | |||
239 | E.on(q_filter,'keyup',function(e){ |
|
221 | E.on(q_filter,'keyup',function(e){ | |
240 | clearTimeout(F.filterTimeout); |
|
222 | clearTimeout(F.filterTimeout); | |
241 | F.filterTimeout = setTimeout(F.updateFilter,600); |
|
223 | F.filterTimeout = setTimeout(F.updateFilter,600); | |
242 | }); |
|
224 | }); | |
243 |
|
225 | |||
244 | </script> |
|
226 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now