|
a/Allura/allura/model/project.py |
|
b/Allura/allura/model/project.py |
|
... |
|
... |
18 |
from allura.lib.security import has_access
|
18 |
from allura.lib.security import has_access
|
19 |
|
19 |
|
20 |
from .session import main_orm_session
|
20 |
from .session import main_orm_session
|
21 |
from .session import project_orm_session, project_doc_session
|
21 |
from .session import project_orm_session, project_doc_session
|
22 |
from .neighborhood import Neighborhood
|
22 |
from .neighborhood import Neighborhood
|
23 |
from .auth import ProjectRole
|
23 |
from .auth import ProjectRole, User
|
24 |
from .timeline import ActivityNode, ActivityObject
|
24 |
from .timeline import ActivityNode, ActivityObject
|
25 |
from .types import ACL, ACE
|
25 |
from .types import ACL, ACE
|
26 |
|
26 |
|
27 |
from filesystem import File
|
27 |
from filesystem import File
|
28 |
|
28 |
|
|
... |
|
... |
456 |
from .artifact import AwardGrant
|
456 |
from .artifact import AwardGrant
|
457 |
return AwardGrant.query.find(dict(granted_to_project_id=self._id)).all()
|
457 |
return AwardGrant.query.find(dict(granted_to_project_id=self._id)).all()
|
458 |
|
458 |
|
459 |
@property
|
459 |
@property
|
460 |
def named_roles(self):
|
460 |
def named_roles(self):
|
|
|
461 |
roles_ids = [r['_id'] for r in g.credentials.project_roles(self.root_project._id).named]
|
461 |
roles = sorted(
|
462 |
roles = sorted(
|
462 |
g.credentials.project_roles(self.root_project._id).named,
|
463 |
ProjectRole.query.find({'_id': {'$in': roles_ids}}),
|
463 |
key=lambda r:r.name.lower())
|
464 |
key=lambda r: r.name.lower())
|
464 |
return roles
|
465 |
return roles
|
465 |
|
466 |
|
466 |
def install_app(self, ep_name, mount_point=None, mount_label=None, ordinal=None, **override_options):
|
467 |
def install_app(self, ep_name, mount_point=None, mount_label=None, ordinal=None, **override_options):
|
467 |
App = g.entry_points['tool'][ep_name]
|
468 |
App = g.entry_points['tool'][ep_name]
|
468 |
if not mount_point:
|
469 |
if not mount_point:
|
|
... |
|
... |
596 |
def users(self):
|
597 |
def users(self):
|
597 |
'''Find all the users who have named roles for this project'''
|
598 |
'''Find all the users who have named roles for this project'''
|
598 |
named_roles = security.RoleCache(
|
599 |
named_roles = security.RoleCache(
|
599 |
g.credentials,
|
600 |
g.credentials,
|
600 |
g.credentials.project_roles(project_id=self.root_project._id).named)
|
601 |
g.credentials.project_roles(project_id=self.root_project._id).named)
|
601 |
return [ r.user for r in named_roles.roles_that_reach if r.user_id is not None ]
|
602 |
uids = [uid for uid in named_roles.userids_that_reach if uid is not None]
|
|
|
603 |
return list(User.query.find({'_id': {'$in': uids}}))
|
602 |
|
604 |
|
603 |
def users_with_role(self, *role_names):
|
605 |
def users_with_role(self, *role_names):
|
604 |
"""Return all users in this project that have at least one of the roles
|
606 |
"""Return all users in this project that have at least one of the roles
|
605 |
specified.
|
607 |
specified.
|
606 |
|
608 |
|
|
... |
|
... |
622 |
u = User.by_username(username)
|
624 |
u = User.by_username(username)
|
623 |
if not u:
|
625 |
if not u:
|
624 |
return None
|
626 |
return None
|
625 |
named_roles = g.credentials.project_roles(project_id=self.root_project._id).named
|
627 |
named_roles = g.credentials.project_roles(project_id=self.root_project._id).named
|
626 |
for r in named_roles.roles_that_reach:
|
628 |
for r in named_roles.roles_that_reach:
|
627 |
if r.user_id == u._id: return u
|
629 |
if r.get('user_id') == u._id: return u
|
628 |
return None
|
630 |
return None
|
629 |
|
631 |
|
630 |
def configure_project(
|
632 |
def configure_project(
|
631 |
self,
|
633 |
self,
|
632 |
users=None, apps=None,
|
634 |
users=None, apps=None,
|