• 
      

    Use subclasses instead of instances to define consent requirements.

    Review Request #9937 — Created May 15, 2018 and submitted

    Information

    Djblets
    release-1.0.x
    55c9486...

    Reviewers

    ConsentRequirement has been renamed to BaseConsentRequirement, and
    instead of defining an instance and passing in state, it's now defined
    initially as a subclass that's then instantiated. Doing so makes it
    easier to construct a requirement (no need to override __init__, just
    set attributes and instantiate), and allows for having a standard set of
    requirements that applications can further customize through subclassing.

    It also gets rid of the "learn more" URL, which ended up not being needed
    in current form.

    Unit tests pass.

    Description From Last Updated

    Do we gain anything be registering an instance vs registering the class itself? What does instantiating do for us?

    brenniebrennie
    brennie
    1. 
        
    2. Show all issues

      Do we gain anything be registering an instance vs registering the class itself? What does instantiating do for us?

      1. Instances have functions that we use for building consent data and checking for consent, so we can do things like: if gravatar_requirement.get_consent(user) == Consent.GRANTED. Not worth instantiating and throwing away every time we do a check like that, and we'll be doing those checks on effectively every page load in the majority of cases. So instantiating once and keeping it around is probably worth doing.

    3. 
        
    brennie
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-1.0.x (7ecb09a)