Mercurial > kallithea
annotate rhodecode/controllers/bookmarks.py @ 3852:eae62e28343e beta
handle case of rewrite without an gistid in nginx example
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 12 May 2013 17:19:21 +0200 |
parents | b950b884ab87 |
children | ffd45b185016 |
rev | line source |
---|---|
1748
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.controllers.bookmarks |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 Bookmarks controller for rhodecode |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: Dec 1, 2011 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
10 :copyright: (C) 2011-2012 Marcin Kuzminski <marcin@python-works.com> |
1748
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import logging |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 from pylons import tmpl_context as c |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 from rhodecode.lib.base import BaseRepoController, render |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 from rhodecode.lib.compat import OrderedDict |
1754
d0effbe1acb1
banned git-repos to use bookmarks views
Marcin Kuzminski <marcin@python-works.com>
parents:
1748
diff
changeset
|
32 from webob.exc import HTTPNotFound |
1748
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 log = logging.getLogger(__name__) |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 class BookmarksController(BaseRepoController): |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 |
3749
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
39 def __before__(self): |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
40 super(BookmarksController, self).__before__() |
b950b884ab87
auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
41 |
1748
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 @LoginRequired() |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 'repository.admin') |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 def index(self): |
1754
d0effbe1acb1
banned git-repos to use bookmarks views
Marcin Kuzminski <marcin@python-works.com>
parents:
1748
diff
changeset
|
46 if c.rhodecode_repo.alias != 'hg': |
d0effbe1acb1
banned git-repos to use bookmarks views
Marcin Kuzminski <marcin@python-works.com>
parents:
1748
diff
changeset
|
47 raise HTTPNotFound() |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1754
diff
changeset
|
48 |
1748
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 c.repo_bookmarks = OrderedDict() |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 bookmarks = [(name, c.rhodecode_repo.get_changeset(hash_)) for \ |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 name, hash_ in c.rhodecode_repo._repo._bookmarks.items()] |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 ordered_tags = sorted(bookmarks, key=lambda x: x[1].date, reverse=True) |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 for name, cs_book in ordered_tags: |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 c.repo_bookmarks[name] = cs_book |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 |
a3ee2611e6e8
implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 return render('bookmarks/bookmarks.html') |