Changeset - b9bbc0d6e9f3
[Not reviewed]
beta
0 7 0
Marcin Kuzminski - 15 years ago 2010-11-18 01:55:51
marcin@python-works.com
added cache reset, stats reset, and delete into repository settings in admin.
Some small template fixes
7 files changed with 105 insertions and 11 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -73,7 +73,13 @@ def make_map(config):
 
        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')
 

	
rhodecode/controllers/admin/repos.py
Show inline comments
 
@@ -207,6 +207,35 @@ class ReposController(BaseController):
 
            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 @@ class ReposController(BaseController):
 
        # 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'
rhodecode/model/db.py
Show inline comments
 
@@ -97,7 +97,7 @@ class Repository(Base):
 
    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 "<Repository('%s:%s')>" % (self.repo_id, self.repo_name)
rhodecode/model/repo.py
Show inline comments
 
@@ -24,7 +24,8 @@ model for handling repositories actions
 
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 @@ class RepoModel(object):
 
            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)
rhodecode/public/css/style.css
Show inline comments
 
@@ -1802,6 +1802,14 @@ padding-top:1px;
 
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;
rhodecode/templates/admin/permissions/permissions.html
Show inline comments
 
@@ -92,7 +92,7 @@
 
                <div class="input">${h.text('ldap_port',class_='small')}</div>
 
            </div>
 
            <div class="field">
 
                <div class="label label-checkbox"><label for="ldap_ldaps">${_('LDAPS')}</label></div>
 
                <div class="label label-checkbox"><label for="ldap_ldaps">${_('Enable LDAPS')}</label></div>
 
                <div class="checkboxes"><div class="checkbox">${h.checkbox('ldap_ldaps',True,class_='small')}</div></div>
 
            </div>
 
            <div class="field">
rhodecode/templates/admin/repos/repo_edit.html
Show inline comments
 
@@ -286,15 +286,42 @@
 
        <h5>${_('Administration')}</h5>    
 
    </div>
 
    
 
    <div class="form">
 
    
 
        <h3>${_('Reset statistics')}</h3>
 
        <h3>${_('Reset cache')}</h3>
 
        <h3>${_('Delete')}</h3>
 
        <h3>${_('Statistics')}</h3>
 
        
 
        ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
 
        <div class="form">
 
           <div class="fields">
 
               ${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');")}
 
               
 
               <div class="field">
 
               <ul>
 
                    <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
 
                    <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
 
               </ul>
 
               </div>
 
               
 
           </div>
 
        </div>                    
 
        ${h.end_form()}
 
        
 
        <h3>${_('Cache')}</h3>
 
        ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
 
        <div class="form">
 
           <div class="fields">
 
               ${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');")}
 
           </div>
 
        </div>                    
 
        ${h.end_form()}
 
        
 
        
 
    
 
    </div>
 
        <h3>${_('Delete')}</h3>
 
        ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
 
        <div class="form">
 
           <div class="fields">
 
               ${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');")}
 
           </div>
 
        </div>                    
 
        ${h.end_form()}
 
    
 
</div>
 

	
0 comments (0 inline, 0 general)