110
from canonical.launchpad.interfaces.lpstorm import IStore
104
111
from canonical.launchpad.interfaces.validation import validate_new_team_email
105
112
from canonical.launchpad.webapp.authorization import check_permission
106
113
from canonical.launchpad.webapp.interfaces import ILaunchpadApplication
524
531
def team_subscription_policy_can_transition(team, policy):
525
"""Can the team can change its subscription policy
532
"""Can the team can change its subscription policy?
527
534
Returns True when the policy can change. or raises an error. OPEN teams
528
535
cannot be members of MODERATED or RESTRICTED teams. OPEN teams
544
551
raise TeamSubscriptionPolicyError(
545
552
"The team subscription policy cannot be %s because one "
546
553
"or more if its super teams are not open." % policy)
547
# The team can be open if it has PPAs.
554
# The team can not be open if it has PPAs.
548
555
for ppa in team.ppas:
549
556
if ppa.status != ArchiveStatus.DELETED:
550
557
raise TeamSubscriptionPolicyError(
551
558
"The team subscription policy cannot be %s because it "
552
559
"has one or more active PPAs." % policy)
561
from lp.bugs.model.bug import Bug
562
from lp.bugs.model.bugsubscription import BugSubscription
563
from lp.bugs.model.bugtask import BugTask
564
# The team cannot be open if it is subscribed to or assigned to
566
private_bugs_involved = IStore(Bug).execute(Union(
571
Join(BugSubscription, BugSubscription.bug_id == Bug.id)),
574
BugSubscription.person_id == team.id)),
579
Join(BugTask, BugTask.bugID == Bug.id)),
580
where=And(Bug.private == True, BugTask.assignee == team.id)),
582
if private_bugs_involved.rowcount:
583
raise TeamSubscriptionPolicyError(
584
"The team subscription policy cannot be %s because it is "
585
"subscribed to or assigned to one or more private "
553
587
elif team.subscriptionpolicy in OPEN_TEAM_POLICY:
554
588
# The team can become MODERATED or RESTRICTED if its member teams