• 
      

    Specify the URL for users when recording ChangeDescription entries.

    Review Request #14410 — Created April 29, 2025 and submitted

    Information

    Review Board
    release-7.1.x

    Reviewers

    When recording ChangeDescription entries for a change in ownership on
    a review request, we rely on User.get_absolute_url(). This is defined
    globally for users via settings.ABSOLUTE_URL_OVERRIDES, but the value
    doesn't take into account Local Sites, and on RBCommons we don't have
    this set at all, meaning this function is not available on User.

    To address this properly, ChangeDescription.record_field_chnage()
    now takes an optional build_url_func(), which can be used to let a
    caller handle URL computation for the objects. This is specified by
    OwnerField to compute a URL relative to the Local Site or global site
    for the parent review request.

    Removed the ABSOLUTE_URL_OVERRIDES and reproduced the original problem
    publishing. Verified that this patch fixed that, and generated a correct
    URL for both the global site and Local Site.

    Tested this on RBCommons as well.

    Summary ID
    Specify the URL for users when recording ChangeDescription entries.
    When recording `ChangeDescription` entries for a change in ownership on a review request, we rely on `User.get_absolute_url()`. This is defined globally for users via `settings.ABSOLUTE_URL_OVERRIDES`, but the value doesn't take into account Local Sites, and on RBCommons we don't have this set at all, meaning this function is not available on `User`. To address this properly, `ChangeDescription.record_field_chnage()` now takes an optional `build_url_func()`, which can be used to let a caller handle URL computation for the objects. This is specified by `OwnerField` to compute a URL relative to the Local Site or global site for the parent review request.
    fba37c6f733e3a86e80495ecbe24734c69d0213d
    Description From Last Updated

    Can we add a unit test that uses build_url_func?

    daviddavid

    From the implementation it looks like these should be _T | str | None

    daviddavid

    Don't feel like you need to do it, but it might be nice to have @overrides to indicate this?

    daviddavid

    Can we add typing for this and the other inner methods?

    daviddavid
    david
    1. 
        
    2. Show all issues

      Can we add a unit test that uses build_url_func?

    3. reviewboard/changedescs/models.py (Diff revision 1)
       
       
       
      Show all issues

      From the implementation it looks like these should be _T | str | None

      1. _T is roughly Any so it covers str and None, but a list[...] as a value causes problems for the _T in build_uri_func (which should be an item). Because I have a lot of work toward a modernization of the whole ChangeDescription work with enhanced typing, I'm going to keep this very simple.

    4. reviewboard/changedescs/models.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      Don't feel like you need to do it, but it might be nice to have @overrides to indicate this?

      1. Sorry, meant @overload

      2. I have a larger change that's been sitting in my tree to make a lot of the typing of ChangeDescription nicer. I'm trying to avoid duplicating any of that work at the moment, so much of this change is just bare minimum typing.

    5. reviewboard/changedescs/models.py (Diff revision 1)
       
       
      Show all issues

      Can we add typing for this and the other inner methods?

    6. 
        
    chipx86
    chipx86
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-7.1.x (bc2ec7d)