Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Anonymous Ticket Portal Anonymous Ticket Portal
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 27
    • Issues 27
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • TPA
  • Anonymous Ticket PortalAnonymous Ticket Portal
  • Merge requests
  • !30

Created new Mixin: PassUserIdentifierMixin

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged MariaV requested to merge user_mixin into master Jan 04, 2021
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 3

As class based views were passing results in a context dictionary, and function based views were passing them in a results dictionary, sidebar template extender for "logged in" user_links required lots of code duplication (e.g., to generate a link back to a user's landing page, the template required an if/else block, where if a dictionary called "results" existed, the url was called using results.user_identifier as an arg, and if there was no results dictionary, the url was called with a function that returned kwargs['user_identifier'].

To solve this, I wrote a Mixin, "PassUserIdentifierMixin", that updates any CBV's context data with an extra dictionary, "results", which contains 'user_identifier', kwargs.user_identifier.

As such, all template language in the the user_links template extender referring to CBV view.user_identifier was able to be deleted, which lowers code duplication and makes development easier going forward, as CBV user_identifiers and FBV user_identifiers are now both passed to the template in a dictionary called "results".

All tests passed, and manual testing of the function reveals it appears to work as intended.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: user_mixin