Mercurial > kallithea
annotate rhodecode/controllers/pullrequests.py @ 2244:77e376fdc4c6 codereview
pull requests draft UI
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 08 May 2012 02:04:28 +0200 |
parents | |
children | b262e349a7a5 |
rev | line source |
---|---|
2244
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.controllers.pullrequests |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 pull requests controller for rhodecode for initializing pull requests |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: May 7, 2012 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import logging |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import traceback |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 from pylons import request, response, session, tmpl_context as c, url |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 from pylons.controllers.util import abort, redirect |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 from pylons.i18n.translation import _ |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from rhodecode.lib.base import BaseRepoController, render |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 from webob.exc import HTTPNotFound |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 log = logging.getLogger(__name__) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 class PullrequestsController(BaseRepoController): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 @LoginRequired() |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 'repository.admin') |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 def __before__(self): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 super(PullrequestsController, self).__before__() |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 def _get_repo_refs(self,repo): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 hist_l = [] |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 branches_group = ([(k, k) for k in repo.branches.keys()], _("Branches")) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 bookmarks_group = ([(k, k) for k in repo.bookmarks.keys()], _("Bookmarks")) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 tags_group = ([(k, k) for k in repo.tags.keys()], _("Tags")) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 hist_l.append(bookmarks_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 hist_l.append(branches_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 hist_l.append(tags_group) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 return hist_l |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 def index(self): |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 c.org_refs = self._get_repo_refs(c.rhodecode_repo) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 c.sources = [] |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 c.sources.append('%s/%s' % (c.rhodecode_db_repo.user.username, |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 c.repo_name)) |
77e376fdc4c6
pull requests draft UI
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 return render('/pullrequests/pullrequest.html') |