1. Olemis Lang
  2. trac-repositoryhooksystem


k0s  committed ac54e07

[svn r5056] check for plugin enablability and display HTML accordingly; closes #4104

  • Participants
  • Parent commits b0a1948
  • Branches repositoryhooksystemplugin

Comments (0)

Files changed (5)

File 0.11/repository_hook_system/admin.py

View file
         data['enabled'] = system.is_enabled(hookname)
+        data['can_enable'] = system.can_enable(hookname)
         activated = [ i.__class__.__name__ for i in system.subscribers(hookname) ]
         data['snippet'] = system.render(hookname, req)

File 0.11/repository_hook_system/filesystemhooks.py

View file
         if self.is_enabled(hookname):
             return # nothing to do
-        if not iswritable(hookname):
+        if not self.can_enable(hookname):
             return # XXX err more gracefully
         def print_hook(f):
                 if project in projects: 
                     return True
         return False
+    def can_enable(self, hookname):
+        return iswritable(self.filename(hookname))

File 0.11/repository_hook_system/interface.py

View file
         contingent upon enable marking the hook in such a way that it can be identified as enabled
+    def can_enable(hookname):
+        """
+        whether the hook can be set up
+        """
 class IRepositoryHookAdminContributer(Interface):
     contributes to the webadmin panel for the RepositoryHookSystem

File 0.11/repository_hook_system/svnhooksystem.py

View file
         filename = self.filename(hookname)
             contents = file(filename).read() # check for CRLF here too?
-            return tag.textarea(contents, rows='25', cols='80', name='hook-file-contents')
+            return tag.textarea(contents, rows='25', cols='80', name='hook-file-contents', disabled=not self.can_enable(hookname) or None)
         except IOError:
-            if iswritable(filename):
+            if self.can_enable(filename):
                 text = "No %s hook file yet exists;  enable this hook to create one" % hookname
-                text = "The file, %s, is unwritable;  enabling this hook will have no effect"
+                text = "The file, %s, is unwritable;  enabling this hook will have no effect" % filename
             return text
     def process_post(self, hookname, req):

File 0.11/repository_hook_system/templates/repositoryhooks.html

View file
 	<div class="field">
 	    <input type="checkbox" name="enable" value="enable" 
-		   py:attrs="{'checked': enabled or None}"/>
+		   py:attrs="{'checked': enabled or None, 'disabled': not can_enable or None}"/>