~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/blueprints/model/specification.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-21 01:24:40 UTC
  • mfrom: (13168.9.8 auto-upgrade-fix)
  • Revision ID: launchpad@pqm.canonical.com-20110621012440-waa76gmxu72in1i8
[r=henninge][bug=798560] Use scanner-compatible directory names when
        upgrading code import branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
from canonical.launchpad.helpers import (
53
53
    get_contact_email_addresses,
54
54
    )
55
 
from lp.app.errors import UserCannotUnsubscribePerson
 
55
from lp.services.propertycache import (
 
56
    cachedproperty,
 
57
    get_property_cache,
 
58
    )
56
59
from lp.blueprints.adapters import SpecificationDelta
57
60
from lp.blueprints.enums import (
58
61
    NewSpecificationDefinitionStatus,
90
93
from lp.registry.interfaces.person import validate_public_person
91
94
from lp.registry.interfaces.productseries import IProductSeries
92
95
from lp.registry.interfaces.product import IProduct
93
 
from lp.services.propertycache import (
94
 
    cachedproperty,
95
 
    get_property_cache,
96
 
    )
97
96
 
98
97
 
99
98
def recursive_blocked_query(spec):
535
534
                return sub
536
535
        return None
537
536
 
538
 
    def subscribe(self, person, subscribed_by=None, essential=False):
539
 
        """See ISpecification."""
540
 
        if subscribed_by is None:
541
 
            subscribed_by = person
542
 
        # Create or modify a user's subscription to this blueprint.
543
 
        # First see if a relevant subscription exists, and if so, return it
 
537
    def subscribe(self, person, user, essential):
 
538
        """Create or modify a user's subscription to this blueprint."""
 
539
        # first see if a relevant subscription exists, and if so, return it
544
540
        sub = self.subscription(person)
545
541
        if sub is not None:
546
542
            if sub.essential != essential:
554
550
                # that we can get away with not examining the attribute
555
551
                # at all - it's a boolean!
556
552
                notify(ObjectModifiedEvent(
557
 
                        sub, sub, ['essential'], user=subscribed_by))
 
553
                        sub, sub, ['essential'], user=user))
558
554
            return sub
559
555
        # since no previous subscription existed, create and return a new one
560
556
        sub = SpecificationSubscription(specification=self,
564
560
            property_cache.subscriptions.append(sub)
565
561
            property_cache.subscriptions.sort(
566
562
                key=lambda sub: sub.person.displayname)
567
 
        notify(ObjectCreatedEvent(sub, user=subscribed_by))
 
563
        notify(ObjectCreatedEvent(sub, user=user))
568
564
        return sub
569
565
 
570
 
    def unsubscribe(self, person, unsubscribed_by):
 
566
    def unsubscribe(self, person):
571
567
        """See ISpecification."""
572
568
        # see if a relevant subscription exists, and if so, delete it
573
 
        if person is None:
574
 
            person = unsubscribed_by
575
569
        for sub in self.subscriptions:
576
570
            if sub.person.id == person.id:
577
 
                if not sub.canBeUnsubscribedByUser(unsubscribed_by):
578
 
                    raise UserCannotUnsubscribePerson(
579
 
                        '%s does not have permission to unsubscribe %s.' % (
580
 
                            unsubscribed_by.displayname,
581
 
                            person.displayname))
582
571
                get_property_cache(self).subscriptions.remove(sub)
583
572
                SpecificationSubscription.delete(sub.id)
584
573
                return