changeset 395:e8af467b5a60

Added hooks managment into application settings
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 06 Aug 2010 02:40:57 +0200
parents 42367607dc19
children 9416269860c9
files pylons_app/controllers/admin/settings.py pylons_app/lib/utils.py pylons_app/model/forms.py pylons_app/templates/admin/settings/settings.html
diffstat 4 files changed, 48 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/controllers/admin/settings.py	Fri Aug 06 02:04:51 2010 +0200
+++ b/pylons_app/controllers/admin/settings.py	Fri Aug 06 02:40:57 2010 +0200
@@ -156,8 +156,23 @@
                     .filter(HgAppUi.ui_key == '/').one()
                     hgsettings2.ui_value = form_result['paths_root_path']                    
                     
+                    
+                    #HOOKS
+                    hgsettings3 = self.sa.query(HgAppUi)\
+                    .filter(HgAppUi.ui_key == 'changegroup.update').one()
+                    hgsettings3.ui_active = bool(form_result['hooks_changegroup_update'])  
+                    
+                    hgsettings4 = self.sa.query(HgAppUi)\
+                    .filter(HgAppUi.ui_key == 'changegroup.repo_size').one()
+                    hgsettings4.ui_active = bool(form_result['hooks_changegroup_repo_size'])                                          
+                    
+                    
+                    
+                    
                     self.sa.add(hgsettings1)
                     self.sa.add(hgsettings2)
+                    self.sa.add(hgsettings3)
+                    self.sa.add(hgsettings4)
                     self.sa.commit()
                     
                     h.flash(_('Updated application settings'),
--- a/pylons_app/lib/utils.py	Fri Aug 06 02:04:51 2010 +0200
+++ b/pylons_app/lib/utils.py	Fri Aug 06 02:40:57 2010 +0200
@@ -123,8 +123,18 @@
         raise Exception('Could not get application ui settings !')
     settings = {}
     for each in ret:
-        k = each.ui_key if each.ui_key != '/' else 'root_path'
-        settings[each.ui_section + '_' + k] = each.ui_value    
+        k = each.ui_key
+        v = each.ui_value
+        if k == '/':
+            k = 'root_path'
+        
+        if k.find('.') != -1:
+            k = k.replace('.', '_')
+        
+        if each.ui_section == 'hooks':
+            v = each.ui_active
+        
+        settings[each.ui_section + '_' + k] = v  
     
     return settings
 
--- a/pylons_app/model/forms.py	Fri Aug 06 02:04:51 2010 +0200
+++ b/pylons_app/model/forms.py	Fri Aug 06 02:40:57 2010 +0200
@@ -323,6 +323,8 @@
         filter_extra_fields = False
         web_push_ssl = OneOf(['true', 'false'], if_missing='false')
         paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=3, not_empty=True))
+        hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False)
+        hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False)
         
     return _ApplicationUiSettingsForm
 
--- a/pylons_app/templates/admin/settings/settings.html	Fri Aug 06 02:04:51 2010 +0200
+++ b/pylons_app/templates/admin/settings/settings.html	Fri Aug 06 02:40:57 2010 +0200
@@ -89,7 +89,7 @@
              
              <div class="field">
                 <div class="label label-checkbox">
-                    <label for="web_push_ssl">${_('Push ssl')}:</label>
+                    <label for="web_push_ssl">${_('Web')}:</label>
                 </div>
                 <div class="checkboxes">
 					<div class="checkbox">
@@ -98,13 +98,29 @@
 					</div>
 				</div>
              </div>						
+
+             <div class="field">
+                <div class="label label-checkbox">
+                    <label for="web_push_ssl">${_('Hooks')}:</label>
+                </div>
+                <div class="checkboxes">
+					<div class="checkbox">
+						${h.checkbox('hooks_changegroup_update','True')}
+						<label for="hooks_changegroup_update">${_('Update repository after push (hg update)')}</label>
+					</div>
+					<div class="checkbox">
+						${h.checkbox('hooks_changegroup_repo_size','True')}
+						<label for="hooks_changegroup_repo_size">${_('Show repository size after push')}</label>
+					</div>					
+				</div>
+             </div>	
 							                          
             <div class="field">
                 <div class="label">
                     <label for="paths_root_path">${_('Repositories location')}:</label>
                 </div>
                 <div class="input">
-                    ${h.text('paths_root_path',size=30,disabled="disabled")}
+                    ${h.text('paths_root_path',size=30,readonly="readonly")}
 					<span id="path_unlock" class="tooltip" tooltip_title="${h.tooltip(_('This a crucial application setting. If You really sure you need to change this, you must restart application in order to make this settings take effect. Click this label to unlock.'))}">
 		                ${_('unlock')}</span>
                 </div>
@@ -120,7 +136,7 @@
     <script type="text/javascript">
         YAHOO.util.Event.onDOMReady(function(){
             YAHOO.util.Event.addListener('path_unlock','click',function(){
-                YAHOO.util.Dom.get('paths_root_path').disabled=false;
+                YAHOO.util.Dom.get('paths_root_path').readonly=false;
             });
         });
     </script>