Brand new user sees "None" for all dashboard counts in a local site.

Review Request #3841 — Created Feb. 5, 2013 and submitted

Information

Djblets

Reviewers

Fix Dashboard counts in localsite for new user
    
CounterField's _reinit method was returning back control if the pk of the model wasnt setup yet. This caused any of the "initializers" to not fire for the very first time. Modified the logic so that control returns back if the model's pk is None and there are no initializers defined. The earlier fix (https://github.com/djblets/djblets/commit/5f38334fabfd282232908ef80b28cd1889d0871c#djblets/util/fields.py) was setting the value to 0 if the pk wasnt available at the time. I've modified the logic so that the method _reinit returns back immediately (without processing the counter value) only if the pk is none and there are no initializers defined. For the case of LocalSiteProfiles table, there are initializers defined for all CounterFields, so they would be initialized the first time the object is created.

With this fix, there is still a problem in calculating counts on the LocalSiteProfiles for starred_public_request_counts. This is fixed in review request #3842 (http://reviews.reviewboard.org/r/3842/)
Manual testing with regular and creating local sites and ensured that the first time was seeing counts rather than None. 
Ran all reviewboard tests
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        djblets/util/fields.py
      Ignored Files:
    
    
  2. 
      
RA
david
  1. Ship It!
  2. 
      
RA
Review request changed
Status:
Completed
Change Summary:
Pushed to master (3b19f86). Thanks!