# HG changeset patch # User Marcin Kuzminski # Date 1290041751 -3600 # Node ID b9bbc0d6e9f376eec1afc4bb82ef37aca3df184b # Parent 1105531ae5729060b4015ad63d0cf1ba20147adb added cache reset, stats reset, and delete into repository settings in admin. Some small template fixes diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/config/routing.py --- a/rhodecode/config/routing.py Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/config/routing.py Thu Nov 18 01:55:51 2010 +0100 @@ -73,7 +73,13 @@ m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}", action="delete_perm_user", conditions=dict(method=["DELETE"], function=check_repo)) - + #settings actions + m.connect('repo_stats', "/repos_stats/{repo_name:.*}", + action="repo_stats", conditions=dict(method=["DELETE"], + function=check_repo)) + m.connect('repo_cache', "/repos_cache/{repo_name:.*}", + action="repo_cache", conditions=dict(method=["DELETE"], + function=check_repo)) #ADMIN USER REST ROUTES map.resource('user', 'users', controller='admin/users', path_prefix='/_admin') diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/controllers/admin/repos.py --- a/rhodecode/controllers/admin/repos.py Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/controllers/admin/repos.py Thu Nov 18 01:55:51 2010 +0100 @@ -207,6 +207,35 @@ raise HTTPInternalServerError() @HasPermissionAllDecorator('hg.admin') + def repo_stats(self, repo_name): + """ + DELETE an existing repository statistics + :param repo_name: + """ + + try: + repo_model = RepoModel() + repo_model.delete_stats(repo_name) + except Exception, e: + h.flash(_('An error occured during deletion of repository stats'), + category='error') + return redirect(url('edit_repo', repo_name=repo_name)) + + @HasPermissionAllDecorator('hg.admin') + def repo_cache(self, repo_name): + """ + INVALIDATE exisitings repository cache + :param repo_name: + """ + + try: + ScmModel().mark_for_invalidation(repo_name) + except Exception, e: + h.flash(_('An error occured during cache invalidation'), + category='error') + return redirect(url('edit_repo', repo_name=repo_name)) + + @HasPermissionAllDecorator('hg.admin') def show(self, repo_name, format='html'): """GET /repos/repo_name: Show a specific item""" # url('repo', repo_name=ID) @@ -217,6 +246,18 @@ # url('edit_repo', repo_name=ID) repo_model = RepoModel() c.repo_info = repo = repo_model.get(repo_name) + if repo.stats: + last_rev = repo.stats.stat_on_revision + else: + last_rev = 0 + c.stats_revision = last_rev + c.repo_last_rev = ScmModel().get(repo_name).revisions[-1] + if last_rev == 0: + c.stats_percentage = 0 + else: + c.stats_percentage = '%.2f' % ((float((last_rev)) / c.repo_last_rev) * 100) + + if not repo: h.flash(_('%s repository is not mapped to db perhaps' ' it was created or renamed from the filesystem' diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/model/db.py --- a/rhodecode/model/db.py Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/model/db.py Thu Nov 18 01:55:51 2010 +0100 @@ -97,7 +97,7 @@ user = relation('User') fork = relation('Repository', remote_side=repo_id) repo_to_perm = relation('RepoToPerm', cascade='all') - stats = relation('Statistics', cascade='all') + stats = relation('Statistics', cascade='all', uselist=False) def __repr__(self): return "" % (self.repo_id, self.repo_name) diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/model/repo.py --- a/rhodecode/model/repo.py Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/model/repo.py Thu Nov 18 01:55:51 2010 +0100 @@ -24,7 +24,8 @@ from vcs.backends import get_repo, get_backend from datetime import datetime from pylons import app_globals as g -from rhodecode.model.db import Repository, RepoToPerm, User, Permission +from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \ + Statistics from rhodecode.model.meta import Session from rhodecode.model.user import UserModel from rhodecode.model.caching_query import FromCache @@ -179,6 +180,17 @@ self.sa.rollback() raise + def delete_stats(self, repo_name): + try: + self.sa.query(Statistics)\ + .filter(Statistics.repository == self.get(repo_name)).delete() + self.sa.commit() + except: + log.error(traceback.format_exc()) + self.sa.rollback() + raise + + def __create_repo(self, repo_name, alias): from rhodecode.lib.utils import check_repo repo_path = os.path.join(g.base_path, repo_name) diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/public/css/style.css Thu Nov 18 01:55:51 2010 +0100 @@ -1802,6 +1802,14 @@ text-align:left; } +.refresh_icon { +background:url("../images/icons/arrow_refresh.png") no-repeat scroll 3px; +height:16px; +padding-left:20px; +padding-top:1px; +text-align:left; +} + .rss_icon { background:url("../images/icons/rss_16.png") no-repeat scroll 3px; height:16px; diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/templates/admin/permissions/permissions.html --- a/rhodecode/templates/admin/permissions/permissions.html Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/templates/admin/permissions/permissions.html Thu Nov 18 01:55:51 2010 +0100 @@ -92,7 +92,7 @@
${h.text('ldap_port',class_='small')}
-
+
${h.checkbox('ldap_ldaps',True,class_='small')}
diff -r 1105531ae572 -r b9bbc0d6e9f3 rhodecode/templates/admin/repos/repo_edit.html --- a/rhodecode/templates/admin/repos/repo_edit.html Thu Nov 18 01:03:00 2010 +0100 +++ b/rhodecode/templates/admin/repos/repo_edit.html Thu Nov 18 01:55:51 2010 +0100 @@ -286,15 +286,42 @@
${_('Administration')}
-
- -

${_('Reset statistics')}

-

${_('Reset cache')}

-

${_('Delete')}

+

${_('Statistics')}

+ + ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')} +
+
+ ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('Confirm to remove current statistics');")} + +
+
    +
  • ${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}
  • +
  • ${_('Percentage of stats gathered')}: ${c.stats_percentage} %
  • +
+
+ +
+
+ ${h.end_form()} + +

${_('Cache')}

+ ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')} +
+
+ ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="refresh_icon action_button",onclick="return confirm('Confirm to invalidate repository cache');")} +
+
+ ${h.end_form()} - -
+

${_('Delete')}

+ ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')} +
+
+ ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")} +
+
+ ${h.end_form()}