Anonymous avatar Anonymous committed d67f729 Draft

multiproduct: moving permissions to MultiProductSystem - towards #105 (from olemis)

Comments (0)

Files changed (2)

multiproduct/api.py

 from trac.core import Component, TracError, implements
 from trac.db import Table, Column, DatabaseManager
 from trac.env import IEnvironmentSetupParticipant
+from trac.perm import IPermissionRequestor
 from trac.web.chrome import ITemplateProvider
 
 class MultiProductSystem(Component):
     """Creates the database tables and template directories"""
     
-    implements(IEnvironmentSetupParticipant, ITemplateProvider)
+    implements(IEnvironmentSetupParticipant, ITemplateProvider,
+            IPermissionRequestor)
     
     SCHEMA = [
         Table('bloodhound_product', key = ['prefix', 'name']) [
         """proved the plugin htdocs"""
         return []
 
+    # IPermissionRequestor methods
+    def get_permission_actions(self):
+        acts = ['PRODUCT_CREATE', 'PRODUCT_DELETE', 'PRODUCT_MODIFY',
+                'PRODUCT_VIEW']
+        return acts + [('PRODUCT_ADMIN', acts)] + [('ROADMAP_ADMIN', acts)]
+

multiproduct/product_admin.py

 from trac.config import *
 from trac.perm import PermissionSystem
 from trac.admin.api import IAdminPanelProvider
-from trac.perm import IPermissionRequestor
 from trac.ticket.admin import TicketAdminPanel, _save_config
 from trac.resource import ResourceNotFound
 from model import Product
             data['owners'] = None
         return 'admin_products.html', data
 
-class ProductPermissions(Component):
-    """Product extensions to permissions"""
-    implements(IPermissionRequestor)
-    
-    # IPermissionRequestor methods
-    def get_permission_actions(self):
-        acts = ['PRODUCT_CREATE', 'PRODUCT_DELETE', 'PRODUCT_MODIFY',
-                'PRODUCT_VIEW']
-        return acts + [('PRODUCT_ADMIN', acts)] + [('ROADMAP_ADMIN', acts)]
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.