Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce reliance on get_absolute_url #244

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Commits on Jun 13, 2024

  1. Remove redundant version fetch

    The block above this line fetches the latest matching version, so it's
    pointless to then use that to get the latest version's URL.
    
    Instead, we get the URL of the object we already have.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    0ac2530 View commit details
    Browse the repository at this point in the history
  2. Customise QuerySet instead of Manager

    This will allow us to add custom queryset methods in an upcoming commit.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    f8973fa View commit details
    Browse the repository at this point in the history
  3. Remove direct knowledge of Django URLs from models

    Django models shouldn't know anything about URLs. This is a step in the
    direction of removing `get_absolute_url` from the models.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    dad158d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    de10f03 View commit details
    Browse the repository at this point in the history
  5. Separate getting latest version from URL

    Before this change, we used a model helper method to fetch the URL of
    the latest version of a matching class.
    
    Now we fetch the latest version, and then get its URL.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    26e1cd0 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f65b2c9 View commit details
    Browse the repository at this point in the history
  7. Replace some calls to Klass().get_absolute_url()

    Part of the process of removing the models is ensuring that we don't
    rely on any methods that live on them.
    
    This change removes most references to `get_absolute_url` on `Klass`,
    leaving behind those in the templates.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    1271520 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2d15e45 View commit details
    Browse the repository at this point in the history
  9. Move get_prepared_attributes from model to view

    We're in the process of moving logic off the models.
    This model method was only used by one view.
    
    This moves the logic from the model to the view.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    46c1fcf View commit details
    Browse the repository at this point in the history
  10. Fetch ancestors outside of loop

    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    27fbac2 View commit details
    Browse the repository at this point in the history
  11. Use a defaultdict for building mapped list

    We were previously manually doing what defaultdict does for us.
    meshy committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    464fcd0 View commit details
    Browse the repository at this point in the history

Commits on Jun 16, 2024

  1. Add test for view with overridden attributes

    Before this change, we didn't have a test which covered rendering
    overridden attributes.
    
    This change adds UpdateView to the snapshot tests, to catch regressions.
    meshy committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    99df59c View commit details
    Browse the repository at this point in the history
  2. Test get_all_ancestors against UpdateView

    We previously tested against a couple of simple artificial examples,
    but I didn't trust it to cover all the possible cases.
    
    This change ensures that we're testing against a complicated real-world
    example, UpdateView, which I believe to represent sufficient complexity.
    meshy committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    e9f1b79 View commit details
    Browse the repository at this point in the history