annotate kallithea/controllers/bookmarks.py @ 4196:06e49be38d78 kallithea-2.2.5-rebrand

Rename rhodecode_repo to db_repo_scm_instance
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:05:00 -0400
parents d1addaf7a91e
children ad38f9f93b3b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 # 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
3 # 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
4 # 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
5 # (at your option) any later version.
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 #
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # 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
8 # 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
9 # 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
10 # GNU General Public License for more details.
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 #
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # 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
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
14 """
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
15 kallithea.controllers.bookmarks
4116
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
17
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
18 Bookmarks controller for rhodecode
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
19
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
20 :created_on: Dec 1, 2011
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
21 :author: marcink
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
22 :copyright: (c) 2013 RhodeCode GmbH.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
23 :license: GPLv3, see LICENSE for more details.
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
24 """
ffd45b185016 Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 3749
diff changeset
25
1748
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 import logging
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 from pylons import tmpl_context as c
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
30 from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
31 from kallithea.lib.base import BaseRepoController, render
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
32 from kallithea.lib.compat import OrderedDict
1754
d0effbe1acb1 banned git-repos to use bookmarks views
Marcin Kuzminski <marcin@python-works.com>
parents: 1748
diff changeset
33 from webob.exc import HTTPNotFound
1748
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 log = logging.getLogger(__name__)
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
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 class BookmarksController(BaseRepoController):
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39
3749
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
40 def __before__(self):
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
41 super(BookmarksController, self).__before__()
b950b884ab87 auth decorators are not used anymore on __before__
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
42
1748
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 @LoginRequired()
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 'repository.admin')
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 def index(self):
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
47 if c.db_repo_scm_instance.alias != 'hg':
1754
d0effbe1acb1 banned git-repos to use bookmarks views
Marcin Kuzminski <marcin@python-works.com>
parents: 1748
diff changeset
48 raise HTTPNotFound()
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1754
diff changeset
49
1748
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 c.repo_bookmarks = OrderedDict()
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51
4196
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
52 bookmarks = [(name, c.db_repo_scm_instance.get_changeset(hash_)) for \
06e49be38d78 Rename rhodecode_repo to db_repo_scm_instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4187
diff changeset
53 name, hash_ in c.db_repo_scm_instance._repo._bookmarks.items()]
1748
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 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
55 for name, cs_book in ordered_tags:
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 c.repo_bookmarks[name] = cs_book
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
a3ee2611e6e8 implements #135 bookmark support for UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 return render('bookmarks/bookmarks.html')