##// END OF EJS Templates
implemented manual repo rescann and remapping
marcink -
r348:e8fc8754 default
parent child Browse files
Show More
@@ -23,14 +23,16 b' settings controller for pylons'
23 23 @author: marcink
24 24 """
25 25 from formencode import htmlfill
26 from pylons import request, session, tmpl_context as c, url
26 from pylons import request, session, tmpl_context as c, url, app_globals as g
27 27 from pylons.controllers.util import abort, redirect
28 28 from pylons.i18n.translation import _
29 29 from pylons_app.lib import helpers as h
30 30 from pylons_app.lib.auth import LoginRequired, HasPermissionAllDecorator
31 31 from pylons_app.lib.base import BaseController, render
32 from pylons_app.lib.utils import repo2db_mapper, invalidate_cache
32 33 from pylons_app.model.db import User, UserLog
33 34 from pylons_app.model.forms import UserForm
35 from pylons_app.model.hg_model import HgModel
34 36 from pylons_app.model.user_model import UserModel
35 37 import formencode
36 38 import logging
@@ -74,6 +76,20 b' class SettingsController(BaseController)'
74 76 # h.form(url('admin_setting', id=ID),
75 77 # method='put')
76 78 # url('admin_setting', id=ID)
79 if id == 'mapping':
80 rm_obsolete = request.POST.get('destroy', False)
81 log.debug('Rescanning directories with destroy=%s', rm_obsolete)
82
83 initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
84 repo2db_mapper(initial, rm_obsolete)
85 invalidate_cache('cached_repo_list')
86
87
88 return redirect(url('admin_settings'))
89
90
91
92
77 93
78 94 def delete(self, id):
79 95 """DELETE /admin/settings/id: Delete an existing item"""
@@ -177,11 +177,10 b' class EmptyChangeset(BaseChangeset):'
177 177 return '0' * 12
178 178
179 179
180 def repo2db_mapper(initial_repo_list):
180 def repo2db_mapper(initial_repo_list, remove_obsolete=False):
181 181 """
182 182 maps all found repositories into db
183 183 """
184 from pylons_app.model.meta import Session
185 184 from pylons_app.model.repo_model import RepoModel
186 185
187 186 sa = Session()
@@ -200,3 +199,12 b' def repo2db_mapper(initial_repo_list):'
200 199 'private':False
201 200 }
202 201 rm.create(form_data, user, just_db=True)
202
203
204 if remove_obsolete:
205 #remove from database those repositories that are not in the filesystem
206 for repo in sa.query(Repository).all():
207 if repo.repo_name not in initial_repo_list.keys():
208 sa.delete(repo)
209 sa.commit()
210
@@ -16,6 +16,38 b''
16 16 <%def name="main()">
17 17 <div>
18 18 <h2>${_('Settings administration')}</h2>
19
19
20 ${h.form(url('admin_setting', id='mapping'),method='put')}
21 <table class="table_disp">
22 <tr class="header">
23 <td colspan="2">${_('Remap andv rescan repositories')}</td>
24 </tr>
25 <tr align="right">
26 <td><span class="tooltip" tooltip_title="${h.tooltip(_('In case a repository was deleted from filesystem and there are leftovers in the database check this option to scan obsolete data in database and remove it.'))}">
27 ${_('destroy old data')}</span> ${h.checkbox('destroy',True)}</td>
28 <td>${h.submit('rescan','rescan repositories')}</td>
29 </table>
30 ${h.end_form()}
31 <br/>
32 ${h.form(url('admin_setting', id='global'),method='put')}
33 <table class="table_disp">
34 <tr class="header">
35 <td colspan="3">${_('Global application settings')}</td>
36 </tr>
37 <tr>
38 <td>${_('Application name')}</td>
39 <td>${h.text('app_title')}</td>
40 </tr>
41 <tr>
42 <td>${_('Realm text')}</td>
43 <td>${h.text('app_auth_realm')}</td>
44 </tr>
45 <tr>
46 <td></td>
47 <td>${h.submit('save','save settings')}</td>
48 </tr>
49 </table>
50 ${h.end_form()}
51
20 52 </div>
21 53 </%def>
General Comments 0
You need to be logged in to leave comments. Login now