Mercurial > kallithea
comparison rhodecode/controllers/summary.py @ 1514:87ec80c280bb beta
fixed issues with python2.5
added compat module to rhodecode to have one point of fetching backward incompatible libs.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 07 Oct 2011 02:51:18 +0200 |
parents | 182f5bd3b49d |
children | da8f1d1b22de df59c0503636 |
comparison
equal
deleted
inserted
replaced
1511:a5981def1961 | 1514:87ec80c280bb |
---|---|
37 from rhodecode.model.repo import RepoModel | 37 from rhodecode.model.repo import RepoModel |
38 | 38 |
39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | 39 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
40 from rhodecode.lib.base import BaseRepoController, render | 40 from rhodecode.lib.base import BaseRepoController, render |
41 from rhodecode.lib.utils import EmptyChangeset | 41 from rhodecode.lib.utils import EmptyChangeset |
42 from rhodecode.lib.odict import OrderedDict | |
43 | 42 |
44 from rhodecode.lib.celerylib import run_task | 43 from rhodecode.lib.celerylib import run_task |
45 from rhodecode.lib.celerylib.tasks import get_commits_stats, \ | 44 from rhodecode.lib.celerylib.tasks import get_commits_stats, \ |
46 LANGUAGES_EXTENSIONS_MAP | 45 LANGUAGES_EXTENSIONS_MAP |
47 from rhodecode.lib.helpers import RepoPage | 46 from rhodecode.lib.helpers import RepoPage |
47 from rhodecode.lib.compat import json, OrderedDict | |
48 | 48 |
49 try: | |
50 import json | |
51 except ImportError: | |
52 #python 2.5 compatibility | |
53 import simplejson as json | |
54 | |
55 log = logging.getLogger(__name__) | 49 log = logging.getLogger(__name__) |
56 | 50 |
57 | 51 |
58 class SummaryController(BaseRepoController): | 52 class SummaryController(BaseRepoController): |
59 | 53 |
137 if stats and stats.languages: | 131 if stats and stats.languages: |
138 c.no_data = False is dbrepo.enable_statistics | 132 c.no_data = False is dbrepo.enable_statistics |
139 lang_stats_d = json.loads(stats.languages) | 133 lang_stats_d = json.loads(stats.languages) |
140 c.commit_data = stats.commit_activity | 134 c.commit_data = stats.commit_activity |
141 c.overview_data = stats.commit_activity_combined | 135 c.overview_data = stats.commit_activity_combined |
142 | 136 |
143 lang_stats = ((x, {"count": y, | 137 lang_stats = ((x, {"count": y, |
144 "desc": LANGUAGES_EXTENSIONS_MAP.get(x)}) | 138 "desc": LANGUAGES_EXTENSIONS_MAP.get(x)}) |
145 for x, y in lang_stats_d.items()) | 139 for x, y in lang_stats_d.items()) |
146 | 140 |
147 c.trending_languages = json.dumps(OrderedDict( | 141 c.trending_languages = json.dumps(OrderedDict( |
160 else: | 154 else: |
161 c.commit_data = json.dumps({}) | 155 c.commit_data = json.dumps({}) |
162 c.overview_data = json.dumps([[ts_min_y, 0], [ts_max_y, 10]]) | 156 c.overview_data = json.dumps([[ts_min_y, 0], [ts_max_y, 10]]) |
163 c.trending_languages = json.dumps({}) | 157 c.trending_languages = json.dumps({}) |
164 c.no_data = True | 158 c.no_data = True |
165 | 159 |
166 c.enable_downloads = dbrepo.enable_downloads | 160 c.enable_downloads = dbrepo.enable_downloads |
167 if c.enable_downloads: | 161 if c.enable_downloads: |
168 c.download_options = self._get_download_links(c.rhodecode_repo) | 162 c.download_options = self._get_download_links(c.rhodecode_repo) |
169 | 163 |
170 return render('summary/summary.html') | 164 return render('summary/summary.html') |