Show More
@@ -1,251 +1,250 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.admin.repos_groups |
|
3 | rhodecode.controllers.admin.repos_groups | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | repos groups controller for RhodeCode |
|
6 | repos groups controller for RhodeCode | |
7 |
|
7 | |||
8 | :created_on: Mar 23, 2010 |
|
8 | :created_on: Mar 23, 2010 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2010-2012 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 | import traceback |
|
27 | import traceback | |
28 | import formencode |
|
28 | import formencode | |
29 |
|
29 | |||
30 | from formencode import htmlfill |
|
30 | from formencode import htmlfill | |
31 |
|
31 | |||
32 | from pylons import request, response, session, tmpl_context as c, url |
|
32 | from pylons import request, response, session, tmpl_context as c, url | |
33 | from pylons.controllers.util import abort, redirect |
|
33 | from pylons.controllers.util import abort, redirect | |
34 | from pylons.i18n.translation import _ |
|
34 | from pylons.i18n.translation import _ | |
35 |
|
35 | |||
36 | from sqlalchemy.exc import IntegrityError |
|
36 | from sqlalchemy.exc import IntegrityError | |
37 |
|
37 | |||
38 | from rhodecode.lib import helpers as h |
|
38 | from rhodecode.lib import helpers as h | |
39 | from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator |
|
39 | from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator | |
40 | from rhodecode.lib.base import BaseController, render |
|
40 | from rhodecode.lib.base import BaseController, render | |
41 | from rhodecode.model.db import RepoGroup |
|
41 | from rhodecode.model.db import RepoGroup | |
42 | from rhodecode.model.repos_group import ReposGroupModel |
|
42 | from rhodecode.model.repos_group import ReposGroupModel | |
43 | from rhodecode.model.forms import ReposGroupForm |
|
43 | from rhodecode.model.forms import ReposGroupForm | |
44 | from rhodecode.model.meta import Session |
|
44 | from rhodecode.model.meta import Session | |
45 |
|
45 | |||
46 | log = logging.getLogger(__name__) |
|
46 | log = logging.getLogger(__name__) | |
47 |
|
47 | |||
48 |
|
48 | |||
49 | class ReposGroupsController(BaseController): |
|
49 | class ReposGroupsController(BaseController): | |
50 | """REST Controller styled on the Atom Publishing Protocol""" |
|
50 | """REST Controller styled on the Atom Publishing Protocol""" | |
51 | # To properly map this controller, ensure your config/routing.py |
|
51 | # To properly map this controller, ensure your config/routing.py | |
52 | # file has a resource setup: |
|
52 | # file has a resource setup: | |
53 | # map.resource('repos_group', 'repos_groups') |
|
53 | # map.resource('repos_group', 'repos_groups') | |
54 |
|
54 | |||
55 | @LoginRequired() |
|
55 | @LoginRequired() | |
56 | def __before__(self): |
|
56 | def __before__(self): | |
57 | super(ReposGroupsController, self).__before__() |
|
57 | super(ReposGroupsController, self).__before__() | |
58 |
|
58 | |||
59 | def __load_defaults(self): |
|
59 | def __load_defaults(self): | |
60 | c.repo_groups = RepoGroup.groups_choices() |
|
60 | c.repo_groups = RepoGroup.groups_choices() | |
61 | c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
|
61 | c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) | |
62 |
|
62 | |||
63 | def __load_data(self, group_id): |
|
63 | def __load_data(self, group_id): | |
64 | """ |
|
64 | """ | |
65 | Load defaults settings for edit, and update |
|
65 | Load defaults settings for edit, and update | |
66 |
|
66 | |||
67 | :param group_id: |
|
67 | :param group_id: | |
68 | """ |
|
68 | """ | |
69 | self.__load_defaults() |
|
69 | self.__load_defaults() | |
70 |
|
70 | |||
71 | repo_group = RepoGroup.get(group_id) |
|
71 | repo_group = RepoGroup.get(group_id) | |
72 |
|
72 | |||
73 | data = repo_group.get_dict() |
|
73 | data = repo_group.get_dict() | |
74 |
|
74 | |||
75 | data['group_name'] = repo_group.name |
|
75 | data['group_name'] = repo_group.name | |
76 |
|
76 | |||
77 | return data |
|
77 | return data | |
78 |
|
78 | |||
79 | @HasPermissionAnyDecorator('hg.admin') |
|
79 | @HasPermissionAnyDecorator('hg.admin') | |
80 | def index(self, format='html'): |
|
80 | def index(self, format='html'): | |
81 | """GET /repos_groups: All items in the collection""" |
|
81 | """GET /repos_groups: All items in the collection""" | |
82 | # url('repos_groups') |
|
82 | # url('repos_groups') | |
83 |
|
83 | |||
84 | sk = lambda g: g.parents[0].group_name if g.parents else g.group_name |
|
84 | sk = lambda g: g.parents[0].group_name if g.parents else g.group_name | |
85 | c.groups = sorted(RepoGroup.query().all(), key=sk) |
|
85 | c.groups = sorted(RepoGroup.query().all(), key=sk) | |
86 | return render('admin/repos_groups/repos_groups_show.html') |
|
86 | return render('admin/repos_groups/repos_groups_show.html') | |
87 |
|
87 | |||
88 | @HasPermissionAnyDecorator('hg.admin') |
|
88 | @HasPermissionAnyDecorator('hg.admin') | |
89 | def create(self): |
|
89 | def create(self): | |
90 | """POST /repos_groups: Create a new item""" |
|
90 | """POST /repos_groups: Create a new item""" | |
91 | # url('repos_groups') |
|
91 | # url('repos_groups') | |
92 | self.__load_defaults() |
|
92 | self.__load_defaults() | |
93 | repos_group_form = ReposGroupForm(available_groups = |
|
93 | repos_group_form = ReposGroupForm(available_groups = | |
94 | c.repo_groups_choices)() |
|
94 | c.repo_groups_choices)() | |
95 | try: |
|
95 | try: | |
96 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
96 | form_result = repos_group_form.to_python(dict(request.POST)) | |
97 | ReposGroupModel().create(form_result) |
|
97 | ReposGroupModel().create(form_result) | |
98 | Session.commit() |
|
98 | Session.commit() | |
99 | h.flash(_('created repos group %s') \ |
|
99 | h.flash(_('created repos group %s') \ | |
100 | % form_result['group_name'], category='success') |
|
100 | % form_result['group_name'], category='success') | |
101 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
101 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
102 | except formencode.Invalid, errors: |
|
102 | except formencode.Invalid, errors: | |
103 |
|
103 | |||
104 | return htmlfill.render( |
|
104 | return htmlfill.render( | |
105 | render('admin/repos_groups/repos_groups_add.html'), |
|
105 | render('admin/repos_groups/repos_groups_add.html'), | |
106 | defaults=errors.value, |
|
106 | defaults=errors.value, | |
107 | errors=errors.error_dict or {}, |
|
107 | errors=errors.error_dict or {}, | |
108 | prefix_error=False, |
|
108 | prefix_error=False, | |
109 | encoding="UTF-8") |
|
109 | encoding="UTF-8") | |
110 | except Exception: |
|
110 | except Exception: | |
111 | log.error(traceback.format_exc()) |
|
111 | log.error(traceback.format_exc()) | |
112 | h.flash(_('error occurred during creation of repos group %s') \ |
|
112 | h.flash(_('error occurred during creation of repos group %s') \ | |
113 | % request.POST.get('group_name'), category='error') |
|
113 | % request.POST.get('group_name'), category='error') | |
114 |
|
114 | |||
115 | return redirect(url('repos_groups')) |
|
115 | return redirect(url('repos_groups')) | |
116 |
|
116 | |||
117 | @HasPermissionAnyDecorator('hg.admin') |
|
117 | @HasPermissionAnyDecorator('hg.admin') | |
118 | def new(self, format='html'): |
|
118 | def new(self, format='html'): | |
119 | """GET /repos_groups/new: Form to create a new item""" |
|
119 | """GET /repos_groups/new: Form to create a new item""" | |
120 | # url('new_repos_group') |
|
120 | # url('new_repos_group') | |
121 | self.__load_defaults() |
|
121 | self.__load_defaults() | |
122 | return render('admin/repos_groups/repos_groups_add.html') |
|
122 | return render('admin/repos_groups/repos_groups_add.html') | |
123 |
|
123 | |||
124 | @HasPermissionAnyDecorator('hg.admin') |
|
124 | @HasPermissionAnyDecorator('hg.admin') | |
125 | def update(self, id): |
|
125 | def update(self, id): | |
126 | """PUT /repos_groups/id: Update an existing item""" |
|
126 | """PUT /repos_groups/id: Update an existing item""" | |
127 | # Forms posted to this method should contain a hidden field: |
|
127 | # Forms posted to this method should contain a hidden field: | |
128 | # <input type="hidden" name="_method" value="PUT" /> |
|
128 | # <input type="hidden" name="_method" value="PUT" /> | |
129 | # Or using helpers: |
|
129 | # Or using helpers: | |
130 | # h.form(url('repos_group', id=ID), |
|
130 | # h.form(url('repos_group', id=ID), | |
131 | # method='put') |
|
131 | # method='put') | |
132 | # url('repos_group', id=ID) |
|
132 | # url('repos_group', id=ID) | |
133 |
|
133 | |||
134 | self.__load_defaults() |
|
134 | self.__load_defaults() | |
135 | c.repos_group = RepoGroup.get(id) |
|
135 | c.repos_group = RepoGroup.get(id) | |
136 |
|
136 | |||
137 | repos_group_form = ReposGroupForm(edit=True, |
|
137 | repos_group_form = ReposGroupForm(edit=True, | |
138 | old_data=c.repos_group.get_dict(), |
|
138 | old_data=c.repos_group.get_dict(), | |
139 | available_groups= |
|
139 | available_groups= | |
140 | c.repo_groups_choices)() |
|
140 | c.repo_groups_choices)() | |
141 | try: |
|
141 | try: | |
142 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
142 | form_result = repos_group_form.to_python(dict(request.POST)) | |
143 | ReposGroupModel().update(id, form_result) |
|
143 | ReposGroupModel().update(id, form_result) | |
144 | Session.commit() |
|
144 | Session.commit() | |
145 | h.flash(_('updated repos group %s') \ |
|
145 | h.flash(_('updated repos group %s') \ | |
146 | % form_result['group_name'], category='success') |
|
146 | % form_result['group_name'], category='success') | |
147 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
147 | #TODO: in futureaction_logger(, '', '', '', self.sa) | |
148 | except formencode.Invalid, errors: |
|
148 | except formencode.Invalid, errors: | |
149 |
|
149 | |||
150 | return htmlfill.render( |
|
150 | return htmlfill.render( | |
151 | render('admin/repos_groups/repos_groups_edit.html'), |
|
151 | render('admin/repos_groups/repos_groups_edit.html'), | |
152 | defaults=errors.value, |
|
152 | defaults=errors.value, | |
153 | errors=errors.error_dict or {}, |
|
153 | errors=errors.error_dict or {}, | |
154 | prefix_error=False, |
|
154 | prefix_error=False, | |
155 | encoding="UTF-8") |
|
155 | encoding="UTF-8") | |
156 | except Exception: |
|
156 | except Exception: | |
157 | log.error(traceback.format_exc()) |
|
157 | log.error(traceback.format_exc()) | |
158 | h.flash(_('error occurred during update of repos group %s') \ |
|
158 | h.flash(_('error occurred during update of repos group %s') \ | |
159 | % request.POST.get('group_name'), category='error') |
|
159 | % request.POST.get('group_name'), category='error') | |
160 |
|
160 | |||
161 | return redirect(url('repos_groups')) |
|
161 | return redirect(url('repos_groups')) | |
162 |
|
162 | |||
163 |
|
||||
164 | @HasPermissionAnyDecorator('hg.admin') |
|
163 | @HasPermissionAnyDecorator('hg.admin') | |
165 | def delete(self, id): |
|
164 | def delete(self, id): | |
166 | """DELETE /repos_groups/id: Delete an existing item""" |
|
165 | """DELETE /repos_groups/id: Delete an existing item""" | |
167 | # Forms posted to this method should contain a hidden field: |
|
166 | # Forms posted to this method should contain a hidden field: | |
168 | # <input type="hidden" name="_method" value="DELETE" /> |
|
167 | # <input type="hidden" name="_method" value="DELETE" /> | |
169 | # Or using helpers: |
|
168 | # Or using helpers: | |
170 | # h.form(url('repos_group', id=ID), |
|
169 | # h.form(url('repos_group', id=ID), | |
171 | # method='delete') |
|
170 | # method='delete') | |
172 | # url('repos_group', id=ID) |
|
171 | # url('repos_group', id=ID) | |
173 |
|
172 | |||
174 | gr = RepoGroup.get(id) |
|
173 | gr = RepoGroup.get(id) | |
175 | repos = gr.repositories.all() |
|
174 | repos = gr.repositories.all() | |
176 | if repos: |
|
175 | if repos: | |
177 | h.flash(_('This group contains %s repositores and cannot be ' |
|
176 | h.flash(_('This group contains %s repositores and cannot be ' | |
178 | 'deleted' % len(repos)), |
|
177 | 'deleted' % len(repos)), | |
179 | category='error') |
|
178 | category='error') | |
180 | return redirect(url('repos_groups')) |
|
179 | return redirect(url('repos_groups')) | |
181 |
|
180 | |||
182 | try: |
|
181 | try: | |
183 | ReposGroupModel().delete(id) |
|
182 | ReposGroupModel().delete(id) | |
184 | Session.commit() |
|
183 | Session.commit() | |
185 | h.flash(_('removed repos group %s' % gr.group_name), category='success') |
|
184 | h.flash(_('removed repos group %s' % gr.group_name), category='success') | |
186 | #TODO: in future action_logger(, '', '', '', self.sa) |
|
185 | #TODO: in future action_logger(, '', '', '', self.sa) | |
187 | except IntegrityError, e: |
|
186 | except IntegrityError, e: | |
188 | if e.message.find('groups_group_parent_id_fkey') != -1: |
|
187 | if e.message.find('groups_group_parent_id_fkey') != -1: | |
189 | log.error(traceback.format_exc()) |
|
188 | log.error(traceback.format_exc()) | |
190 | h.flash(_('Cannot delete this group it still contains ' |
|
189 | h.flash(_('Cannot delete this group it still contains ' | |
191 | 'subgroups'), |
|
190 | 'subgroups'), | |
192 | category='warning') |
|
191 | category='warning') | |
193 | else: |
|
192 | else: | |
194 | log.error(traceback.format_exc()) |
|
193 | log.error(traceback.format_exc()) | |
195 | h.flash(_('error occurred during deletion of repos ' |
|
194 | h.flash(_('error occurred during deletion of repos ' | |
196 | 'group %s' % gr.group_name), category='error') |
|
195 | 'group %s' % gr.group_name), category='error') | |
197 |
|
196 | |||
198 | except Exception: |
|
197 | except Exception: | |
199 | log.error(traceback.format_exc()) |
|
198 | log.error(traceback.format_exc()) | |
200 | h.flash(_('error occurred during deletion of repos ' |
|
199 | h.flash(_('error occurred during deletion of repos ' | |
201 | 'group %s' % gr.group_name), category='error') |
|
200 | 'group %s' % gr.group_name), category='error') | |
202 |
|
201 | |||
203 | return redirect(url('repos_groups')) |
|
202 | return redirect(url('repos_groups')) | |
204 |
|
203 | |||
205 | def show_by_name(self, group_name): |
|
204 | def show_by_name(self, group_name): | |
206 | id_ = RepoGroup.get_by_group_name(group_name).group_id |
|
205 | id_ = RepoGroup.get_by_group_name(group_name).group_id | |
207 | return self.show(id_) |
|
206 | return self.show(id_) | |
208 |
|
207 | |||
209 | def show(self, id, format='html'): |
|
208 | def show(self, id, format='html'): | |
210 | """GET /repos_groups/id: Show a specific item""" |
|
209 | """GET /repos_groups/id: Show a specific item""" | |
211 | # url('repos_group', id=ID) |
|
210 | # url('repos_group', id=ID) | |
212 |
|
211 | |||
213 | c.group = RepoGroup.get(id) |
|
212 | c.group = RepoGroup.get(id) | |
214 |
|
213 | |||
215 | if c.group: |
|
214 | if c.group: | |
216 | c.group_repos = c.group.repositories.all() |
|
215 | c.group_repos = c.group.repositories.all() | |
217 | else: |
|
216 | else: | |
218 | return redirect(url('home')) |
|
217 | return redirect(url('home')) | |
219 |
|
218 | |||
220 | #overwrite our cached list with current filter |
|
219 | #overwrite our cached list with current filter | |
221 | gr_filter = c.group_repos |
|
220 | gr_filter = c.group_repos | |
222 | c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) |
|
221 | c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) | |
223 |
|
222 | |||
224 | c.repos_list = c.cached_repo_list |
|
223 | c.repos_list = c.cached_repo_list | |
225 |
|
224 | |||
226 | c.repo_cnt = 0 |
|
225 | c.repo_cnt = 0 | |
227 |
|
226 | |||
228 | c.groups = self.sa.query(RepoGroup).order_by(RepoGroup.group_name)\ |
|
227 | c.groups = self.sa.query(RepoGroup).order_by(RepoGroup.group_name)\ | |
229 | .filter(RepoGroup.group_parent_id == id).all() |
|
228 | .filter(RepoGroup.group_parent_id == id).all() | |
230 |
|
229 | |||
231 | return render('admin/repos_groups/repos_groups.html') |
|
230 | return render('admin/repos_groups/repos_groups.html') | |
232 |
|
231 | |||
233 | @HasPermissionAnyDecorator('hg.admin') |
|
232 | @HasPermissionAnyDecorator('hg.admin') | |
234 | def edit(self, id, format='html'): |
|
233 | def edit(self, id, format='html'): | |
235 | """GET /repos_groups/id/edit: Form to edit an existing item""" |
|
234 | """GET /repos_groups/id/edit: Form to edit an existing item""" | |
236 | # url('edit_repos_group', id=ID) |
|
235 | # url('edit_repos_group', id=ID) | |
237 |
|
236 | |||
238 | id_ = int(id) |
|
237 | id_ = int(id) | |
239 |
|
238 | |||
240 | c.repos_group = RepoGroup.get(id_) |
|
239 | c.repos_group = RepoGroup.get(id_) | |
241 | defaults = self.__load_data(id_) |
|
240 | defaults = self.__load_data(id_) | |
242 |
|
241 | |||
243 | # we need to exclude this group from the group list for editing |
|
242 | # we need to exclude this group from the group list for editing | |
244 | c.repo_groups = filter(lambda x:x[0] != id_, c.repo_groups) |
|
243 | c.repo_groups = filter(lambda x:x[0] != id_, c.repo_groups) | |
245 |
|
244 | |||
246 | return htmlfill.render( |
|
245 | return htmlfill.render( | |
247 | render('admin/repos_groups/repos_groups_edit.html'), |
|
246 | render('admin/repos_groups/repos_groups_edit.html'), | |
248 | defaults=defaults, |
|
247 | defaults=defaults, | |
249 | encoding="UTF-8", |
|
248 | encoding="UTF-8", | |
250 | force_defaults=False |
|
249 | force_defaults=False | |
251 | ) |
|
250 | ) |
@@ -1,190 +1,190 | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%def name="title()"> |
|
4 | <%def name="title()"> | |
5 | ${_('My account')} ${c.rhodecode_user.username} - ${c.rhodecode_name} |
|
5 | ${_('My account')} ${c.rhodecode_user.username} - ${c.rhodecode_name} | |
6 | </%def> |
|
6 | </%def> | |
7 |
|
7 | |||
8 | <%def name="breadcrumbs_links()"> |
|
8 | <%def name="breadcrumbs_links()"> | |
9 | ${_('My Account')} |
|
9 | ${_('My Account')} | |
10 | </%def> |
|
10 | </%def> | |
11 |
|
11 | |||
12 | <%def name="page_nav()"> |
|
12 | <%def name="page_nav()"> | |
13 | ${self.menu('admin')} |
|
13 | ${self.menu('admin')} | |
14 | </%def> |
|
14 | </%def> | |
15 |
|
15 | |||
16 | <%def name="main()"> |
|
16 | <%def name="main()"> | |
17 |
|
17 | |||
18 | <div class="box box-left"> |
|
18 | <div class="box box-left"> | |
19 | <!-- box / title --> |
|
19 | <!-- box / title --> | |
20 | <div class="title"> |
|
20 | <div class="title"> | |
21 | ${self.breadcrumbs()} |
|
21 | ${self.breadcrumbs()} | |
22 | </div> |
|
22 | </div> | |
23 | <!-- end box / title --> |
|
23 | <!-- end box / title --> | |
24 | <div> |
|
24 | <div> | |
25 | ${h.form(url('admin_settings_my_account_update'),method='put')} |
|
25 | ${h.form(url('admin_settings_my_account_update'),method='put')} | |
26 | <div class="form"> |
|
26 | <div class="form"> | |
27 |
|
27 | |||
28 | <div class="field"> |
|
28 | <div class="field"> | |
29 | <div class="gravatar_box"> |
|
29 | <div class="gravatar_box"> | |
30 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div> |
|
30 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div> | |
31 | <p> |
|
31 | <p> | |
32 | %if c.use_gravatar: |
|
32 | %if c.use_gravatar: | |
33 | <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong> |
|
33 | <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong> | |
34 | <br/>${_('Using')} ${c.user.email} |
|
34 | <br/>${_('Using')} ${c.user.email} | |
35 | %else: |
|
35 | %else: | |
36 | <br/>${c.user.email} |
|
36 | <br/>${c.user.email} | |
37 | %endif |
|
37 | %endif | |
38 | </p> |
|
38 | </p> | |
39 | </div> |
|
39 | </div> | |
40 | </div> |
|
40 | </div> | |
41 | <div class="field"> |
|
41 | <div class="field"> | |
42 | <div class="label"> |
|
42 | <div class="label"> | |
43 | <label>${_('API key')}</label> ${c.user.api_key} |
|
43 | <label>${_('API key')}</label> ${c.user.api_key} | |
44 | </div> |
|
44 | </div> | |
45 | </div> |
|
45 | </div> | |
46 | <div class="fields"> |
|
46 | <div class="fields"> | |
47 | <div class="field"> |
|
47 | <div class="field"> | |
48 | <div class="label"> |
|
48 | <div class="label"> | |
49 | <label for="username">${_('Username')}:</label> |
|
49 | <label for="username">${_('Username')}:</label> | |
50 | </div> |
|
50 | </div> | |
51 | <div class="input"> |
|
51 | <div class="input"> | |
52 | ${h.text('username',class_="medium")} |
|
52 | ${h.text('username',class_="medium")} | |
53 | </div> |
|
53 | </div> | |
54 | </div> |
|
54 | </div> | |
55 |
|
55 | |||
56 | <div class="field"> |
|
56 | <div class="field"> | |
57 | <div class="label"> |
|
57 | <div class="label"> | |
58 | <label for="new_password">${_('New password')}:</label> |
|
58 | <label for="new_password">${_('New password')}:</label> | |
59 | </div> |
|
59 | </div> | |
60 | <div class="input"> |
|
60 | <div class="input"> | |
61 | ${h.password('new_password',class_="medium",autocomplete="off")} |
|
61 | ${h.password('new_password',class_="medium",autocomplete="off")} | |
62 | </div> |
|
62 | </div> | |
63 | </div> |
|
63 | </div> | |
64 |
|
64 | |||
65 | <div class="field"> |
|
65 | <div class="field"> | |
66 | <div class="label"> |
|
66 | <div class="label"> | |
67 | <label for="password_confirmation">${_('New password confirmation')}:</label> |
|
67 | <label for="password_confirmation">${_('New password confirmation')}:</label> | |
68 | </div> |
|
68 | </div> | |
69 | <div class="input"> |
|
69 | <div class="input"> | |
70 | ${h.password('password_confirmation',class_="medium",autocomplete="off")} |
|
70 | ${h.password('password_confirmation',class_="medium",autocomplete="off")} | |
71 | </div> |
|
71 | </div> | |
72 | </div> |
|
72 | </div> | |
73 |
|
73 | |||
74 | <div class="field"> |
|
74 | <div class="field"> | |
75 | <div class="label"> |
|
75 | <div class="label"> | |
76 | <label for="name">${_('First Name')}:</label> |
|
76 | <label for="name">${_('First Name')}:</label> | |
77 | </div> |
|
77 | </div> | |
78 | <div class="input"> |
|
78 | <div class="input"> | |
79 | ${h.text('name',class_="medium")} |
|
79 | ${h.text('name',class_="medium")} | |
80 | </div> |
|
80 | </div> | |
81 | </div> |
|
81 | </div> | |
82 |
|
82 | |||
83 | <div class="field"> |
|
83 | <div class="field"> | |
84 | <div class="label"> |
|
84 | <div class="label"> | |
85 | <label for="lastname">${_('Last Name')}:</label> |
|
85 | <label for="lastname">${_('Last Name')}:</label> | |
86 | </div> |
|
86 | </div> | |
87 | <div class="input"> |
|
87 | <div class="input"> | |
88 | ${h.text('lastname',class_="medium")} |
|
88 | ${h.text('lastname',class_="medium")} | |
89 | </div> |
|
89 | </div> | |
90 | </div> |
|
90 | </div> | |
91 |
|
91 | |||
92 | <div class="field"> |
|
92 | <div class="field"> | |
93 | <div class="label"> |
|
93 | <div class="label"> | |
94 | <label for="email">${_('Email')}:</label> |
|
94 | <label for="email">${_('Email')}:</label> | |
95 | </div> |
|
95 | </div> | |
96 | <div class="input"> |
|
96 | <div class="input"> | |
97 | ${h.text('email',class_="medium")} |
|
97 | ${h.text('email',class_="medium")} | |
98 | </div> |
|
98 | </div> | |
99 | </div> |
|
99 | </div> | |
100 |
|
100 | |||
101 | <div class="buttons"> |
|
101 | <div class="buttons"> | |
102 | ${h.submit('save',_('Save'),class_="ui-button")} |
|
102 | ${h.submit('save',_('Save'),class_="ui-button")} | |
103 | ${h.reset('reset',_('Reset'),class_="ui-button")} |
|
103 | ${h.reset('reset',_('Reset'),class_="ui-button")} | |
104 | </div> |
|
104 | </div> | |
105 | </div> |
|
105 | </div> | |
106 | </div> |
|
106 | </div> | |
107 | ${h.end_form()} |
|
107 | ${h.end_form()} | |
108 | </div> |
|
108 | </div> | |
109 | </div> |
|
109 | </div> | |
110 |
|
110 | |||
111 | <div class="box box-right"> |
|
111 | <div class="box box-right"> | |
112 | <!-- box / title --> |
|
112 | <!-- box / title --> | |
113 | <div class="title"> |
|
113 | <div class="title"> | |
114 | <h5> |
|
114 | <h5> | |
115 | <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> |
|
115 | <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> | |
116 | ${_('My repositories')} |
|
116 | ${_('My repositories')} | |
117 | </h5> |
|
117 | </h5> | |
118 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): |
|
118 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): | |
119 | <ul class="links"> |
|
119 | <ul class="links"> | |
120 | <li> |
|
120 | <li> | |
121 | <span>${h.link_to(_('ADD REPOSITORY'),h.url('admin_settings_create_repository'))}</span> |
|
121 | <span>${h.link_to(_('ADD REPOSITORY'),h.url('admin_settings_create_repository'))}</span> | |
122 | </li> |
|
122 | </li> | |
123 | </ul> |
|
123 | </ul> | |
124 | %endif |
|
124 | %endif | |
125 | </div> |
|
125 | </div> | |
126 | <!-- end box / title --> |
|
126 | <!-- end box / title --> | |
127 | <div class="table"> |
|
127 | <div class="table"> | |
128 | <table> |
|
128 | <table> | |
129 | <thead> |
|
129 | <thead> | |
130 | <tr> |
|
130 | <tr> | |
131 | <th class="left">${_('Name')}</th> |
|
131 | <th class="left">${_('Name')}</th> | |
132 | <th class="left">${_('revision')}</th> |
|
132 | <th class="left">${_('revision')}</th> | |
133 | <th colspan="2" class="left">${_('action')}</th> |
|
133 | <th colspan="2" class="left">${_('action')}</th> | |
134 | </thead> |
|
134 | </thead> | |
135 | <tbody> |
|
135 | <tbody> | |
136 | %if c.user_repos: |
|
136 | %if c.user_repos: | |
137 | %for repo in c.user_repos: |
|
137 | %for repo in c.user_repos: | |
138 | <tr> |
|
138 | <tr> | |
139 | <td> |
|
139 | <td> | |
140 |
%if repo['dbrepo']['repo_type'] |
|
140 | %if h.is_hg(repo['dbrepo']['repo_type']): | |
141 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> |
|
141 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> | |
142 |
%elif repo['dbrepo']['repo_type'] |
|
142 | %elif h.is_git(repo['dbrepo']['repo_type']): | |
143 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> |
|
143 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> | |
144 | %else: |
|
144 | %else: | |
145 |
|
145 | |||
146 | %endif |
|
146 | %endif | |
147 | %if repo['dbrepo']['private']: |
|
147 | %if repo['dbrepo']['private']: | |
148 | <img class="icon" alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/> |
|
148 | <img class="icon" alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/> | |
149 | %else: |
|
149 | %else: | |
150 | <img class="icon" alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/> |
|
150 | <img class="icon" alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/> | |
151 | %endif |
|
151 | %endif | |
152 |
|
152 | |||
153 | ${h.link_to(repo['name'], h.url('summary_home',repo_name=repo['name']),class_="repo_name")} |
|
153 | ${h.link_to(repo['name'], h.url('summary_home',repo_name=repo['name']),class_="repo_name")} | |
154 | %if repo['dbrepo_fork']: |
|
154 | %if repo['dbrepo_fork']: | |
155 | <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}"> |
|
155 | <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}"> | |
156 | <img class="icon" alt="${_('public')}" |
|
156 | <img class="icon" alt="${_('public')}" | |
157 | title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" |
|
157 | title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" | |
158 | src="${h.url('/images/icons/arrow_divide.png')}"/></a> |
|
158 | src="${h.url('/images/icons/arrow_divide.png')}"/></a> | |
159 | %endif |
|
159 | %endif | |
160 | </td> |
|
160 | </td> | |
161 | <td><span class="tooltip" title="${repo['last_change']}">${("r%s:%s") % (repo['rev'],h.short_id(repo['tip']))}</span></td> |
|
161 | <td><span class="tooltip" title="${repo['last_change']}">${("r%s:%s") % (repo['rev'],h.short_id(repo['tip']))}</span></td> | |
162 | <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> |
|
162 | <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> | |
163 | <td> |
|
163 | <td> | |
164 | ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')} |
|
164 | ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')} | |
165 | ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")} |
|
165 | ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")} | |
166 | ${h.end_form()} |
|
166 | ${h.end_form()} | |
167 | </td> |
|
167 | </td> | |
168 | </tr> |
|
168 | </tr> | |
169 | %endfor |
|
169 | %endfor | |
170 | %else: |
|
170 | %else: | |
171 | <div style="padding:5px 0px 10px 0px;"> |
|
171 | <div style="padding:5px 0px 10px 0px;"> | |
172 | ${_('No repositories yet')} |
|
172 | ${_('No repositories yet')} | |
173 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): |
|
173 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): | |
174 | ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")} |
|
174 | ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")} | |
175 | %endif |
|
175 | %endif | |
176 | </div> |
|
176 | </div> | |
177 | %endif |
|
177 | %endif | |
178 | </tbody> |
|
178 | </tbody> | |
179 | </table> |
|
179 | </table> | |
180 | </div> |
|
180 | </div> | |
181 | </div> |
|
181 | </div> | |
182 | <script type="text/javascript"> |
|
182 | <script type="text/javascript"> | |
183 | var nodes = YUQ('div.table tr td a.repo_name'); |
|
183 | var nodes = YUQ('div.table tr td a.repo_name'); | |
184 | var target = 'q_filter'; |
|
184 | var target = 'q_filter'; | |
185 | var func = function(node){ |
|
185 | var func = function(node){ | |
186 | return node.parentNode.parentNode; |
|
186 | return node.parentNode.parentNode; | |
187 | } |
|
187 | } | |
188 | q_filter(target,nodes,func); |
|
188 | q_filter(target,nodes,func); | |
189 | </script> |
|
189 | </script> | |
190 | </%def> |
|
190 | </%def> |
@@ -1,290 +1,280 | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%def name="title()"> |
|
4 | <%def name="title()"> | |
5 | ${_('Edit users group')} ${c.users_group.users_group_name} - ${c.rhodecode_name} |
|
5 | ${_('Edit users group')} ${c.users_group.users_group_name} - ${c.rhodecode_name} | |
6 | </%def> |
|
6 | </%def> | |
7 |
|
7 | |||
8 | <%def name="breadcrumbs_links()"> |
|
8 | <%def name="breadcrumbs_links()"> | |
9 | ${h.link_to(_('Admin'),h.url('admin_home'))} |
|
9 | ${h.link_to(_('Admin'),h.url('admin_home'))} | |
10 | » |
|
10 | » | |
11 | ${h.link_to(_('UsersGroups'),h.url('users_groups'))} |
|
11 | ${h.link_to(_('UsersGroups'),h.url('users_groups'))} | |
12 | » |
|
12 | » | |
13 | ${_('edit')} "${c.users_group.users_group_name}" |
|
13 | ${_('edit')} "${c.users_group.users_group_name}" | |
14 | </%def> |
|
14 | </%def> | |
15 |
|
15 | |||
16 | <%def name="page_nav()"> |
|
16 | <%def name="page_nav()"> | |
17 | ${self.menu('admin')} |
|
17 | ${self.menu('admin')} | |
18 | </%def> |
|
18 | </%def> | |
19 |
|
19 | |||
20 | <%def name="main()"> |
|
20 | <%def name="main()"> | |
21 | <div class="box box-left"> |
|
21 | <div class="box box-left"> | |
22 | <!-- box / title --> |
|
22 | <!-- box / title --> | |
23 | <div class="title"> |
|
23 | <div class="title"> | |
24 | ${self.breadcrumbs()} |
|
24 | ${self.breadcrumbs()} | |
25 | </div> |
|
25 | </div> | |
26 | <!-- end box / title --> |
|
26 | <!-- end box / title --> | |
27 | ${h.form(url('users_group', id=c.users_group.users_group_id),method='put', id='edit_users_group')} |
|
27 | ${h.form(url('users_group', id=c.users_group.users_group_id),method='put', id='edit_users_group')} | |
28 | <div class="form"> |
|
28 | <div class="form"> | |
29 | <!-- fields --> |
|
29 | <!-- fields --> | |
30 | <div class="fields"> |
|
30 | <div class="fields"> | |
31 | <div class="field"> |
|
31 | <div class="field"> | |
32 | <div class="label"> |
|
32 | <div class="label"> | |
33 | <label for="users_group_name">${_('Group name')}:</label> |
|
33 | <label for="users_group_name">${_('Group name')}:</label> | |
34 | </div> |
|
34 | </div> | |
35 | <div class="input"> |
|
35 | <div class="input"> | |
36 | ${h.text('users_group_name',class_='small')} |
|
36 | ${h.text('users_group_name',class_='small')} | |
37 | </div> |
|
37 | </div> | |
38 | </div> |
|
38 | </div> | |
39 |
|
39 | |||
40 | <div class="field"> |
|
40 | <div class="field"> | |
41 | <div class="label label-checkbox"> |
|
41 | <div class="label label-checkbox"> | |
42 | <label for="users_group_active">${_('Active')}:</label> |
|
42 | <label for="users_group_active">${_('Active')}:</label> | |
43 | </div> |
|
43 | </div> | |
44 | <div class="checkboxes"> |
|
44 | <div class="checkboxes"> | |
45 | ${h.checkbox('users_group_active',value=True)} |
|
45 | ${h.checkbox('users_group_active',value=True)} | |
46 | </div> |
|
46 | </div> | |
47 | </div> |
|
47 | </div> | |
48 | <div class="field"> |
|
48 | <div class="field"> | |
49 | <div class="label"> |
|
49 | <div class="label"> | |
50 | <label for="users_group_active">${_('Members')}:</label> |
|
50 | <label for="users_group_active">${_('Members')}:</label> | |
51 | </div> |
|
51 | </div> | |
52 | <div class="select"> |
|
52 | <div class="select"> | |
53 | <table> |
|
53 | <table> | |
54 | <tr> |
|
54 | <tr> | |
55 | <td> |
|
55 | <td> | |
56 | <div> |
|
56 | <div> | |
57 | <div style="float:left"> |
|
57 | <div style="float:left"> | |
58 | <div class="text" style="padding: 0px 0px 6px;">${_('Choosen group members')}</div> |
|
58 | <div class="text" style="padding: 0px 0px 6px;">${_('Choosen group members')}</div> | |
59 | ${h.select('users_group_members',[x[0] for x in c.group_members],c.group_members,multiple=True,size=8,style="min-width:210px")} |
|
59 | ${h.select('users_group_members',[x[0] for x in c.group_members],c.group_members,multiple=True,size=8,style="min-width:210px")} | |
60 | <div id="remove_all_elements" style="cursor:pointer;text-align:center"> |
|
60 | <div id="remove_all_elements" style="cursor:pointer;text-align:center"> | |
61 | ${_('Remove all elements')} |
|
61 | ${_('Remove all elements')} | |
62 | <img alt="remove" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_right.png')}"/> |
|
62 | <img alt="remove" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_right.png')}"/> | |
63 | </div> |
|
63 | </div> | |
64 | </div> |
|
64 | </div> | |
65 | <div style="float:left;width:20px;padding-top:50px"> |
|
65 | <div style="float:left;width:20px;padding-top:50px"> | |
66 | <img alt="add" id="add_element" |
|
66 | <img alt="add" id="add_element" | |
67 | style="padding:2px;cursor:pointer" |
|
67 | style="padding:2px;cursor:pointer" | |
68 | src="${h.url('/images/icons/arrow_left.png')}"/> |
|
68 | src="${h.url('/images/icons/arrow_left.png')}"/> | |
69 | <br /> |
|
69 | <br /> | |
70 | <img alt="remove" id="remove_element" |
|
70 | <img alt="remove" id="remove_element" | |
71 | style="padding:2px;cursor:pointer" |
|
71 | style="padding:2px;cursor:pointer" | |
72 | src="${h.url('/images/icons/arrow_right.png')}"/> |
|
72 | src="${h.url('/images/icons/arrow_right.png')}"/> | |
73 | </div> |
|
73 | </div> | |
74 | <div style="float:left"> |
|
74 | <div style="float:left"> | |
75 | <div class="text" style="padding: 0px 0px 6px;">${_('Available members')}</div> |
|
75 | <div class="text" style="padding: 0px 0px 6px;">${_('Available members')}</div> | |
76 | ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")} |
|
76 | ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")} | |
77 | <div id="add_all_elements" style="cursor:pointer;text-align:center"> |
|
77 | <div id="add_all_elements" style="cursor:pointer;text-align:center"> | |
78 | <img alt="add" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_left.png')}"/> |
|
78 | <img alt="add" style="vertical-align:text-bottom" src="${h.url('/images/icons/arrow_left.png')}"/> | |
79 | ${_('Add all elements')} |
|
79 | ${_('Add all elements')} | |
80 | </div> |
|
80 | </div> | |
81 | </div> |
|
81 | </div> | |
82 | </div> |
|
82 | </div> | |
83 | </td> |
|
83 | </td> | |
84 | </tr> |
|
84 | </tr> | |
85 | </table> |
|
85 | </table> | |
86 | </div> |
|
86 | </div> | |
87 |
|
87 | |||
88 | </div> |
|
88 | </div> | |
89 | <div class="buttons"> |
|
89 | <div class="buttons"> | |
90 | ${h.submit('save',_('save'),class_="ui-button")} |
|
90 | ${h.submit('save',_('save'),class_="ui-button")} | |
91 | </div> |
|
91 | </div> | |
92 | </div> |
|
92 | </div> | |
93 | </div> |
|
93 | </div> | |
94 | ${h.end_form()} |
|
94 | ${h.end_form()} | |
95 | </div> |
|
95 | </div> | |
96 |
|
96 | |||
97 | <div class="box box-right"> |
|
97 | <div class="box box-right"> | |
98 | <!-- box / title --> |
|
98 | <!-- box / title --> | |
99 | <div class="title"> |
|
99 | <div class="title"> | |
100 | <h5>${_('Permissions')}</h5> |
|
100 | <h5>${_('Permissions')}</h5> | |
101 | </div> |
|
101 | </div> | |
102 | ${h.form(url('users_group_perm', id=c.users_group.users_group_id), method='put')} |
|
102 | ${h.form(url('users_group_perm', id=c.users_group.users_group_id), method='put')} | |
103 | <div class="form"> |
|
103 | <div class="form"> | |
104 | <!-- fields --> |
|
104 | <!-- fields --> | |
105 | <div class="fields"> |
|
105 | <div class="fields"> | |
106 | <div class="field"> |
|
106 | <div class="field"> | |
107 | <div class="label label-checkbox"> |
|
107 | <div class="label label-checkbox"> | |
108 | <label for="create_repo_perm">${_('Create repositories')}:</label> |
|
108 | <label for="create_repo_perm">${_('Create repositories')}:</label> | |
109 | </div> |
|
109 | </div> | |
110 | <div class="checkboxes"> |
|
110 | <div class="checkboxes"> | |
111 | ${h.checkbox('create_repo_perm',value=True)} |
|
111 | ${h.checkbox('create_repo_perm',value=True)} | |
112 | </div> |
|
112 | </div> | |
113 | </div> |
|
113 | </div> | |
114 | <div class="buttons"> |
|
114 | <div class="buttons"> | |
115 | ${h.submit('save',_('Save'),class_="ui-button")} |
|
115 | ${h.submit('save',_('Save'),class_="ui-button")} | |
116 | ${h.reset('reset',_('Reset'),class_="ui-button")} |
|
116 | ${h.reset('reset',_('Reset'),class_="ui-button")} | |
117 | </div> |
|
117 | </div> | |
118 | </div> |
|
118 | </div> | |
119 | </div> |
|
119 | </div> | |
120 | ${h.end_form()} |
|
120 | ${h.end_form()} | |
121 | </div> |
|
121 | </div> | |
122 |
|
122 | |||
123 | <div class="box box-right"> |
|
123 | <div class="box box-right"> | |
124 | <!-- box / title --> |
|
124 | <!-- box / title --> | |
125 | <div class="title"> |
|
125 | <div class="title"> | |
126 | <h5>${_('Group members')}</h5> |
|
126 | <h5>${_('Group members')}</h5> | |
127 | </div> |
|
127 | </div> | |
128 | <div class="group_members_wrap"> |
|
128 | <div class="group_members_wrap"> | |
129 | <ul class="group_members"> |
|
129 | <ul class="group_members"> | |
130 | %for user in c.group_members_obj: |
|
130 | %for user in c.group_members_obj: | |
131 | <li> |
|
131 | <li> | |
132 | <div class="group_member"> |
|
132 | <div class="group_member"> | |
133 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/> </div> |
|
133 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/> </div> | |
134 | <div>${user.username}</div> |
|
134 | <div>${user.username}</div> | |
135 | <div>${user.full_name}</div> |
|
135 | <div>${user.full_name}</div> | |
136 | </div> |
|
136 | </div> | |
137 | </li> |
|
137 | </li> | |
138 | %endfor |
|
138 | %endfor | |
139 | </ul> |
|
139 | </ul> | |
140 | </div> |
|
140 | </div> | |
141 | </div> |
|
141 | </div> | |
142 | <script type="text/javascript"> |
|
142 | <script type="text/javascript"> | |
143 |
|
|
143 | YAHOO.util.Event.onDOMReady(function(){ | |
144 |
|
|
144 | var D = YAHOO.util.Dom; | |
145 |
|
|
145 | var E = YAHOO.util.Event; | |
146 |
|
146 | |||
147 |
|
|
147 | //definition of containers ID's | |
148 |
|
|
148 | var available_container = 'available_members'; | |
149 |
|
|
149 | var selected_container = 'users_group_members'; | |
150 |
|
150 | |||
151 |
|
|
151 | //form containing containers id | |
152 |
|
|
152 | var form_id = 'edit_users_group'; | |
153 |
|
153 | |||
154 |
|
|
154 | //temp container for selected storage. | |
155 |
|
|
155 | var cache = new Array(); | |
156 |
|
|
156 | var av_cache = new Array(); | |
157 |
|
|
157 | var c = D.get(selected_container); | |
158 |
|
|
158 | var ac = D.get(available_container); | |
159 |
|
159 | |||
160 |
|
|
160 | //get only selected options for further fullfilment | |
161 |
|
|
161 | for(var i = 0;node =c.options[i];i++){ | |
162 |
|
|
162 | if(node.selected){ | |
163 |
|
|
163 | //push selected to my temp storage left overs :) | |
164 |
|
|
164 | cache.push(node); | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | //clear 'selected' select |
|
|||
169 | //c.options.length = 0; |
|
|||
170 |
|
||||
171 | //fill it with remembered options |
|
|||
172 | //for(var i = 0;node = cache[i];i++){ |
|
|||
173 | // c.options[i]=new Option(node.text, node.value, false, false); |
|
|||
174 | //} |
|
|||
175 |
|
||||
176 |
|
||||
177 |
|
|
168 | //get all available options to cache | |
178 |
|
|
169 | for(var i = 0;node =ac.options[i];i++){ | |
179 |
|
|
170 | //push selected to my temp storage left overs :) | |
180 |
|
|
171 | av_cache.push(node); | |
181 | } |
|
172 | } | |
182 |
|
173 | |||
183 |
|
|
174 | //fill available only with those not in choosen | |
184 |
|
|
175 | ac.options.length=0; | |
185 |
|
|
176 | tmp_cache = new Array(); | |
186 |
|
177 | |||
187 |
|
|
178 | for(var i = 0;node = av_cache[i];i++){ | |
188 |
|
|
179 | var add = true; | |
189 |
|
|
180 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
190 |
|
|
181 | if(node.value == node_2.value){ | |
191 |
|
|
182 | add=false; | |
192 |
|
|
183 | break; | |
193 |
|
|
184 | } | |
194 | } |
|
185 | } | |
195 |
|
|
186 | if(add){ | |
196 |
|
|
187 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
197 | } |
|
188 | } | |
198 | } |
|
189 | } | |
199 |
|
190 | |||
200 |
|
|
191 | for(var i = 0;node = tmp_cache[i];i++){ | |
201 |
|
|
192 | ac.options[i] = node; | |
202 | } |
|
193 | } | |
203 |
|
194 | |||
204 |
|
|
195 | function prompts_action_callback(e){ | |
205 |
|
196 | |||
206 |
|
|
197 | var choosen = D.get(selected_container); | |
207 |
|
|
198 | var available = D.get(available_container); | |
208 |
|
199 | |||
209 |
|
|
200 | //get checked and unchecked options from field | |
210 |
|
|
201 | function get_checked(from_field){ | |
211 |
|
|
202 | //temp container for storage. | |
212 |
|
|
203 | var sel_cache = new Array(); | |
213 |
|
|
204 | var oth_cache = new Array(); | |
214 |
|
205 | |||
215 |
|
|
206 | for(var i = 0;node = from_field.options[i];i++){ | |
216 |
|
|
207 | if(node.selected){ | |
217 |
|
|
208 | //push selected fields :) | |
218 |
|
|
209 | sel_cache.push(node); | |
219 |
|
|
210 | } | |
220 |
|
|
211 | else{ | |
221 |
|
|
212 | oth_cache.push(node) | |
222 |
|
|
213 | } | |
223 |
|
|
214 | } | |
224 |
|
215 | |||
225 |
|
|
216 | return [sel_cache,oth_cache] | |
226 | } |
|
217 | } | |
227 |
|
218 | |||
228 |
|
|
219 | //fill the field with given options | |
229 |
|
|
220 | function fill_with(field,options){ | |
230 |
|
|
221 | //clear firtst | |
231 |
|
|
222 | field.options.length=0; | |
232 |
|
|
223 | for(var i = 0;node = options[i];i++){ | |
233 |
|
|
224 | field.options[i]=new Option(node.text, node.value, | |
234 |
|
|
225 | false, false); | |
235 |
|
|
226 | } | |
236 |
|
227 | |||
237 | } |
|
228 | } | |
238 |
|
|
229 | //adds to current field | |
239 |
|
|
230 | function add_to(field,options){ | |
240 |
|
|
231 | for(var i = 0;node = options[i];i++){ | |
241 |
|
|
232 | field.appendChild(new Option(node.text, node.value, | |
242 |
|
|
233 | false, false)); | |
243 |
|
|
234 | } | |
244 | } |
|
235 | } | |
245 |
|
236 | |||
246 |
|
|
237 | // add action | |
247 |
|
|
238 | if (this.id=='add_element'){ | |
248 |
|
|
239 | var c = get_checked(available); | |
249 |
|
|
240 | add_to(choosen,c[0]); | |
250 |
|
|
241 | fill_with(available,c[1]); | |
251 | } |
|
242 | } | |
252 |
|
|
243 | // remove action | |
253 |
|
|
244 | if (this.id=='remove_element'){ | |
254 |
|
|
245 | var c = get_checked(choosen); | |
255 |
|
|
246 | add_to(available,c[0]); | |
256 |
|
|
247 | fill_with(choosen,c[1]); | |
257 | } |
|
248 | } | |
258 |
|
|
249 | // add all elements | |
259 |
|
|
250 | if(this.id=='add_all_elements'){ | |
260 |
|
|
251 | for(var i=0; node = available.options[i];i++){ | |
261 |
|
|
252 | choosen.appendChild(new Option(node.text, | |
262 |
|
|
253 | node.value, false, false)); | |
263 |
|
|
254 | } | |
264 |
|
|
255 | available.options.length = 0; | |
265 | } |
|
256 | } | |
266 |
|
|
257 | //remove all elements | |
267 |
|
|
258 | if(this.id=='remove_all_elements'){ | |
268 |
|
|
259 | for(var i=0; node = choosen.options[i];i++){ | |
269 |
|
|
260 | available.appendChild(new Option(node.text, | |
270 |
|
|
261 | node.value, false, false)); | |
271 |
|
|
262 | } | |
272 |
|
|
263 | choosen.options.length = 0; | |
273 | } |
|
264 | } | |
274 |
|
265 | |||
275 | } |
|
266 | } | |
276 |
|
267 | |||
277 |
|
||||
278 |
|
|
268 | E.addListener(['add_element','remove_element', | |
279 |
|
|
269 | 'add_all_elements','remove_all_elements'],'click', | |
280 |
|
|
270 | prompts_action_callback) | |
281 |
|
271 | |||
282 |
|
|
272 | E.addListener(form_id,'submit',function(){ | |
283 |
|
|
273 | var choosen = D.get(selected_container); | |
284 |
|
|
274 | for (var i = 0; i < choosen.options.length; i++) { | |
285 |
|
|
275 | choosen.options[i].selected = 'selected'; | |
286 | } |
|
276 | } | |
287 | }) |
|
277 | }); | |
288 | }); |
|
278 | }); | |
289 | </script> |
|
279 | </script> | |
290 | </%def> |
|
280 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now