diff --git a/rhodecode/controllers/admin/repos.py b/rhodecode/controllers/admin/repos.py --- a/rhodecode/controllers/admin/repos.py +++ b/rhodecode/controllers/admin/repos.py @@ -141,6 +141,20 @@ class ReposController(BaseController): except formencode.Invalid, errors: c.repo_info = repo_model.get_by_repo_name(repo_name) + if c.repo_info.stats: + last_rev = c.repo_info.stats.stat_on_revision + else: + last_rev = 0 + c.stats_revision = last_rev + r = ScmModel().get(repo_name) + c.repo_last_rev = r.revisions[-1] if r.revisions else 0 + + if last_rev == 0: + c.stats_percentage = 0 + else: + c.stats_percentage = '%.2f' % ((float((last_rev)) / + c.repo_last_rev) * 100) + c.users_array = repo_model.get_users_js() errors.value.update({'user':c.repo_info.user.username}) return htmlfill.render( @@ -245,9 +259,9 @@ class ReposController(BaseController): """GET /repos/repo_name/edit: Form to edit an existing item""" # url('edit_repo', repo_name=ID) repo_model = RepoModel() - c.repo_info = repo = repo_model.get_by_repo_name(repo_name) - if repo.stats: - last_rev = repo.stats.stat_on_revision + c.repo_info = repo_model.get_by_repo_name(repo_name) + if c.repo_info.stats: + last_rev = c.repo_info.stats.stat_on_revision else: last_rev = 0 c.stats_revision = last_rev @@ -257,10 +271,11 @@ class ReposController(BaseController): if last_rev == 0: c.stats_percentage = 0 else: - c.stats_percentage = '%.2f' % ((float((last_rev)) / c.repo_last_rev) * 100) + c.stats_percentage = '%.2f' % ((float((last_rev)) / + c.repo_last_rev) * 100) - if not repo: + if not c.repo_info: h.flash(_('%s repository is not mapped to db perhaps' ' it was created or renamed from the filesystem' ' please run the application again' diff --git a/rhodecode/controllers/summary.py b/rhodecode/controllers/summary.py --- a/rhodecode/controllers/summary.py +++ b/rhodecode/controllers/summary.py @@ -4,6 +4,7 @@ ~~~~~~~~~~~~~~ Summary controller for Rhodecode + :created_on: Apr 18, 2010 :author: marcink :copyright: (C) 2009-2010 Marcin Kuzminski @@ -114,7 +115,7 @@ class SummaryController(BaseController): c.no_data_msg = _('No data loaded yet') run_task(get_commits_stats, c.repo_info.name, ts_min_y, ts_max_y) else: - c.no_data_msg = _('Statistics are disabled for this repository') + c.no_data_msg = _('Statistics update are disabled for this repository') c.ts_min = ts_min_m c.ts_max = ts_max_y @@ -124,7 +125,7 @@ class SummaryController(BaseController): if stats and stats.languages: - c.no_data = False + c.no_data = False is c.repo_info.dbrepo.enable_statistics lang_stats = json.loads(stats.languages) c.commit_data = stats.commit_activity c.overview_data = stats.commit_activity_combined diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py --- a/rhodecode/model/repo.py +++ b/rhodecode/model/repo.py @@ -75,38 +75,36 @@ class RepoModel(BaseModel): def update(self, repo_name, form_data): try: + cur_repo = self.get_by_repo_name(repo_name, cache=False) + user_model = UserModel(self.sa) #update permissions for username, perm in form_data['perms_updates']: r2p = self.sa.query(RepoToPerm)\ - .filter(RepoToPerm.user == UserModel(self.sa)\ - .get_by_username(username, cache=False))\ - .filter(RepoToPerm.repository == \ - self.get_by_repo_name(repo_name))\ + .filter(RepoToPerm.user == user_model.get_by_username(username))\ + .filter(RepoToPerm.repository == cur_repo)\ .one() - r2p.permission_id = self.sa.query(Permission).filter( - Permission.permission_name == - perm).one().permission_id + r2p.permission = self.sa.query(Permission)\ + .filter(Permission.permission_name == perm)\ + .scalar() self.sa.add(r2p) #set new permissions for username, perm in form_data['perms_new']: r2p = RepoToPerm() - r2p.repository = self.get_by_repo_name(repo_name) - r2p.user = UserModel(self.sa).get_by_username(username, cache=False) + r2p.repository = cur_repo + r2p.user = user_model.get_by_username(username, cache=False) - r2p.permission_id = self.sa.query(Permission).filter( - Permission.permission_name == perm)\ - .one().permission_id + r2p.permission = self.sa.query(Permission)\ + .filter(Permission.permission_name == perm)\ + .scalar() self.sa.add(r2p) #update current repo - cur_repo = self.get_by_repo_name(repo_name, cache=False) - for k, v in form_data.items(): if k == 'user': - cur_repo.user_id = v + cur_repo.user = user_model.get(v) else: setattr(cur_repo, k, v) diff --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html --- a/rhodecode/templates/summary/summary.html +++ b/rhodecode/templates/summary/summary.html @@ -619,7 +619,7 @@
- +
<%include file='../tags/tags_data.html'/> @@ -630,7 +630,7 @@
- +
<%include file='../branches/branches_data.html'/>