Pull out diff-related data into a "diff context" object and initialize models from it.

Review Request #4618 — Created Sept. 21, 2013 and submitted

Information

Review Board
master

Reviewers

Pull out diff-related data into a "diff context" object and initialize models from it.

The diff viewer needs a bunch of bits of data, which we render in a django
template as info in a <script> tag and then consume from javascript. This
change centralizes all of that info into a "diff_context" object which is
rendered using the json_dumps filter tag. This object is then consumed by a new
DiffViewerPageModel, which will parse the high-level object and create/update a
bunch of child models, which are then consumed by the various views that make
up the diff viewer UI.

Coming soon, we'll be able to consume this diff context either from the
javascript rendered into the template, as well as when it comes from an API
payload.

  • Tested various pieces of the diff viewer UI to make sure that the initial
    data was still correct.
  • Used this in conjunction with other changes that load different parts of the
    diff viewer without reloads.
  • Ran unit tests.
Description From Last Updated

Col: 80 E501 line too long (86 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (85 > 79 characters)

reviewbotreviewbot

undefined name 'escape'

reviewbotreviewbot

undefined name 'BaseComment'

reviewbotreviewbot

local variable 'diffset_pair' is assigned to but never used

reviewbotreviewbot

Col: 80 E501 line too long (83 > 79 characters)

reviewbotreviewbot

'from settings_local import *' used; unable to detect undefined names

reviewbotreviewbot

Can you make this alphabetical while here?

chipx86chipx86

These are all separate sets of things. Blank lines between these three?

chipx86chipx86

'from settings_local import *' used; unable to detect undefined names

reviewbotreviewbot

Trailing comma.

chipx86chipx86

We fetch this and 'numDiffs' twice. Can you cache this?

chipx86chipx86

'from settings_local import *' used; unable to detect undefined names

reviewbotreviewbot

'from settings_local import *' used; unable to detect undefined names

reviewbotreviewbot
reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. reviewboard/diffviewer/views.py (Diff revision 1)
     
     
    Show all issues

    Col: 80
    E501 line too long (86 > 79 characters)

  3. reviewboard/diffviewer/views.py (Diff revision 1)
     
     
    Show all issues

    Col: 80
    E501 line too long (85 > 79 characters)

  4. reviewboard/reviews/views.py (Diff revision 1)
     
     
    Show all issues

    Col: 80
    E501 line too long (83 > 79 characters)

  5. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. reviewboard/reviews/context.py (Diff revision 1)
     
     
    Show all issues

    undefined name 'escape'

  3. reviewboard/reviews/context.py (Diff revision 1)
     
     
    Show all issues

    undefined name 'BaseComment'

  4. reviewboard/reviews/views.py (Diff revision 1)
     
     
    Show all issues

    local variable 'diffset_pair' is assigned to but never used

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

    'from settings_local import *' used; unable to detect undefined names

  6. 
      
david
reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. reviewboard/settings.py (Diff revision 2)
     
     
    Show all issues

    'from settings_local import *' used; unable to detect undefined names

  3. 
      
chipx86
  1. 
      
  2. reviewboard/reviews/views.py (Diff revision 2)
     
     
     
    Show all issues

    Can you make this alphabetical while here?

  3. reviewboard/reviews/views.py (Diff revision 2)
     
     
     
     
    Show all issues

    These are all separate sets of things. Blank lines between these three?

  4. Show all issues

    Trailing comma.

  5. Show all issues

    We fetch this and 'numDiffs' twice. Can you cache this?

  6. 
      
david
reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. reviewboard/settings.py (Diff revision 3)
     
     
    Show all issues

    'from settings_local import *' used; unable to detect undefined names

  3. 
      
david
reviewbot
  1. This is a review from Review Bot.
    Tool: PEP8 Style Checker
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. 
      
reviewbot
  1. This is a review from Review Bot.
    Tool: Pyflakes
    Processed Files:
    reviewboard/reviews/views.py
    reviewboard/settings.py
    reviewboard/reviews/tests.py
    reviewboard/reviews/templatetags/reviewtags.py
    reviewboard/diffviewer/views.py
    reviewboard/reviews/context.py
    Ignored Files:
    reviewboard/static/rb/js/diffviewer/models/paginationModel.js
    reviewboard/templates/diffviewer/view_diff.html
    reviewboard/static/rb/js/pages/models/diffViewerPageModel.js
    reviewboard/static/rb/js/diffviewer/models/diffFileModel.js
    reviewboard/static/rb/js/diffviewer/models/diffRevisionModel.js
    reviewboard/static/rb/js/pages/views/diffViewerPageView.js

  2. reviewboard/settings.py (Diff revision 4)
     
     
    Show all issues

    'from settings_local import *' used; unable to detect undefined names

  3. 
      
chipx86
  1. Ship It!

  2. 
      
david
Review request changed
Status:
Completed
Change Summary:

Pushed to master (e97c723).