Show More
@@ -141,6 +141,20 b' class ReposController(BaseController):' | |||||
141 |
|
141 | |||
142 | except formencode.Invalid, errors: |
|
142 | except formencode.Invalid, errors: | |
143 | c.repo_info = repo_model.get_by_repo_name(repo_name) |
|
143 | c.repo_info = repo_model.get_by_repo_name(repo_name) | |
|
144 | if c.repo_info.stats: | |||
|
145 | last_rev = c.repo_info.stats.stat_on_revision | |||
|
146 | else: | |||
|
147 | last_rev = 0 | |||
|
148 | c.stats_revision = last_rev | |||
|
149 | r = ScmModel().get(repo_name) | |||
|
150 | c.repo_last_rev = r.revisions[-1] if r.revisions else 0 | |||
|
151 | ||||
|
152 | if last_rev == 0: | |||
|
153 | c.stats_percentage = 0 | |||
|
154 | else: | |||
|
155 | c.stats_percentage = '%.2f' % ((float((last_rev)) / | |||
|
156 | c.repo_last_rev) * 100) | |||
|
157 | ||||
144 | c.users_array = repo_model.get_users_js() |
|
158 | c.users_array = repo_model.get_users_js() | |
145 | errors.value.update({'user':c.repo_info.user.username}) |
|
159 | errors.value.update({'user':c.repo_info.user.username}) | |
146 | return htmlfill.render( |
|
160 | return htmlfill.render( | |
@@ -245,9 +259,9 b' class ReposController(BaseController):' | |||||
245 | """GET /repos/repo_name/edit: Form to edit an existing item""" |
|
259 | """GET /repos/repo_name/edit: Form to edit an existing item""" | |
246 | # url('edit_repo', repo_name=ID) |
|
260 | # url('edit_repo', repo_name=ID) | |
247 | repo_model = RepoModel() |
|
261 | repo_model = RepoModel() | |
248 |
c.repo_info |
|
262 | c.repo_info = repo_model.get_by_repo_name(repo_name) | |
249 | if repo.stats: |
|
263 | if c.repo_info.stats: | |
250 | last_rev = repo.stats.stat_on_revision |
|
264 | last_rev = c.repo_info.stats.stat_on_revision | |
251 | else: |
|
265 | else: | |
252 | last_rev = 0 |
|
266 | last_rev = 0 | |
253 | c.stats_revision = last_rev |
|
267 | c.stats_revision = last_rev | |
@@ -257,10 +271,11 b' class ReposController(BaseController):' | |||||
257 | if last_rev == 0: |
|
271 | if last_rev == 0: | |
258 | c.stats_percentage = 0 |
|
272 | c.stats_percentage = 0 | |
259 | else: |
|
273 | else: | |
260 |
c.stats_percentage = '%.2f' % ((float((last_rev)) / |
|
274 | c.stats_percentage = '%.2f' % ((float((last_rev)) / | |
|
275 | c.repo_last_rev) * 100) | |||
261 |
|
276 | |||
262 |
|
277 | |||
263 | if not repo: |
|
278 | if not c.repo_info: | |
264 | h.flash(_('%s repository is not mapped to db perhaps' |
|
279 | h.flash(_('%s repository is not mapped to db perhaps' | |
265 | ' it was created or renamed from the filesystem' |
|
280 | ' it was created or renamed from the filesystem' | |
266 | ' please run the application again' |
|
281 | ' please run the application again' |
@@ -4,6 +4,7 b'' | |||||
4 | ~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | Summary controller for Rhodecode |
|
6 | Summary controller for Rhodecode | |
|
7 | ||||
7 | :created_on: Apr 18, 2010 |
|
8 | :created_on: Apr 18, 2010 | |
8 | :author: marcink |
|
9 | :author: marcink | |
9 | :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
@@ -114,7 +115,7 b' class SummaryController(BaseController):' | |||||
114 | c.no_data_msg = _('No data loaded yet') |
|
115 | c.no_data_msg = _('No data loaded yet') | |
115 | run_task(get_commits_stats, c.repo_info.name, ts_min_y, ts_max_y) |
|
116 | run_task(get_commits_stats, c.repo_info.name, ts_min_y, ts_max_y) | |
116 | else: |
|
117 | else: | |
117 | c.no_data_msg = _('Statistics are disabled for this repository') |
|
118 | c.no_data_msg = _('Statistics update are disabled for this repository') | |
118 | c.ts_min = ts_min_m |
|
119 | c.ts_min = ts_min_m | |
119 | c.ts_max = ts_max_y |
|
120 | c.ts_max = ts_max_y | |
120 |
|
121 | |||
@@ -124,7 +125,7 b' class SummaryController(BaseController):' | |||||
124 |
|
125 | |||
125 |
|
126 | |||
126 | if stats and stats.languages: |
|
127 | if stats and stats.languages: | |
127 | c.no_data = False |
|
128 | c.no_data = False is c.repo_info.dbrepo.enable_statistics | |
128 | lang_stats = json.loads(stats.languages) |
|
129 | lang_stats = json.loads(stats.languages) | |
129 | c.commit_data = stats.commit_activity |
|
130 | c.commit_data = stats.commit_activity | |
130 | c.overview_data = stats.commit_activity_combined |
|
131 | c.overview_data = stats.commit_activity_combined |
@@ -75,38 +75,36 b' class RepoModel(BaseModel):' | |||||
75 |
|
75 | |||
76 | def update(self, repo_name, form_data): |
|
76 | def update(self, repo_name, form_data): | |
77 | try: |
|
77 | try: | |
|
78 | cur_repo = self.get_by_repo_name(repo_name, cache=False) | |||
|
79 | user_model = UserModel(self.sa) | |||
78 |
|
80 | |||
79 | #update permissions |
|
81 | #update permissions | |
80 | for username, perm in form_data['perms_updates']: |
|
82 | for username, perm in form_data['perms_updates']: | |
81 | r2p = self.sa.query(RepoToPerm)\ |
|
83 | r2p = self.sa.query(RepoToPerm)\ | |
82 |
.filter(RepoToPerm.user == |
|
84 | .filter(RepoToPerm.user == user_model.get_by_username(username))\ | |
83 | .get_by_username(username, cache=False))\ |
|
85 | .filter(RepoToPerm.repository == cur_repo)\ | |
84 | .filter(RepoToPerm.repository == \ |
|
|||
85 | self.get_by_repo_name(repo_name))\ |
|
|||
86 | .one() |
|
86 | .one() | |
87 |
|
87 | |||
88 |
r2p.permission |
|
88 | r2p.permission = self.sa.query(Permission)\ | |
89 |
|
|
89 | .filter(Permission.permission_name == perm)\ | |
90 |
|
|
90 | .scalar() | |
91 | self.sa.add(r2p) |
|
91 | self.sa.add(r2p) | |
92 |
|
92 | |||
93 | #set new permissions |
|
93 | #set new permissions | |
94 | for username, perm in form_data['perms_new']: |
|
94 | for username, perm in form_data['perms_new']: | |
95 | r2p = RepoToPerm() |
|
95 | r2p = RepoToPerm() | |
96 |
r2p.repository = |
|
96 | r2p.repository = cur_repo | |
97 |
r2p.user = |
|
97 | r2p.user = user_model.get_by_username(username, cache=False) | |
98 |
|
98 | |||
99 |
r2p.permission |
|
99 | r2p.permission = self.sa.query(Permission)\ | |
100 |
|
|
100 | .filter(Permission.permission_name == perm)\ | |
101 |
|
|
101 | .scalar() | |
102 | self.sa.add(r2p) |
|
102 | self.sa.add(r2p) | |
103 |
|
103 | |||
104 | #update current repo |
|
104 | #update current repo | |
105 | cur_repo = self.get_by_repo_name(repo_name, cache=False) |
|
|||
106 |
|
||||
107 | for k, v in form_data.items(): |
|
105 | for k, v in form_data.items(): | |
108 | if k == 'user': |
|
106 | if k == 'user': | |
109 |
cur_repo.user |
|
107 | cur_repo.user = user_model.get(v) | |
110 | else: |
|
108 | else: | |
111 | setattr(cur_repo, k, v) |
|
109 | setattr(cur_repo, k, v) | |
112 |
|
110 |
@@ -619,7 +619,7 b'' | |||||
619 | </div> |
|
619 | </div> | |
620 | <div class="box"> |
|
620 | <div class="box"> | |
621 | <div class="title"> |
|
621 | <div class="title"> | |
622 |
<div class="breadcrumbs">${h.link_to(_(' |
|
622 | <div class="breadcrumbs">${h.link_to(_('Tags'),h.url('tags_home',repo_name=c.repo_name))}</div> | |
623 | </div> |
|
623 | </div> | |
624 | <div class="table"> |
|
624 | <div class="table"> | |
625 | <%include file='../tags/tags_data.html'/> |
|
625 | <%include file='../tags/tags_data.html'/> | |
@@ -630,7 +630,7 b'' | |||||
630 | </div> |
|
630 | </div> | |
631 | <div class="box"> |
|
631 | <div class="box"> | |
632 | <div class="title"> |
|
632 | <div class="title"> | |
633 |
<div class="breadcrumbs">${h.link_to(_(' |
|
633 | <div class="breadcrumbs">${h.link_to(_('Branches'),h.url('branches_home',repo_name=c.repo_name))}</div> | |
634 | </div> |
|
634 | </div> | |
635 | <div class="table"> |
|
635 | <div class="table"> | |
636 | <%include file='../branches/branches_data.html'/> |
|
636 | <%include file='../branches/branches_data.html'/> |
General Comments 0
You need to be logged in to leave comments.
Login now