Hello.
It is channges for the dispatcher.py. I added the function remove_user().
=== modified file 'pkgdb/dispatcher.py'
--- pkgdb/dispatcher.py 2009-02-27 15:58:55 +0000
+++ pkgdb/dispatcher.py 2009-03-13 01:20:10 +0000
@@ -1397,3 +1397,95 @@
identity.current.user, [clone_branch])
return dict(pkglisting=clone_branch)
+
+ @expose(allow_json=True)
+ # Check that the requestor is in a group that could potentially set ACLs.
+ @identity.require(identity.not_anonymous())
+ def remove_user(self, pkg_name, username, collectn_list=None):
+ '''Remove users from a package.
+ :arg pkg_name: Name of the package
+ :arg username: Name of user to remove from the package
+ :arg collectn_list: list of collections like 'F-10', 'devel'
+ '''
+ person = fas.person_by_username(username)
+ if not person:
+ return dict(status=False,
+ message='Specified user name %s does not have a' \
+ ' Fedora Account' % username)
+ try:
+ # pylint: disable-msg=E1101
+ pkg = Package.query.filter_by(name=pkg_name).one()
+ except InvalidRequestError:
+ return dict(status=False, message='Package %s does not exist' % pkg_name)
+
+ # Check that the current user is allowed to change acl statuses
+ approved = self._user_can_set_acls(identity, pkg)
+ if not ident.in_group('cvsadmin'):
+ return dict(status=False, message=
+ '%s is not allowed to remove user from the package' %
+ identity.current.user_name)
+
+ log_msgs = []
+
+ if collectn_list:
+ for simple_name in collectn_list:
+ try:
+ collectn = Collection.by_simple_name(simple_name)
+ except InvalidRequestError:
+ return dict(status=False, message='Collection %s does not exist' % simple_name)
+
+ pkg_listing = PackageListing.query.filter_by(packageid=pkg.id,
+ collectionid=collectn.id).one()
+
+ acls = PersonPackageListingAcl.query.filter(and_(
+ PersonPackageListingAcl.c.personpackagelistingid
+ == PersonPackageListing.c.id,
+ PersonPackageListing.c.packagelistingid == pkg_listing.id,
+ PersonPackageListing.c.username == person['username'])).all()
+
+ for acl in acls:
+ person_acl = self._create_or_modify_acl(pkg_listing, person['id'], acl, self.obsoleteStatus)
+
+ log_msg = u'%s has set the %s acl on %s (%s %s) to Obsolete for %s' % (
+ identity.current.user_name, acl, pkg.name,
+ pkg_listing.collection.name, pkg_listing.collection.version,
+ person['username'])
+ log = PersonPackageListingAclLog(identity.current.user.id,
+ self.obsoleteStatus.statuscodeid, log_msg)
+ log.acl = person_acl # pylint: disable-msg=W0201
+ log_msgs.append(log_msg)
+
+ else:
+ for pkg_listing in pkg.listings:
+ acls = PersonPackageListingAcl.query.filter(and_(
+ PersonPackageListingAcl.c.personpackagelistingid
+ == PersonPackageListing.c.id,
+ PersonPackageListing.c.packagelistingid == pkg_listing.id,
+ PersonPackageListing.c.username == person['username'])).all()
+
+ for acl in acls:
+ person_acl = self._create_or_modify_acl(pkg_listing, person['id'], acl, self.obsoleteStatus)
+
+ log_msg = u'%s has set the %s acl on %s (%s %s) to Obsolete for %s' % (
+ identity.current.user_name, acl, pkg.name,
+ pkg_listing.collection.name, pkg_listing.collection.version,
+ person['username'])
+ log = PersonPackageListingAclLog(identity.current.user.id,
+ self.obsoleteStatus.statuscodeid, log_msg)
+ log.acl = person_acl # pylint: disable-msg=W0201
+ log_msgs.append(log_msg)
+
+ try:
+ session.flush()
+ except SQLError, e:
+ # An error was generated
+ return dict(status=False,
+ message='Not able to change acl %s on %s with status %s' \
+ % (acl, pkgid, self.obsoleteStatus.statusname))
+
+ # Send a log to people interested in this package as well
+ self._send_log_msg('\n'.join(log_msgs), '%s had acl change status' % (
+ pkg.name), identity.current.user, pkg.listings,
+ other_email=(person['email'],))
+
+ return dict(status=True)