Mercurial > kallithea
comparison rhodecode/controllers/home.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | 5293d4bbb1ea |
children | 9dd726706178 |
comparison
equal
deleted
inserted
replaced
4115:8b7294a804a0 | 4116:ffd45b185016 |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """ | |
3 rhodecode.controllers.home | |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 | |
6 Home controller for Rhodecode | |
7 | |
8 :created_on: Feb 18, 2010 | |
9 :author: marcink | |
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> | |
11 :license: GPLv3, see COPYING for more details. | |
12 """ | |
13 # This program is free software: you can redistribute it and/or modify | 2 # This program is free software: you can redistribute it and/or modify |
14 # it under the terms of the GNU General Public License as published by | 3 # it under the terms of the GNU General Public License as published by |
15 # the Free Software Foundation, either version 3 of the License, or | 4 # the Free Software Foundation, either version 3 of the License, or |
16 # (at your option) any later version. | 5 # (at your option) any later version. |
17 # | 6 # |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 # GNU General Public License for more details. | 10 # GNU General Public License for more details. |
22 # | 11 # |
23 # You should have received a copy of the GNU General Public License | 12 # You should have received a copy of the GNU General Public License |
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 """ | |
15 rhodecode.controllers.home | |
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
17 | |
18 Home controller for Rhodecode | |
19 | |
20 :created_on: Feb 18, 2010 | |
21 :author: marcink | |
22 :copyright: (c) 2013 RhodeCode GmbH. | |
23 :license: GPLv3, see LICENSE for more details. | |
24 | |
25 """ | |
25 | 26 |
26 import logging | 27 import logging |
27 | 28 |
28 from pylons import tmpl_context as c, request | 29 from pylons import tmpl_context as c, request |
29 from pylons.i18n.translation import _ | 30 from pylons.i18n.translation import _ |
30 from webob.exc import HTTPBadRequest | 31 from webob.exc import HTTPBadRequest |
31 from sqlalchemy.sql.expression import func | 32 from sqlalchemy.sql.expression import func |
32 | 33 |
33 import rhodecode | 34 import rhodecode |
34 from rhodecode.lib import helpers as h | 35 from rhodecode.lib import helpers as h |
36 from rhodecode.lib.utils import jsonify, conditional_cache | |
35 from rhodecode.lib.compat import json | 37 from rhodecode.lib.compat import json |
36 from rhodecode.lib.auth import LoginRequired | 38 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
37 from rhodecode.lib.base import BaseController, render | 39 from rhodecode.lib.base import BaseController, render |
38 from rhodecode.model.db import Repository | 40 from rhodecode.model.db import Repository, RepoGroup |
39 from rhodecode.model.repo import RepoModel | 41 from rhodecode.model.repo import RepoModel |
40 | 42 |
41 | 43 |
42 log = logging.getLogger(__name__) | 44 log = logging.getLogger(__name__) |
43 | 45 |
47 def __before__(self): | 49 def __before__(self): |
48 super(HomeController, self).__before__() | 50 super(HomeController, self).__before__() |
49 | 51 |
50 @LoginRequired() | 52 @LoginRequired() |
51 def index(self): | 53 def index(self): |
52 c.groups = self.scm_model.get_repos_groups() | 54 c.groups = self.scm_model.get_repo_groups() |
53 c.group = None | 55 c.group = None |
54 | 56 |
55 c.repos_list = Repository.query()\ | 57 c.repos_list = Repository.query()\ |
56 .filter(Repository.group_id == None)\ | 58 .filter(Repository.group_id == None)\ |
57 .order_by(func.lower(Repository.repo_name))\ | 59 .order_by(func.lower(Repository.repo_name))\ |
63 c.data = json.dumps(repos_data) | 65 c.data = json.dumps(repos_data) |
64 | 66 |
65 return render('/index.html') | 67 return render('/index.html') |
66 | 68 |
67 @LoginRequired() | 69 @LoginRequired() |
68 def repo_switcher(self): | 70 @jsonify |
71 def repo_switcher_data(self): | |
72 #wrapper for conditional cache | |
73 def _c(): | |
74 log.debug('generating switcher repo/groups list') | |
75 all_repos = Repository.query().order_by(Repository.repo_name).all() | |
76 repo_iter = self.scm_model.get_repos(all_repos, simple=True) | |
77 all_groups = RepoGroup.query().order_by(RepoGroup.group_name).all() | |
78 repo_groups_iter = self.scm_model.get_repo_groups(all_groups) | |
79 | |
80 res = [{ | |
81 'text': _('Groups'), | |
82 'children': [ | |
83 {'id': obj.group_name, 'text': obj.group_name, | |
84 'type': 'group', 'obj': {}} for obj in repo_groups_iter] | |
85 }, { | |
86 'text': _('Repositories'), | |
87 'children': [ | |
88 {'id': obj['name'], 'text': obj['name'], | |
89 'type': 'repo', 'obj': obj['dbrepo']} for obj in repo_iter] | |
90 }] | |
91 | |
92 data = { | |
93 'more': False, | |
94 'results': res | |
95 } | |
96 return data | |
97 | |
69 if request.is_xhr: | 98 if request.is_xhr: |
70 all_repos = Repository.query().order_by(Repository.repo_name).all() | 99 condition = False |
71 c.repos_list = self.scm_model.get_repos(all_repos, | 100 compute = conditional_cache('short_term', 'cache_desc', |
72 sort_key='name_sort', | 101 condition=condition, func=_c) |
73 simple=True) | 102 return compute() |
74 return render('/repo_switcher_list.html') | |
75 else: | 103 else: |
76 raise HTTPBadRequest() | 104 raise HTTPBadRequest() |
77 | 105 |
78 @LoginRequired() | 106 @LoginRequired() |
107 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', | |
108 'repository.admin') | |
79 def branch_tag_switcher(self, repo_name): | 109 def branch_tag_switcher(self, repo_name): |
80 if request.is_xhr: | 110 if request.is_xhr: |
81 c.rhodecode_db_repo = Repository.get_by_repo_name(c.repo_name) | 111 c.rhodecode_db_repo = Repository.get_by_repo_name(repo_name) |
82 if c.rhodecode_db_repo: | 112 if c.rhodecode_db_repo: |
83 c.rhodecode_repo = c.rhodecode_db_repo.scm_instance | 113 c.rhodecode_repo = c.rhodecode_db_repo.scm_instance |
84 return render('/switch_to_list.html') | 114 return render('/switch_to_list.html') |
85 raise HTTPBadRequest() | 115 raise HTTPBadRequest() |
116 | |
117 @LoginRequired() | |
118 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', | |
119 'repository.admin') | |
120 @jsonify | |
121 def repo_refs_data(self, repo_name): | |
122 repo = Repository.get_by_repo_name(repo_name).scm_instance | |
123 res = [] | |
124 _branches = repo.branches.items() | |
125 if _branches: | |
126 res.append({ | |
127 'text': _('Branch'), | |
128 'children': [{'id': rev, 'text': name, 'type': 'branch'} for name, rev in _branches] | |
129 }) | |
130 _tags = repo.tags.items() | |
131 if _tags: | |
132 res.append({ | |
133 'text': _('Tag'), | |
134 'children': [{'id': rev, 'text': name, 'type': 'tag'} for name, rev in _tags] | |
135 }) | |
136 _bookmarks = repo.bookmarks.items() | |
137 if _bookmarks: | |
138 res.append({ | |
139 'text': _('Bookmark'), | |
140 'children': [{'id': rev, 'text': name, 'type': 'book'} for name, rev in _bookmarks] | |
141 }) | |
142 data = { | |
143 'more': False, | |
144 'results': res | |
145 } | |
146 return data |