def visibleByUser(self, person): """See `IBranchCollection`.""" if (person == LAUNCHPAD_SERVICES or user_has_special_branch_access(person)): return self if person is None: return AnonymousBranchCollection( self._store, self._branch_filter_expressions, self._tables, self._asymmetric_filter_expressions, self._asymmetric_tables) return VisibleBranchCollection(person, self._store, self._branch_filter_expressions, self._tables, self._asymmetric_filter_expressions, self._asymmetric_tables)
def visibleByUser(self, person): """See `IBranchCollection`.""" if (person == LAUNCHPAD_SERVICES or user_has_special_branch_access(person)): return self if person is None: return AnonymousBranchCollection( self._store, self._branch_filter_expressions, self._tables, self._exclude_from_search, self._asymmetric_filter_expressions, self._asymmetric_tables) return VisibleBranchCollection( person, self._store, self._branch_filter_expressions, self._tables, self._exclude_from_search, self._asymmetric_filter_expressions, self._asymmetric_tables)
def validateRegistrant(self, registrant, branch=None): """See `IBranchNamespace`.""" if user_has_special_branch_access(registrant, branch): return owner = self.owner if not registrant.inTeam(owner): if owner.is_team: raise BranchCreatorNotMemberOfOwnerTeam( "%s is not a member of %s" % (registrant.displayname, owner.displayname) ) else: raise BranchCreatorNotOwner( "%s cannot create branches owned by %s" % (registrant.displayname, owner.displayname) ) if not self.getAllowedInformationTypes(registrant): raise BranchCreationForbidden('You cannot create branches in "%s"' % self.name)
def validateRegistrant(self, registrant, branch=None): """See `IBranchNamespace`.""" if user_has_special_branch_access(registrant, branch): return owner = self.owner if not registrant.inTeam(owner): if owner.is_team: raise BranchCreatorNotMemberOfOwnerTeam( "%s is not a member of %s" % (registrant.displayname, owner.displayname)) else: raise BranchCreatorNotOwner( "%s cannot create branches owned by %s" % (registrant.displayname, owner.displayname)) if not self.getAllowedInformationTypes(registrant): raise BranchCreationForbidden( 'You cannot create branches in "%s"' % self.name)
def setUpFields(self): CodeImportBaseView.setUpFields(self) if self.context_is_product: self.form_fields = self.form_fields.omit('product') # If the user can administer branches, then they should be able to # assign the ownership of the branch to any valid person or team. if user_has_special_branch_access(self.user): owner_field = self.schema['owner'] any_owner_choice = Choice( __name__='owner', title=owner_field.title, description=_( "As an administrator you are able to reassign this " "branch to any person or team."), required=True, vocabulary='ValidPersonOrTeam') any_owner_field = form.Fields( any_owner_choice, render_context=self.render_context) # Replace the normal owner field with a more permissive vocab. self.form_fields = self.form_fields.omit('owner') self.form_fields = any_owner_field + self.form_fields