##// END OF EJS Templates
fixed #113 to high permission was required to fork a repository
marcink -
r1054:32dbf759 beta
parent child Browse files
Show More
@@ -1,200 +1,202
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.controllers.settings
4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 Settings controller for rhodecode
7 7
8 8 :created_on: Jun 30, 2010
9 9 :author: marcink
10 10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 11 :license: GPLv3, see COPYING for more details.
12 12 """
13 13 # This program is free software; you can redistribute it and/or
14 14 # modify it under the terms of the GNU General Public License
15 15 # as published by the Free Software Foundation; version 2
16 16 # of the License or (at your opinion) any later version of the license.
17 17 #
18 18 # This program is distributed in the hope that it will be useful,
19 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 21 # GNU General Public License for more details.
22 22 #
23 23 # You should have received a copy of the GNU General Public License
24 24 # along with this program; if not, write to the Free Software
25 25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 26 # MA 02110-1301, USA.
27 27
28 28 import logging
29 29 import traceback
30 30
31 31 import formencode
32 32
33 33 from pylons import tmpl_context as c, request, url
34 34 from pylons.controllers.util import redirect
35 35 from pylons.i18n.translation import _
36 36
37 37 import rhodecode.lib.helpers as h
38 38 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAllDecorator
39 39 from rhodecode.lib.base import BaseRepoController, render
40 40 from rhodecode.lib.utils import invalidate_cache, action_logger
41 41 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
42 42 from rhodecode.model.repo import RepoModel
43 43 from rhodecode.model.db import User
44 44
45 45 log = logging.getLogger(__name__)
46 46
47 47 class SettingsController(BaseRepoController):
48 48
49 49 @LoginRequired()
50 @HasRepoPermissionAllDecorator('repository.admin')
51 50 def __before__(self):
52 51 super(SettingsController, self).__before__()
53 52
53 @HasRepoPermissionAllDecorator('repository.admin')
54 54 def index(self, repo_name):
55 55 repo_model = RepoModel()
56 56 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
57 57 if not repo:
58 58 h.flash(_('%s repository is not mapped to db perhaps'
59 59 ' it was created or renamed from the file system'
60 60 ' please run the application again'
61 61 ' in order to rescan repositories') % repo_name,
62 62 category='error')
63 63
64 64 return redirect(url('home'))
65 65
66 66 c.users_array = repo_model.get_users_js()
67 67 c.users_groups_array = repo_model.get_users_groups_js()
68 68
69 69 defaults = c.repo_info.get_dict()
70 70
71 71 #fill owner
72 72 if c.repo_info.user:
73 73 defaults.update({'user':c.repo_info.user.username})
74 74 else:
75 75 replacement_user = self.sa.query(User)\
76 76 .filter(User.admin == True).first().username
77 77 defaults.update({'user':replacement_user})
78 78
79 79 #fill repository users
80 80 for p in c.repo_info.repo_to_perm:
81 81 defaults.update({'u_perm_%s' % p.user.username:
82 82 p.permission.permission_name})
83 83
84 84 #fill repository groups
85 85 for p in c.repo_info.users_group_to_perm:
86 86 defaults.update({'g_perm_%s' % p.users_group.users_group_name:
87 87 p.permission.permission_name})
88 88
89 89 return formencode.htmlfill.render(
90 90 render('settings/repo_settings.html'),
91 91 defaults=defaults,
92 92 encoding="UTF-8",
93 93 force_defaults=False
94 94 )
95 95
96 @HasRepoPermissionAllDecorator('repository.admin')
96 97 def update(self, repo_name):
97 98 repo_model = RepoModel()
98 99 changed_name = repo_name
99 100 _form = RepoSettingsForm(edit=True, old_data={'repo_name':repo_name})()
100 101 try:
101 102 form_result = _form.to_python(dict(request.POST))
102 103 repo_model.update(repo_name, form_result)
103 104 invalidate_cache('get_repo_cached_%s' % repo_name)
104 105 h.flash(_('Repository %s updated successfully' % repo_name),
105 106 category='success')
106 107 changed_name = form_result['repo_name']
107 108 action_logger(self.rhodecode_user, 'user_updated_repo',
108 109 changed_name, '', self.sa)
109 110 except formencode.Invalid, errors:
110 111 c.repo_info = repo_model.get_by_repo_name(repo_name)
111 112 c.users_array = repo_model.get_users_js()
112 113 errors.value.update({'user':c.repo_info.user.username})
113 114 return formencode.htmlfill.render(
114 115 render('settings/repo_settings.html'),
115 116 defaults=errors.value,
116 117 errors=errors.error_dict or {},
117 118 prefix_error=False,
118 119 encoding="UTF-8")
119 120 except Exception:
120 121 log.error(traceback.format_exc())
121 122 h.flash(_('error occurred during update of repository %s') \
122 123 % repo_name, category='error')
123 124
124 125 return redirect(url('repo_settings_home', repo_name=changed_name))
125 126
126 127
127
128 @HasRepoPermissionAllDecorator('repository.admin')
128 129 def delete(self, repo_name):
129 130 """DELETE /repos/repo_name: Delete an existing item"""
130 131 # Forms posted to this method should contain a hidden field:
131 132 # <input type="hidden" name="_method" value="DELETE" />
132 133 # Or using helpers:
133 134 # h.form(url('repo_settings_delete', repo_name=ID),
134 135 # method='delete')
135 136 # url('repo_settings_delete', repo_name=ID)
136 137
137 138 repo_model = RepoModel()
138 139 repo = repo_model.get_by_repo_name(repo_name)
139 140 if not repo:
140 141 h.flash(_('%s repository is not mapped to db perhaps'
141 142 ' it was moved or renamed from the filesystem'
142 143 ' please run the application again'
143 144 ' in order to rescan repositories') % repo_name,
144 145 category='error')
145 146
146 147 return redirect(url('home'))
147 148 try:
148 149 action_logger(self.rhodecode_user, 'user_deleted_repo',
149 150 repo_name, '', self.sa)
150 151 repo_model.delete(repo)
151 152 invalidate_cache('get_repo_cached_%s' % repo_name)
152 153 h.flash(_('deleted repository %s') % repo_name, category='success')
153 154 except Exception:
154 155 h.flash(_('An error occurred during deletion of %s') % repo_name,
155 156 category='error')
156 157
157 158 return redirect(url('home'))
158 159
160 @HasRepoPermissionAllDecorator('repository.read')
159 161 def fork(self, repo_name):
160 162 repo_model = RepoModel()
161 163 c.repo_info = repo = repo_model.get_by_repo_name(repo_name)
162 164 if not repo:
163 165 h.flash(_('%s repository is not mapped to db perhaps'
164 166 ' it was created or renamed from the file system'
165 167 ' please run the application again'
166 168 ' in order to rescan repositories') % repo_name,
167 169 category='error')
168 170
169 171 return redirect(url('home'))
170 172
171 173 return render('settings/repo_fork.html')
172 174
173 175
174
176 @HasRepoPermissionAllDecorator('repository.read')
175 177 def fork_create(self, repo_name):
176 178 repo_model = RepoModel()
177 179 c.repo_info = repo_model.get_by_repo_name(repo_name)
178 180 _form = RepoForkForm(old_data={'repo_type':c.repo_info.repo_type})()
179 181 form_result = {}
180 182 try:
181 183 form_result = _form.to_python(dict(request.POST))
182 184 form_result.update({'repo_name':repo_name})
183 185 repo_model.create_fork(form_result, c.rhodecode_user)
184 186 h.flash(_('forked %s repository as %s') \
185 187 % (repo_name, form_result['fork_name']),
186 188 category='success')
187 189 action_logger(self.rhodecode_user,
188 190 'user_forked_repo:%s' % form_result['fork_name'],
189 191 repo_name, '', self.sa)
190 192 except formencode.Invalid, errors:
191 193 c.new_repo = errors.value['fork_name']
192 194 r = render('settings/repo_fork.html')
193 195
194 196 return formencode.htmlfill.render(
195 197 r,
196 198 defaults=errors.value,
197 199 errors=errors.error_dict or {},
198 200 prefix_error=False,
199 201 encoding="UTF-8")
200 202 return redirect(url('home'))
@@ -1,392 +1,392
1 1 ## -*- coding: utf-8 -*-
2 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 3 <html xmlns="http://www.w3.org/1999/xhtml" id="mainhtml">
4 4 <head>
5 5 <title>${next.title()}</title>
6 6 <link rel="icon" href="${h.url('/images/icons/database_gear.png')}" type="image/png" />
7 7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8 8 <meta name="robots" content="index, nofollow"/>
9 9 <!-- stylesheets -->
10 10 ${self.css()}
11 11 <!-- scripts -->
12 12 ${self.js()}
13 13 %if c.ga_code:
14 14 <script type="text/javascript">
15 15
16 16 var _gaq = _gaq || [];
17 17 _gaq.push(['_setAccount', '${c.ga_code}']);
18 18 _gaq.push(['_trackPageview']);
19 19
20 20 (function() {
21 21 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
22 22 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
23 23 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
24 24 })();
25 25
26 26
27 27 </script>
28 28 %endif
29 29 </head>
30 30 <body>
31 31 <!-- header -->
32 32 <div id="header">
33 33 <!-- user -->
34 34 <ul id="logged-user">
35 35 <li class="first">
36 36 <div class="gravatar">
37 37 <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,20)}" />
38 38 </div>
39 39 <div class="account">
40 40 %if c.rhodecode_user.username == 'default':
41 41 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
42 42 ${h.link_to('anonymous',h.url('register'),title='%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname))}
43 43 %else:
44 44 ${h.link_to('anonymous',h.url('#'),title='%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname))}
45 45 %endif
46 46
47 47 %else:
48 48 ${h.link_to(c.rhodecode_user.username,h.url('admin_settings_my_account'),title='%s %s'%(c.rhodecode_user.name,c.rhodecode_user.lastname))}
49 49 %endif
50 50 </div>
51 51 </li>
52 52 <li>
53 53 <a href="${h.url('home')}">${_('Home')}</a>
54 54 </li>
55 55 %if c.rhodecode_user.username != 'default':
56 56 <li>
57 57 <a href="${h.url('journal')}">${_('Journal')}</a>
58 58 ##(${c.unread_journal})</a>
59 59 </li>
60 60 %endif
61 61 %if c.rhodecode_user.username == 'default':
62 62 <li class="last highlight">${h.link_to(u'Login',h.url('login_home'))}</li>
63 63 %else:
64 64 <li class="last highlight">${h.link_to(u'Log Out',h.url('logout_home'))}</li>
65 65 %endif
66 66 </ul>
67 67 <!-- end user -->
68 68 <div id="header-inner" class="title top-left-rounded-corner top-right-rounded-corner">
69 69 <!-- logo -->
70 70 <div id="logo">
71 71 <h1><a href="${h.url('home')}">${c.rhodecode_name}</a></h1>
72 72 </div>
73 73 <!-- end logo -->
74 74 <!-- menu -->
75 75 ${self.page_nav()}
76 76 <!-- quick -->
77 77 </div>
78 78 </div>
79 79 <!-- end header -->
80 80
81 81 <!-- CONTENT -->
82 82 <div id="content">
83 83 <div class="flash_msg">
84 84 <% messages = h.flash.pop_messages() %>
85 85 % if messages:
86 86 <ul id="flash-messages">
87 87 % for message in messages:
88 88 <li class="${message.category}_msg">${message}</li>
89 89 % endfor
90 90 </ul>
91 91 % endif
92 92 </div>
93 93 <div id="main">
94 94 ${next.main()}
95 95 </div>
96 96 </div>
97 97 <!-- END CONTENT -->
98 98
99 99 <!-- footer -->
100 100 <div id="footer">
101 101 <div id="footer-inner" class="title bottom-left-rounded-corner bottom-right-rounded-corner">
102 102 <div>
103 103 <p class="footer-link">${h.link_to(_('Submit a bug'),h.url('bugtracker'))}</p>
104 104 <p class="footer-link">${h.link_to(_('GPL license'),h.url('gpl_license'))}</p>
105 105 <p>RhodeCode ${c.rhodecode_version} &copy; 2010-2011 by Marcin Kuzminski</p>
106 106 </div>
107 107 </div>
108 108 <script type="text/javascript">
109 109 function tooltip_activate(){
110 110 ${h.tooltip.activate()}
111 111 }
112 112 tooltip_activate();
113 113 </script>
114 114 </div>
115 115 <!-- end footer -->
116 116 </body>
117 117
118 118 </html>
119 119
120 120 ### MAKO DEFS ###
121 121 <%def name="page_nav()">
122 122 ${self.menu()}
123 123 </%def>
124 124
125 125 <%def name="menu(current=None)">
126 126 <%
127 127 def is_current(selected):
128 128 if selected == current:
129 129 return h.literal('class="current"')
130 130 %>
131 131 %if current not in ['home','admin']:
132 132 ##REGULAR MENU
133 133 <ul id="quick">
134 134 <!-- repo switcher -->
135 135 <li>
136 136 <a id="repo_switcher" title="${_('Switch repository')}" href="#">
137 137 <span class="icon">
138 138 <img src="${h.url("/images/icons/database.png")}" alt="${_('Products')}" />
139 139 </span>
140 140 <span>&darr;</span>
141 141 </a>
142 142 <ul class="repo_switcher">
143 143 %for repo in c.cached_repo_list:
144 144
145 145 %if repo['dbrepo']['private']:
146 146 <li><img src="${h.url("/images/icons/lock.png")}" alt="${_('Private repository')}" class="repo_switcher_type"/>${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo']['repo_type'])}</li>
147 147 %else:
148 148 <li><img src="${h.url("/images/icons/lock_open.png")}" alt="${_('Public repository')}" class="repo_switcher_type" />${h.link_to(repo['repo'].name,h.url('summary_home',repo_name=repo['repo'].name),class_="%s" % repo['dbrepo']['repo_type'])}</li>
149 149 %endif
150 150 %endfor
151 151 </ul>
152 152 </li>
153 153
154 154 <li ${is_current('summary')}>
155 155 <a title="${_('Summary')}" href="${h.url('summary_home',repo_name=c.repo_name)}">
156 156 <span class="icon">
157 157 <img src="${h.url("/images/icons/clipboard_16.png")}" alt="${_('Summary')}" />
158 158 </span>
159 159 <span>${_('Summary')}</span>
160 160 </a>
161 161 </li>
162 162 ##<li ${is_current('shortlog')}>
163 163 ## <a title="${_('Shortlog')}" href="${h.url('shortlog_home',repo_name=c.repo_name)}">
164 164 ## <span class="icon">
165 165 ## <img src="${h.url("/images/icons/application_view_list.png")}" alt="${_('Shortlog')}" />
166 166 ## </span>
167 167 ## <span>${_('Shortlog')}</span>
168 168 ## </a>
169 169 ##</li>
170 170 <li ${is_current('changelog')}>
171 171 <a title="${_('Changelog')}" href="${h.url('changelog_home',repo_name=c.repo_name)}">
172 172 <span class="icon">
173 173 <img src="${h.url("/images/icons/time.png")}" alt="${_('Changelog')}" />
174 174 </span>
175 175 <span>${_('Changelog')}</span>
176 176 </a>
177 177 </li>
178 178
179 179 <li ${is_current('switch_to')}>
180 180 <a title="${_('Switch to')}" href="#">
181 181 <span class="icon">
182 182 <img src="${h.url("/images/icons/arrow_switch.png")}" alt="${_('Switch to')}" />
183 183 </span>
184 184 <span>${_('Switch to')}</span>
185 185 </a>
186 186 <ul>
187 187 <li>
188 188 ${h.link_to('%s (%s)' % (_('branches'),len(c.rhodecode_repo.branches.values()),),h.url('branches_home',repo_name=c.repo_name),class_='branches childs')}
189 189 <ul>
190 190 %if c.rhodecode_repo.branches.values():
191 191 %for cnt,branch in enumerate(c.rhodecode_repo.branches.items()):
192 192 <li>${h.link_to('%s - %s' % (branch[0],h.short_id(branch[1])),h.url('files_home',repo_name=c.repo_name,revision=branch[1]))}</li>
193 193 %endfor
194 194 %else:
195 195 <li>${h.link_to(_('There are no branches yet'),'#')}</li>
196 196 %endif
197 197 </ul>
198 198 </li>
199 199 <li>
200 200 ${h.link_to('%s (%s)' % (_('tags'),len(c.rhodecode_repo.tags.values()),),h.url('tags_home',repo_name=c.repo_name),class_='tags childs')}
201 201 <ul>
202 202 %if c.rhodecode_repo.tags.values():
203 203 %for cnt,tag in enumerate(c.rhodecode_repo.tags.items()):
204 204 <li>${h.link_to('%s - %s' % (tag[0],h.short_id(tag[1])),h.url('files_home',repo_name=c.repo_name,revision=tag[1]))}</li>
205 205 %endfor
206 206 %else:
207 207 <li>${h.link_to(_('There are no tags yet'),'#')}</li>
208 208 %endif
209 209 </ul>
210 210 </li>
211 211 </ul>
212 212 </li>
213 213 <li ${is_current('files')}>
214 214 <a title="${_('Files')}" href="${h.url('files_home',repo_name=c.repo_name)}">
215 215 <span class="icon">
216 216 <img src="${h.url("/images/icons/file.png")}" alt="${_('Files')}" />
217 217 </span>
218 218 <span>${_('Files')}</span>
219 219 </a>
220 220 </li>
221 221
222 222 <li ${is_current('options')}>
223 223 <a title="${_('Options')}" href="#">
224 224 <span class="icon">
225 225 <img src="${h.url("/images/icons/table_gear.png")}" alt="${_('Admin')}" />
226 226 </span>
227 227 <span>${_('Options')}</span>
228 228 </a>
229 229 <ul>
230 230 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
231 231 %if h.HasPermissionAll('hg.admin')('access settings on repository'):
232 232 <li>${h.link_to(_('settings'),h.url('edit_repo',repo_name=c.repo_name),class_='settings')}</li>
233 233 %else:
234 234 <li>${h.link_to(_('settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li>
235 235 %endif
236 %endif
236 237 <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li>
237 %endif
238 238 <li>${h.link_to(_('search'),h.url('search_repo',search_repo=c.repo_name),class_='search')}</li>
239 239
240 240 %if h.HasPermissionAll('hg.admin')('access admin main page'):
241 241 <li>
242 242 ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')}
243 243 <%def name="admin_menu()">
244 244 <ul>
245 245 <li>${h.link_to(_('journal'),h.url('admin_home'),class_='journal')}</li>
246 246 <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li>
247 247 <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li>
248 248 <li>${h.link_to(_('users groups'),h.url('users_groups'),class_='groups')}</li>
249 249 <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li>
250 250 <li>${h.link_to(_('ldap'),h.url('ldap_home'),class_='ldap')}</li>
251 251 <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li>
252 252 </ul>
253 253 </%def>
254 254
255 255 ${admin_menu()}
256 256 </li>
257 257 %endif
258 258
259 259 </ul>
260 260 </li>
261 261
262 262 <li>
263 263 <a title="${_('Followers')}" href="#">
264 264 <span class="icon_short">
265 265 <img src="${h.url("/images/icons/heart.png")}" alt="${_('Followers')}" />
266 266 </span>
267 267 <span class="short">${c.repository_followers}</span>
268 268 </a>
269 269 </li>
270 270 <li>
271 271 <a title="${_('Forks')}" href="#">
272 272 <span class="icon_short">
273 273 <img src="${h.url("/images/icons/arrow_divide.png")}" alt="${_('Forks')}" />
274 274 </span>
275 275 <span class="short">${c.repository_forks}</span>
276 276 </a>
277 277 </li>
278 278
279 279
280 280
281 281 </ul>
282 282 %else:
283 283 ##ROOT MENU
284 284 <ul id="quick">
285 285 <li>
286 286 <a title="${_('Home')}" href="${h.url('home')}">
287 287 <span class="icon">
288 288 <img src="${h.url("/images/icons/home_16.png")}" alt="${_('Home')}" />
289 289 </span>
290 290 <span>${_('Home')}</span>
291 291 </a>
292 292 </li>
293 293 %if c.rhodecode_user.username != 'default':
294 294 <li>
295 295 <a title="${_('Journal')}" href="${h.url('journal')}">
296 296 <span class="icon">
297 297 <img src="${h.url("/images/icons/book.png")}" alt="${_('Journal')}" />
298 298 </span>
299 299 <span>${_('Journal')}</span>
300 300 </a>
301 301 </li>
302 302 %endif
303 303 <li>
304 304 <a title="${_('Search')}" href="${h.url('search')}">
305 305 <span class="icon">
306 306 <img src="${h.url("/images/icons/search_16.png")}" alt="${_('Search')}" />
307 307 </span>
308 308 <span>${_('Search')}</span>
309 309 </a>
310 310 </li>
311 311
312 312 %if h.HasPermissionAll('hg.admin')('access admin main page'):
313 313 <li ${is_current('admin')}>
314 314 <a title="${_('Admin')}" href="${h.url('admin_home')}">
315 315 <span class="icon">
316 316 <img src="${h.url("/images/icons/cog_edit.png")}" alt="${_('Admin')}" />
317 317 </span>
318 318 <span>${_('Admin')}</span>
319 319 </a>
320 320 ${admin_menu()}
321 321 </li>
322 322 %endif
323 323 </ul>
324 324 %endif
325 325 </%def>
326 326
327 327
328 328 <%def name="css()">
329 329 <link rel="stylesheet" type="text/css" href="${h.url('/css/style.css')}" media="screen" />
330 330 <link rel="stylesheet" type="text/css" href="${h.url('/css/pygments.css')}" />
331 331 <link rel="stylesheet" type="text/css" href="${h.url('/css/diff.css')}" />
332 332 </%def>
333 333
334 334 <%def name="js()">
335 335 ##<script type="text/javascript" src="${h.url('/js/yui/utilities/utilities.js')}"></script>
336 336 ##<script type="text/javascript" src="${h.url('/js/yui/container/container.js')}"></script>
337 337 ##<script type="text/javascript" src="${h.url('/js/yui/datasource/datasource.js')}"></script>
338 338 ##<script type="text/javascript" src="${h.url('/js/yui/autocomplete/autocomplete.js')}"></script>
339 339 ##<script type="text/javascript" src="${h.url('/js/yui/selector/selector-min.js')}"></script>
340 340
341 341 <script type="text/javascript" src="${h.url('/js/yui2a.js')}"></script>
342 342 <!--[if IE]><script language="javascript" type="text/javascript" src="${h.url('/js/excanvas.min.js')}"></script><![endif]-->
343 343 <script type="text/javascript" src="${h.url('/js/yui.flot.js')}"></script>
344 344
345 345 <script type="text/javascript">
346 346 var base_url = "${h.url('toggle_following')}";
347 347 var YUC = YAHOO.util.Connect;
348 348 var YUD = YAHOO.util.Dom;
349 349 var YUE = YAHOO.util.Event;
350 350
351 351 function onSuccess(target){
352 352
353 353 var f = YUD.get(target.id);
354 354 if(f.getAttribute('class')=='follow'){
355 355 f.setAttribute('class','following');
356 356 f.setAttribute('title',"${_('Stop following this repository')}");
357 357 }
358 358 else{
359 359 f.setAttribute('class','follow');
360 360 f.setAttribute('title',"${_('Start following this repository')}");
361 361 }
362 362 }
363 363
364 364 function toggleFollowingUser(fallows_user_id,token){
365 365 args = 'follows_user_id='+fallows_user_id;
366 366 args+= '&amp;auth_token='+token;
367 367 YUC.asyncRequest('POST',base_url,{
368 368 success:function(o){
369 369 onSuccess();
370 370 }
371 371 },args); return false;
372 372 }
373 373
374 374 function toggleFollowingRepo(target,fallows_repo_id,token){
375 375
376 376 args = 'follows_repo_id='+fallows_repo_id;
377 377 args+= '&amp;auth_token='+token;
378 378 YUC.asyncRequest('POST',base_url,{
379 379 success:function(o){
380 380 onSuccess(target);
381 381 }
382 382 },args); return false;
383 383 }
384 384 </script>
385 385
386 386 </%def>
387 387
388 388 <%def name="breadcrumbs()">
389 389 <div class="breadcrumbs">
390 390 ${self.breadcrumbs_links()}
391 391 </div>
392 392 </%def> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now