Show More
@@ -22,14 +22,19 b' class BaseController(WSGIController):' | |||
|
22 | 22 | c.backends = BACKENDS.keys() |
|
23 | 23 | |
|
24 | 24 | if c.repo_name: |
|
25 |
|
|
|
25 | scm_model = ScmModel() | |
|
26 | cached_repo = scm_model.get(c.repo_name) | |
|
26 | 27 | |
|
27 | 28 | if cached_repo: |
|
28 | 29 | c.repository_tags = cached_repo.tags |
|
29 | 30 | c.repository_branches = cached_repo.branches |
|
31 | c.repository_followers = scm_model.get_followers(cached_repo.dbrepo.repo_id) | |
|
32 | c.repository_forks = scm_model.get_forks(cached_repo.dbrepo.repo_id) | |
|
30 | 33 | else: |
|
31 | 34 | c.repository_tags = {} |
|
32 | 35 | c.repository_branches = {} |
|
36 | c.repository_followers = 0 | |
|
37 | c.repository_forks = 0 | |
|
33 | 38 | |
|
34 | 39 | self.sa = meta.Session() |
|
35 | 40 |
@@ -52,8 +52,8 b' class UserTemp(object):' | |||
|
52 | 52 | class RepoTemp(object): |
|
53 | 53 | def __init__(self, repo_id): |
|
54 | 54 | self.repo_id = repo_id |
|
55 | ||
|
56 | ||
|
55 | ||
|
56 | ||
|
57 | 57 | class ScmModel(object): |
|
58 | 58 | """ |
|
59 | 59 | Mercurial Model |
@@ -236,13 +236,13 b' class ScmModel(object):' | |||
|
236 | 236 | .filter(UserFollowing.user_id == user_id).scalar() |
|
237 | 237 | |
|
238 | 238 | if f is not None: |
|
239 | ||
|
239 | ||
|
240 | 240 | try: |
|
241 | 241 | self.sa.delete(f) |
|
242 | 242 | self.sa.commit() |
|
243 | 243 | action_logger(UserTemp(user_id), |
|
244 | 244 | 'stopped_following_repo', |
|
245 |
RepoTemp(follow_repo_id)) |
|
|
245 | RepoTemp(follow_repo_id)) | |
|
246 | 246 | return |
|
247 | 247 | except: |
|
248 | 248 | log.error(traceback.format_exc()) |
@@ -258,7 +258,7 b' class ScmModel(object):' | |||
|
258 | 258 | self.sa.commit() |
|
259 | 259 | action_logger(UserTemp(user_id), |
|
260 | 260 | 'started_following_repo', |
|
261 |
RepoTemp(follow_repo_id)) |
|
|
261 | RepoTemp(follow_repo_id)) | |
|
262 | 262 | except: |
|
263 | 263 | log.error(traceback.format_exc()) |
|
264 | 264 | self.sa.rollback() |
@@ -310,6 +310,13 b' class ScmModel(object):' | |||
|
310 | 310 | |
|
311 | 311 | return f is not None |
|
312 | 312 | |
|
313 | def get_followers(self, repo_id): | |
|
314 | return self.sa.query(UserFollowing)\ | |
|
315 | .filter(UserFollowing.follows_repo_id == repo_id).count() | |
|
316 | ||
|
317 | def get_forks(self, repo_id): | |
|
318 | return self.sa.query(Repository)\ | |
|
319 | .filter(Repository.fork_id == repo_id).count() | |
|
313 | 320 | |
|
314 | 321 | def _should_invalidate(self, repo_name): |
|
315 | 322 | """ |
@@ -302,6 +302,10 b' background:#369 url("../../images/quick_' | |||
|
302 | 302 | padding:0; |
|
303 | 303 | } |
|
304 | 304 | |
|
305 | #header #header-inner #quick li span.short { | |
|
306 | padding:9px 6px 8px 6px; | |
|
307 | } | |
|
308 | ||
|
305 | 309 | #header #header-inner #quick li span { |
|
306 | 310 | top:0; |
|
307 | 311 | right:0; |
@@ -328,6 +332,15 b' border-right:1px solid #2e5c89;' | |||
|
328 | 332 | padding:8px 8px 4px; |
|
329 | 333 | } |
|
330 | 334 | |
|
335 | #header #header-inner #quick li span.icon_short { | |
|
336 | top:0; | |
|
337 | left:0; | |
|
338 | border-left:none; | |
|
339 | background:url("../../images/quick_l.png") no-repeat top left; | |
|
340 | border-right:1px solid #2e5c89; | |
|
341 | padding:9px 4px 4px; | |
|
342 | } | |
|
343 | ||
|
331 | 344 | #header #header-inner #quick li a:hover { |
|
332 | 345 | background:#4e4e4e url("../../images/quick_l_selected.png") no-repeat top left; |
|
333 | 346 | } |
@@ -337,12 +350,13 b' border-left:1px solid #545454;' | |||
|
337 | 350 | background:url("../../images/quick_r_selected.png") no-repeat top right; |
|
338 | 351 | } |
|
339 | 352 | |
|
340 | #header #header-inner #quick li a:hover span.icon { | |
|
353 | #header #header-inner #quick li a:hover span.icon,#header #header-inner #quick li a:hover span.icon_short { | |
|
341 | 354 | border-left:none; |
|
342 | 355 | border-right:1px solid #464646; |
|
343 | 356 | background:url("../../images/quick_l_selected.png") no-repeat top left; |
|
344 | 357 | } |
|
345 | 358 | |
|
359 | ||
|
346 | 360 | #header #header-inner #quick ul { |
|
347 | 361 | top:29px; |
|
348 | 362 | right:0; |
@@ -212,19 +212,30 b'' | |||
|
212 | 212 | <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li> |
|
213 | 213 | </ul> |
|
214 | 214 | </li> |
|
215 |
%endif |
|
|
215 | %endif | |
|
216 | 216 | |
|
217 | ||
|
218 | ## %if h.HasRepoPermissionAll('repository.admin')(c.repo_name): | |
|
219 | ## <li class="last"> | |
|
220 | ## ${h.link_to(_('delete'),'#',class_='delete')} | |
|
221 | ## ${h.form(url('repo_settings_delete', repo_name=c.repo_name),method='delete')} | |
|
222 | ## ${h.submit('remove_%s' % c.repo_name,'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")} | |
|
223 | ## ${h.end_form()} | |
|
224 | ## </li> | |
|
225 | ## %endif | |
|
226 | 217 | </ul> |
|
227 | 218 | </li> |
|
219 | ||
|
220 | <li> | |
|
221 | <a title="${_('Followers')}" href="#"> | |
|
222 | <span class="icon_short"> | |
|
223 | <img src="/images/icons/heart.png" alt="${_('Followers')}" /> | |
|
224 | </span> | |
|
225 | <span class="short">${c.repository_followers}</span> | |
|
226 | </a> | |
|
227 | </li> | |
|
228 | <li> | |
|
229 | <a title="${_('Forks')}" href="#"> | |
|
230 | <span class="icon_short"> | |
|
231 | <img src="/images/icons/arrow_divide.png" alt="${_('Forks')}" /> | |
|
232 | </span> | |
|
233 | <span class="short">${c.repository_forks}</span> | |
|
234 | </a> | |
|
235 | </li> | |
|
236 | ||
|
237 | ||
|
238 | ||
|
228 | 239 | </ul> |
|
229 | 240 | %else: |
|
230 | 241 | ##ROOT MENU |
General Comments 0
You need to be logged in to leave comments.
Login now