• 
      

    Cache a file attachment's review request on creation.

    Review Request #15175 — Created July 17, 2026 and updated

    Information

    Review Board
    release-8.x

    Reviewers

    As mentioned in /r/15164, the M2M field for file attachments and
    their review request only gets set after the attachment's first save.
    However, it would be useful to access the review request of a file
    attachment before the first save. File attachments already made use of
    a cached _review_request instance variable that we would set in
    BaseReviewRequestDetails.get_file_attachments(). This change similarly
    sets the attribute when a file attachment is created, since we have the
    review request already. This also improves
    FileAttachment.get_review_request() to set the cached instance if not
    already set when its called.

    • Ran unit tests.
    • Used in a change where we call attachment.get_review_request() in a
      file attachment post-save signal handler upon the first save, saw the
      cached instance was used.
    Summary ID
    Cache a file attachment's review request on creation.
    As mentioned in /r/15164, the M2M field for file attachments and their review request only gets set after the attachment's first save. However, it would be useful to access the review request of a file attachment before the first save. File attachments already made use of a cached `_review_request` instance variable that we would set in `BaseReviewRequestDetails.get_file_attachments()`. This change similarly sets the attribute when a file attachment is created, since we have the review request already. This also improves `FileAttachment.get_review_request()` to set the cached instance if not already set when its called.
    064a1b53bcfe76c760c9adb40b326e544dd83830
    Description From Last Updated

    Can we change "directly" to "instead"?

    david david

    Can we wrap this with try / except AttributeError: pass?

    david david

    Can we wrap this with try / except AttributeError: pass?

    david david
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    david
    1. 
        
    2. reviewboard/attachments/models.py (Diff revision 1)
       
       
      Show all issues

      Can we change "directly" to "instead"?

    3. Show all issues

      Can we wrap this with try / except AttributeError: pass?

    4. Show all issues

      Can we wrap this with try / except AttributeError: pass?

    5.