##// END OF EJS Templates
Added form for controlling mercurial extensions...
marcink -
r2708:9bce679a beta
parent child Browse files
Show More
@@ -79,7 +79,7 b' class SettingsController(BaseController)'
79 # url('admin_settings')
79 # url('admin_settings')
80
80
81 defaults = RhodeCodeSetting.get_app_settings()
81 defaults = RhodeCodeSetting.get_app_settings()
82 defaults.update(self.get_hg_ui_settings())
82 defaults.update(self._get_hg_ui_settings())
83
83
84 return htmlfill.render(
84 return htmlfill.render(
85 render('admin/settings/settings.html'),
85 render('admin/settings/settings.html'),
@@ -123,7 +123,7 b' class SettingsController(BaseController)'
123 category='success')
123 category='success')
124
124
125 if setting_id == 'whoosh':
125 if setting_id == 'whoosh':
126 repo_location = self.get_hg_ui_settings()['paths_root_path']
126 repo_location = self._get_hg_ui_settings()['paths_root_path']
127 full_index = request.POST.get('full_index', False)
127 full_index = request.POST.get('full_index', False)
128 run_task(tasks.whoosh_index, repo_location, full_index)
128 run_task(tasks.whoosh_index, repo_location, full_index)
129 h.flash(_('Whoosh reindex task scheduled'), category='success')
129 h.flash(_('Whoosh reindex task scheduled'), category='success')
@@ -220,51 +220,55 b' class SettingsController(BaseController)'
220 )
220 )
221
221
222 try:
222 try:
223 # fix namespaces for hooks
223 # fix namespaces for hooks and extensions
224 _f = lambda s: s.replace('.', '_')
224 _f = lambda s: s.replace('.', '_')
225
225
226 sett1 = RhodeCodeUi.query()\
226 sett = RhodeCodeUi.get_by_key('push_ssl')
227 .filter(RhodeCodeUi.ui_key == 'push_ssl').one()
227 sett.ui_value = form_result['web_push_ssl']
228 sett1.ui_value = form_result['web_push_ssl']
228 Session().add(sett)
229
229
230 sett2 = RhodeCodeUi.query()\
230 sett = RhodeCodeUi.get_by_key('/')
231 .filter(RhodeCodeUi.ui_key == '/').one()
231 sett.ui_value = form_result['paths_root_path']
232 sett2.ui_value = form_result['paths_root_path']
232 Session().add(sett)
233
233
234 #HOOKS
234 #HOOKS
235 sett3 = RhodeCodeUi.query()\
235 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE)
236 .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_UPDATE)\
236 sett.ui_active = form_result[_f('hooks_%s' %
237 .one()
237 RhodeCodeUi.HOOK_UPDATE)]
238 sett3.ui_active = bool(form_result[_f('hooks_%s' %
238 Session().add(sett)
239 RhodeCodeUi.HOOK_UPDATE)])
240
239
241 sett4 = RhodeCodeUi.query()\
240 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE)
242 .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_REPO_SIZE)\
241 sett.ui_active = form_result[_f('hooks_%s' %
243 .one()
242 RhodeCodeUi.HOOK_REPO_SIZE)]
244 sett4.ui_active = bool(form_result[_f('hooks_%s' %
243 Session().add(sett)
245 RhodeCodeUi.HOOK_REPO_SIZE)])
244
245 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PUSH)
246 sett.ui_active = form_result[_f('hooks_%s' %
247 RhodeCodeUi.HOOK_PUSH)]
248 Session().add(sett)
246
249
247 sett5 = RhodeCodeUi.query()\
250 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PULL)
248 .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PUSH)\
251 sett.ui_active = form_result[_f('hooks_%s' %
249 .one()
252 RhodeCodeUi.HOOK_PULL)]
250 sett5.ui_active = bool(form_result[_f('hooks_%s' %
253
251 RhodeCodeUi.HOOK_PUSH)])
254 Session().add(sett)
252
255
253 sett6 = RhodeCodeUi.query()\
256 ## EXTENSIONS
254 .filter(RhodeCodeUi.ui_key == RhodeCodeUi.HOOK_PULL)\
257 sett = RhodeCodeUi.get_by_key('largefiles')
255 .one()
258 sett.ui_active = form_result[_f('extensions_largefiles')]
256 sett6.ui_active = bool(form_result[_f('hooks_%s' %
259 Session().add(sett)
257 RhodeCodeUi.HOOK_PULL)])
258
260
259 Session().add(sett1)
261 sett = RhodeCodeUi.get_by_key('hgsubversion')
260 Session().add(sett2)
262 sett.ui_active = form_result[_f('extensions_hgsubversion')]
261 Session().add(sett3)
263 Session().add(sett)
262 Session().add(sett4)
264
263 Session().add(sett5)
265 # sett = RhodeCodeUi.get_by_key('hggit')
264 Session().add(sett6)
266 # sett.ui_active = form_result[_f('extensions_hggit')]
267 # Session().add(sett)
268
265 Session().commit()
269 Session().commit()
266
270
267 h.flash(_('Updated mercurial settings'), category='success')
271 h.flash(_('Updated VCS settings'), category='success')
268
272
269 except Exception:
273 except Exception:
270 log.error(traceback.format_exc())
274 log.error(traceback.format_exc())
@@ -455,8 +459,7 b' class SettingsController(BaseController)'
455
459
456 return render('admin/repos/repo_add_create_repository.html')
460 return render('admin/repos/repo_add_create_repository.html')
457
461
458 @NotAnonymous()
462 def _get_hg_ui_settings(self):
459 def get_hg_ui_settings(self):
460 ret = RhodeCodeUi.query().all()
463 ret = RhodeCodeUi.query().all()
461
464
462 if not ret:
465 if not ret:
@@ -471,7 +474,7 b' class SettingsController(BaseController)'
471 if k.find('.') != -1:
474 if k.find('.') != -1:
472 k = k.replace('.', '_')
475 k = k.replace('.', '_')
473
476
474 if each.ui_section == 'hooks':
477 if each.ui_section in ['hooks', 'extensions']:
475 v = each.ui_active
478 v = each.ui_active
476
479
477 settings[each.ui_section + '_' + k] = v
480 settings[each.ui_section + '_' + k] = v
@@ -152,8 +152,7 b' class BaseVCSController(object):'
152 """
152 """
153 org_proto = environ['wsgi._org_proto']
153 org_proto = environ['wsgi._org_proto']
154 #check if we have SSL required ! if not it's a bad request !
154 #check if we have SSL required ! if not it's a bad request !
155 require_ssl = str2bool(RhodeCodeUi.get_by_key('push_ssl')\
155 require_ssl = str2bool(RhodeCodeUi.get_by_key('push_ssl').ui_value)
156 .scalar().ui_value)
157 if require_ssl and org_proto == 'http':
156 if require_ssl and org_proto == 'http':
158 log.debug('proto is %s and SSL is required BAD REQUEST !'
157 log.debug('proto is %s and SSL is required BAD REQUEST !'
159 % org_proto)
158 % org_proto)
@@ -346,12 +346,20 b' class DbManage(object):'
346 hgsubversion.ui_value = ''
346 hgsubversion.ui_value = ''
347 hgsubversion.ui_active = False
347 hgsubversion.ui_active = False
348
348
349 # enable hggit disabled by default
350 hggit = RhodeCodeUi()
351 hggit.ui_section = 'extensions'
352 hggit.ui_key = 'hggit'
353 hggit.ui_value = ''
354 hggit.ui_active = False
355
349 self.sa.add(hooks1)
356 self.sa.add(hooks1)
350 self.sa.add(hooks2)
357 self.sa.add(hooks2)
351 self.sa.add(hooks3)
358 self.sa.add(hooks3)
352 self.sa.add(hooks4)
359 self.sa.add(hooks4)
353 self.sa.add(largefiles)
360 self.sa.add(largefiles)
354 self.sa.add(hgsubversion)
361 self.sa.add(hgsubversion)
362 self.sa.add(hggit)
355
363
356 def create_ldap_options(self, skip_existing=False):
364 def create_ldap_options(self, skip_existing=False):
357 """Creates ldap settings"""
365 """Creates ldap settings"""
@@ -242,7 +242,7 b' class RhodeCodeUi(Base, BaseModel):'
242
242
243 @classmethod
243 @classmethod
244 def get_by_key(cls, key):
244 def get_by_key(cls, key):
245 return cls.query().filter(cls.ui_key == key)
245 return cls.query().filter(cls.ui_key == key).scalar()
246
246
247 @classmethod
247 @classmethod
248 def get_builtin_hooks(cls):
248 def get_builtin_hooks(cls):
@@ -263,11 +263,11 b' class RhodeCodeUi(Base, BaseModel):'
263
263
264 @classmethod
264 @classmethod
265 def get_repos_location(cls):
265 def get_repos_location(cls):
266 return cls.get_by_key('/').one().ui_value
266 return cls.get_by_key('/').ui_value
267
267
268 @classmethod
268 @classmethod
269 def create_or_update_hook(cls, key, val):
269 def create_or_update_hook(cls, key, val):
270 new_ui = cls.get_by_key(key).scalar() or cls()
270 new_ui = cls.get_by_key(key) or cls()
271 new_ui.ui_section = 'hooks'
271 new_ui.ui_section = 'hooks'
272 new_ui.ui_active = True
272 new_ui.ui_active = True
273 new_ui.ui_key = key
273 new_ui.ui_key = key
@@ -267,6 +267,10 b' def ApplicationUiSettingsForm():'
267 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
267 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
268 hooks_preoutgoing_pull_logger = v.StringBoolean(if_missing=False)
268 hooks_preoutgoing_pull_logger = v.StringBoolean(if_missing=False)
269
269
270 extensions_largefiles = v.StringBoolean(if_missing=False)
271 extensions_hgsubversion = v.StringBoolean(if_missing=False)
272 extensions_hggit = v.StringBoolean(if_missing=False)
273
270 return _ApplicationUiSettingsForm
274 return _ApplicationUiSettingsForm
271
275
272
276
@@ -55,7 +55,7 b' class ReposGroupModel(BaseModel):'
55 Get's the repositories root path from database
55 Get's the repositories root path from database
56 """
56 """
57
57
58 q = RhodeCodeUi.get_by_key('/').one()
58 q = RhodeCodeUi.get_by_key('/')
59 return q.ui_value
59 return q.ui_value
60
60
61 def _create_default_perms(self, new_group):
61 def _create_default_perms(self, new_group):
@@ -219,6 +219,27 b''
219 ${h.link_to(_('advanced setup'),url('admin_edit_setting',setting_id='hooks'),class_="ui-btn")}
219 ${h.link_to(_('advanced setup'),url('admin_edit_setting',setting_id='hooks'),class_="ui-btn")}
220 </div>
220 </div>
221 </div>
221 </div>
222 <div class="field">
223 <div class="label label-checkbox">
224 <label>${_('Mercurial Extensions')}:</label>
225 </div>
226 <div class="checkboxes">
227 <div class="checkbox">
228 ${h.checkbox('extensions_largefiles','True')}
229 <label for="extensions_hgsubversion">${_('largefiles extensions')}</label>
230 </div>
231 <div class="checkbox">
232 ${h.checkbox('extensions_hgsubversion','True')}
233 <label for="extensions_hgsubversion">${_('hgsubversion extensions')}</label>
234 </div>
235 <span class="help-block">${_('Requires hgsubversion library installed. Allows clonning from svn remote locations')}</span>
236 ##<div class="checkbox">
237 ## ${h.checkbox('extensions_hggit','True')}
238 ## <label for="extensions_hggit">${_('hg-git extensions')}</label>
239 ##</div>
240 ##<span class="help-block">${_('Requires hg-git library installed. Allows clonning from git remote locations')}</span>
241 </div>
242 </div>
222 <div class="field">
243 <div class="field">
223 <div class="label">
244 <div class="label">
224 <label for="paths_root_path">${_('Repositories location')}:</label>
245 <label for="paths_root_path">${_('Repositories location')}:</label>
General Comments 0
You need to be logged in to leave comments. Login now