[ckan-changes] commit/ckanext-datano: sebbacon: allow other members of my authzgroup to edit my packages

Bitbucket commits-noreply at bitbucket.org
Thu Jun 9 14:09:32 UTC 2011


1 new changeset in ckanext-datano:

http://bitbucket.org/okfn/ckanext-datano/changeset/f484bf34a43c/
changeset:   f484bf34a43c
user:        sebbacon
date:        2011-06-09 16:09:18
summary:     allow other members of my authzgroup to edit my packages
affected #:  1 file (462 bytes)

--- a/ckanext/datano/plugin.py	Mon Jun 06 17:53:35 2011 +0100
+++ b/ckanext/datano/plugin.py	Thu Jun 09 15:09:18 2011 +0100
@@ -1,15 +1,17 @@
 import os
 from logging import getLogger
 
-from genshi.filters.transform import Transformer
-
+from pylons import c
+from ckan import model
 from ckan.plugins import implements, SingletonPlugin
-from ckan.plugins import IConfigurer
+from ckan.plugins import IConfigurer, IPackageController
 
 log = getLogger(__name__)
 
+
 class DataNOPlugin(SingletonPlugin):
     implements(IConfigurer, inherit=True)
+    implements(IPackageController, inherit=True)
 
     def update_config(self, config):
         here = os.path.dirname(__file__)
@@ -27,4 +29,13 @@
         config['ckan.site_logo'] = "http://drupal1.computas.no/ckan/img/fad_logo_ckan.png"
         config['ckan.favicon'] = "http://drupal1.computas.no/ckan/img/favicon.ico"
         config['package_form'] = "datano_package_form"  # XXX change
-		
\ No newline at end of file
+
+    def create(self, package):
+        # take my first authzgroup
+        # and give it the editor role on this package
+        user = model.User.by_name(c.user)
+        authzgroups = user and user.authorization_groups
+        authzgroup = authzgroups and authzgroups[0]
+        if authzgroup:
+            role = "editor"
+            model.add_authorization_group_to_role(authzgroup, role, package)

Repository URL: https://bitbucket.org/okfn/ckanext-datano/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list