Construct RB.UserSession state for each page in Python.

Review Request #10946 — Created March 10, 2020 and submitted

chipx86
Review Board
release-4.0.x
2c29d9d...
reviewboard

Every page constructs a large block of attributes for a RB.UserSession
instance, which is used to let JavaScript code determine session-related
information. This has historically been done in the template itself,
which is slow, hard to maintain, error-prone, and wastes a lot of
whitespace.

This change introduces a new {% js_user_session_info %}` template tag,
which does the work instead. It's much faster and easier to extend, and
cuts down quite a bit on what the template has to do.

It also handles defaults better. The system-wide rich text setting is
now used if a profile isn't yet set for the user. Timezone offsets are
also based off the configured timezone and not the page render context.

Besides that, none of the actual content has changed, and we're
leveraging the benefits of the json_dumps template filter, giving us
more reliable values going forward, if we start needing more
information.

Compared the output of the old and new payloads (normalizing both so
they could be easily diffable) for both authenticated and anonymous
users, and verified that the data remained the same.

Unit tests pass on all supported versions of Python.

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (4774c59)
Loading...