User Infobox Improvements
Review Request #7662 — Created Sept. 26, 2015 and discarded
When hovering over a user's name, an info box appears showing their avatar/photo, name, e-mail address, and some other information. It's somewhat useful, but could be more useful.
This change adds a couple new pieces of information:1) Their timezone and how many hours ahead/behind you they are (to help determine if they'd be available at the moment).
2) Some review request stats (how many review requests they have been assigned to, and how many they have had out for review).A new
UserInfoExtensionHook
is also created to provide additional information, and associated entity tag data, for this box, should the need arise. That way, third-parties can integrate other services they use with this box. Documentation and example usage for the new hook are also provided.
Moused over usernames to verify that the infobox appears with the new (and old) pieces of information displays correctly.
Overrodeget_extra_context
to ensure that additional information added via the extension hook displays correctly.
Description | From | Last Updated |
---|---|---|
Just saying how far ahead/behind forces me to do math. Can we imitate what Slack does? They have: <clock symbol> … |
david | |
There's a mismatch in styles here. We should aim for consistency, or separate them out more by whitespace. Also, the … |
chipx86 | |
Now that we're showing this using a time notation, we can probably skip the word "hours" ("4:00 hours" seems weird, … |
david | |
'tzinfo' imported but unused |
reviewbot | |
'timedelta' imported but unused |
reviewbot | |
Col: 47 E231 missing whitespace after ',' |
reviewbot | |
Col: 5 E303 too many blank lines (2) |
reviewbot | |
Col: 22 E261 at least two spaces before inline comment |
reviewbot | |
Col: 64 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 31 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 34 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 37 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 40 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 60 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 27 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 30 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 33 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 36 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 24 E261 at least two spaces before inline comment |
reviewbot | |
Col: 64 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 26 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 32 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 35 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 60 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 26 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 32 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 35 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 10 E261 at least two spaces before inline comment |
reviewbot | |
Col: 64 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 75 E225 missing whitespace around operator |
reviewbot | |
Col: 13 E122 continuation line missing indentation or outdented |
reviewbot | |
Col: 60 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 75 E225 missing whitespace around operator |
reviewbot | |
These imports need to be broken up. We organize our imports as following: from __future__ import unicode_literals # Standard library … |
brennie | |
'django' imported but unused |
reviewbot | |
No blank line here. |
brennie | |
Col: 32 E225 missing whitespace around operator |
reviewbot | |
Col: 28 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 36 E225 missing whitespace around operator |
reviewbot | |
Col: 42 E226 missing whitespace around arithmetic operator |
reviewbot | |
This should be six.text_type (i.e., unicode) instead of str. Also This will have to use fomratting so we can localize … |
brennie | |
Col: 36 E225 missing whitespace around operator |
reviewbot | |
Col: 5 E303 too many blank lines (3) |
reviewbot | |
Col: 57 E225 missing whitespace around operator |
reviewbot | |
I would break this up as: 'users_stats': { 'assigned': num_requests_assigned, 'posted': num_requests_posted, # ... } Then you can do the … |
brennie | |
Col: 1 W391 blank line at end of file |
reviewbot | |
Col: 15 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 15 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 15 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 15 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 15 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 15 E126 continuation line over-indented for hanging indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
No need to sign your work here. :) |
mike_conley | |
This is essentially the same value as requsr_dttemp. Can't we re-use the same value for both, and just call it … |
mike_conley | |
Converting the UTC datetime into a string and then extracting things from the string and converting them back into integers … |
mike_conley | |
I think it'd maybe make more sense do put the tz and hours values into the context and pass them … |
mike_conley | |
We already have the user, no? |
mike_conley | |
It seems to me we should be able to narrow down the review_requests with a QuerySet to find the cases … |
mike_conley | |
I think we should be fine to pass these down to the template as ints. |
mike_conley | |
"Assigned:" and "Posted:" aren't going to be translated. Let's send down just the raw integers, and do the translation in … |
mike_conley | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
undefined name 'e' |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 W292 no newline at end of file |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 58 E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
Col: 60 E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
Col: 22 E225 missing whitespace around operator |
reviewbot | |
Col: 5 E303 too many blank lines (2) |
reviewbot | |
Col: 5 E265 block comment should start with '# ' |
reviewbot | |
Col: 28 E226 missing whitespace around arithmetic operator |
reviewbot | |
"HTML" |
chipx86 | |
A couple things: 1) When showing examples like this, we want them in literal blocks. 2) I have no idea … |
chipx86 | |
This shouldn't be here. |
chipx86 | |
These docs, just like the ones above, will be generated and made available on our site. This needs to be … |
chipx86 | |
No blank line here. |
chipx86 | |
This shouldn't take a list of sections. That's going to lock us into a particular design, and it's going to … |
chipx86 | |
Missing a docstring. No blank line here. |
chipx86 | |
Two blank lines here. |
chipx86 | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
This is a third-party module. |
chipx86 | |
This must be inserted alphabetically. |
chipx86 | |
This blank line must remain. |
chipx86 | |
I'm going to want to see all this logic heavily documented, so every bit of it is clear. |
chipx86 | |
What's all this? |
chipx86 | |
<html> means the start of a document. We never want that, or we'll confuse browsers. |
chipx86 | |
On a large deployment, this may produce thousands or tens of thousands of review requests. Since we're just counting, we … |
chipx86 | |
Blank line between these. |
chipx86 | |
Missing a trailing comma. |
chipx86 | |
These should be one statemnet. |
chipx86 | |
Make sure all the content aligns properly with the current indentation level. |
chipx86 | |
'format_html' imported but unused |
reviewbot | |
'mark_safe' imported but unused |
reviewbot | |
Col: 39 E231 missing whitespace after ',' |
reviewbot | |
Col: 9 E303 too many blank lines (2) |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 17 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E123 closing bracket does not match indentation of opening bracket's line |
reviewbot | |
Col: 43 E231 missing whitespace after ',' |
reviewbot | |
Col: 51 E202 whitespace before ')' |
reviewbot | |
This should start with .. code-block:: python |
david | |
Docstrings should start with a 1-line summary, then a blank line, then additional paragraphs of explanation. |
david | |
We should check that template_name is a string, because otherwise we'll call render_to_string and pass it None. Alternatively, just get … |
david | |
ExtensionHook doesn't define get_extra_context so the super call is superfluous and useless. |
david | |
Remove this line. |
david | |
We should just include the <span> in the template, instead of passing it in like this. |
david | |
Please put this line back. |
david | |
'format_html' imported but unused |
reviewbot | |
This should line up with the c in code-block. |
brennie | |
This should line up with the c in code-block. |
brennie | |
Can you reformat this as follows? raise ValueError( 'Invalid UserInfoBox section: %s; must be one of %s' % (section, ', … |
brennie | |
Can you reformat this as: return render_to_string(self.template_name, RequestContext(request, context)) It's easier to read this way. |
brennie | |
Remove this line. |
brennie | |
This comment is unnecessary. |
brennie | |
Single quotes. Also, this should be six.text_type, not str: from django.utils import six The reason we use this is that … |
brennie | |
Can you put UserInfoBoxHook.render on one line? that way its clear there is not supposed to be a space between … |
brennie | |
This should be '... extension: "', extension.id, e, exc_info=True) (I know some places use exc_info=1, but we aren't doing that … |
brennie | |
This blank line isn't necessary when there's no docstring. |
david | |
I'm not sure what "custom parameters..." means here, and it's not something that users can change (since render chooses what … |
david | |
get_extra_context should return a dict, not a str. |
david | |
Col: 25 E128 continuation line under-indented for visual indent |
reviewbot | |
There are fractional time zones that aren't 30 minutes (for example, Kathmandu, Nepal is GMT +5:45). I don't think this … |
david | |
We should pass the raw numbers in to the template and put the text there. |
david | |
As is, this won't include any of the arguments because the first argument doesn't have any format specifiers. You can … |
david | |
Col: 30 E201 whitespace after '(' |
reviewbot | |
local variable 'e' is assigned to but never used |
reviewbot | |
How about the following: # We round the timezones while minutes >= 10: if ahead: hr_diff += 0.25 else: hr_diff … |
brennie | |
elif |
brennie | |
When interpolating only one variable, you don't need to use dict interpolation. |
brennie | |
So string additions are slow. How about: custom_info_parts = [] for hook in UserInfoBoxHooks.hooks: try: custom_info_parts.append(hook.render(user, request)) except Exception: # … |
brennie | |
We want to make sure that this isn't going to be escaped incorrectly. We should be checking if the result … |
brennie | |
extension.id on next line. |
brennie | |
Can we move all of this computation to happen after the etag_if_none_match call? We don't want to do this if … |
david | |
I suspect we should show something else (or not show this at all) if request.user is the same as user. … |
david | |
Can we localize this? We also should be able to skip the six.text_type call. td_msg = _('Same local time as … |
david | |
I know the existing text in here isn't localized, but we should mark these words (and the others in here) … |
david | |
If you do: :py:class:`~reviewboard.extensions.hooks.UserInfoHook` it will still link to the right class, but it will render as UserInfoHook. |
brennie | |
get_extra_context should return a rst :py:class:`dict`. |
brennie | |
Double backquotes |
brennie | |
Double backquotes |
brennie | |
No blank line here. |
brennie | |
six.text_type, not unicode. (from django.util import six) |
brennie | |
How about: review_requests_sent = ( ReviewRequest.objects .public(user=request.user) .filter(submitter=user) .count() ) Does this include ALL sent rrs or only the open … |
brennie | |
Why are you casting this to a string? Does this include ALL assigned rrs or only open? |
brennie | |
Maybe we should we leave it up to the hook to return their strings as marked safe? |
brennie | |
Col: 13 E131 continuation line unaligned for hanging indent |
reviewbot | |
"A :py:class:`~reviewboard.extensions.hooks.UserInfoBoxHook` can be used..." |
brennie | |
Blank space after comma |
brennie | |
"to return a :py:class:`dict`. The result of this function will be used, in addition to the request and user, for … |
brennie | |
Should comment out the dots because its not valid python. |
brennie | |
Provide an actual example. |
brennie | |
backquotes around the strings, e.g. * ``'user-identity'`` * ``'extra-details'`` |
brennie | |
If required, :py:meth:`get_extra_context` may be overridden ... |
brennie | |
If required, :py:meth:`get_extra_context` may be overridden ... |
brennie | |
Can we call this SECTIONS instead? |
brennie | |
Col: 33 E128 continuation line under-indented for visual indent |
reviewbot | |
All comments should be complete sentences and should end in periods. This goes for all comments in this method. |
brennie | |
requser? How about target_user? |
brennie | |
Instead of my_user, lets call it user or local_user |
brennie | |
This isn't a very useful comment. |
brennie | |
This is not a complete sentence. |
brennie | |
We should probably wrap this in an {% if custom_info %}. Also class="custom-info" |
brennie | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
We should call this SECTIONS |
david | |
We should indent this as: return mark_safe( render_to_string(self.template_name, RequestContext(request, context))) |
david | |
Col: 17 E128 continuation line under-indented for visual indent |
reviewbot | |
There's no need to cast this to a string. |
david | |
We don't seem to be splitting this into the different sections. |
david | |
The etag needs to take into account the time difference and stats, and probably the extension hook stuff as well. … |
brennie | |
According to the raw diff, you removed a newline from the last line. Please add it back. |
brennie | |
Unnecessary. |
brennie | |
Can we just call this user_tz? |
brennie | |
Unnecessary |
brennie | |
This isn't the entity tag. You have to call encode_etag on the result. |
brennie | |
Can you just put one, larger comment above the timezone calculation stuff? We don't need comments every few lines -- … |
brennie | |
Unnecessary. |
brennie | |
Unnecessary. |
brennie | |
No blank line here. |
brennie | |
Unnecessary. |
brennie | |
Get. |
brennie | |
Unnecessary. |
brennie | |
"custom rendering context" |
brennie | |
"In this case, the get_etag_data should be overridden to return data that will be used to generate the entity tag … |
brennie | |
"Get" |
brennie | |
Remove this. |
brennie |
- Change Summary:
-
Reworked hour difference code to use the "datetime, ptyz, and utcoffset" method, halfway through working on user's RR stats component of the project
- Description:
-
WIP: Created and implemented algorithm to display time difference, experimented with utcoffset as an alternative.
Before trying out the aforementioned algorithm, I first coded it in a separate .py file (attached as main.py), and then I wrote an exhaustive test (attached as test.py). The log file from that test is too big to attach here (50MB), but it is uploaded to Google Drive (https://drive.google.com/file/d/0B0qLz3PLbZZIX0h4TlllN1RydlE/view?usp=sharing). In addition to the exhaustive test, I also ran some individual tests for a shorter log file (attached here as rb_hr_indiv_tests.txt).
+ + UPDATE: The code now uses the "datetime, ptyz, and utcoffset" method rather than the algorithm I created.
- Testing Done:
-
~ Hovering over a self-created test account's username on a local test server. The user infobox will show the result of the algorithm (until I can get utcoffset to work properly).
~ Hovering over a self-created test account's username on a local test server. UPDATE: The user infobox will now display result of the "datetime, ptyz, and utcoffset" method, not the algorithm.
- Diff:
-
Revision 2 (+133)
- Removed Files:
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
-
-
-
-
-
-
-
-
-
-
-
These imports need to be broken up. We organize our imports as following:
from __future__ import unicode_literals # Standard library imports like logging, time, etc. # Third-party library imports like django, pytz, etc. # reviewboard.* imports
-
-
This should be
six.text_type
(i.e.,unicode
) instead ofstr
.Also This will have to use fomratting so we can localize the strings, e.g.
from django.utils.translation import ugettext as _ # ... if hr_diff < 0: td_msg = (_('%(tz)s: %(hours)s hours ahead of you') % { 'tz': requsr_tz, 'hours': -1 * hr_diff }) elif hr_diff > 0: # ...
-
I would break this up as:
'users_stats': { 'assigned': num_requests_assigned, 'posted': num_requests_posted, # ... }
Then you can do the formatting in the infobox with
{% blocktrans %} .... {% endblocktrans %}
so that it gets localized.
- Change Summary:
-
Completed the functionality to display user RR statistics.
- Description:
-
~ WIP: Created and implemented algorithm to display time difference, experimented with utcoffset as an alternative.
~ ~ Before trying out the aforementioned algorithm, I first coded it in a separate .py file (attached as main.py), and then I wrote an exhaustive test (attached as test.py). The log file from that test is too big to attach here (50MB), but it is uploaded to Google Drive (https://drive.google.com/file/d/0B0qLz3PLbZZIX0h4TlllN1RydlE/view?usp=sharing). In addition to the exhaustive test, I also ran some individual tests for a shorter log file (attached here as rb_hr_indiv_tests.txt).
~ ~ Adds three pieces of information to the user info box:
~ 1) Hour difference with local computer ~ 2) User's review requests ~ 3) User's assigned requests - UPDATE: The code now uses the "datetime, ptyz, and utcoffset" method rather than the algorithm I created.
- Testing Done:
-
~ Hovering over a self-created test account's username on a local test server. UPDATE: The user infobox will now display result of the "datetime, ptyz, and utcoffset" method, not the algorithm.
~ Hovering over a test account usernames on a local test server.
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
- Change Summary:
-
WIP: Adding UserInfoBoxExtensionHook
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests + + WIP: Adds a UserInfoBoxHook to allow for more information to be added.
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html
-
-
-
-
-
-
-
-
This is essentially the same value as requsr_dttemp.
Can't we re-use the same value for both, and just call it "now" or "utc_now"?
utc_now = datetime.datetime.now(pytz.utc)
-
Converting the UTC datetime into a string and then extracting things from the string and converting them back into integers to do math seems suboptimal.
I'm reasonably certain that we can extract the values that we need from the return value of datetime.now(pytz.utc) and similar.
Example:
now = datetime.datetime.now(pytz.utc) other_user_tz = pytz.timezone(user.get_profile().timezone) other_user_time = now.astimezone(other_user_tz) my_user_tz = pytz.timezone(request.user.get_profile().timezone) my_user_time = now.astimezone(my_user_tz)
Can we not then get the timedelta's that we want in seconds, and then convert to minutes / hours, to generate the values that we need?
Also, you might find this interesting: http://stackoverflow.com/questions/14190045/how-to-convert-datetime-timedelta-to-minutes-hours-in-python
-
I think it'd maybe make more sense do put the tz and hours values into the context and pass them into the template, and then insert them with the translation strings in the template, instead of just sending down the translated strings from the view.
-
-
It seems to me we should be able to narrow down the review_requests with a QuerySet to find the cases where rr.submitter == user. QuerySet docs: https://docs.djangoproject.com/en/1.6/topics/db/queries/
-
-
"Assigned:" and "Posted:" aren't going to be translated.
Let's send down just the raw integers, and do the translation in the views.
- Change Summary:
-
Added extension hook and documentation for using the hook. Made changes to UI and calculation method for time difference
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests ~ WIP: Adds a UserInfoBoxHook to allow for more information to be added.
~ Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook.
+ + NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
- Testing Done:
-
~ Hovering over a test account usernames on a local test server.
~ Hovering over a test account usernames on a local test server.
+ Unit testing for the extension hook. - Diff:
-
Revision 8 (+304 -7)
- Removed Files:
- Added Files:
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/templates/accounts/user_infobox.html docs/codebase/index.rst~ Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/templates/accounts/user_infobox.html docs/codebase/index.rst~
-
-
-
-
-
-
-
- Change Summary:
-
Reviewbot fixes.
- Diff:
-
Revision 9 (+237 -7)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/templates/accounts/user_infobox.html docs/codebase/index.rst~ Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/templates/accounts/user_infobox.html docs/codebase/index.rst~
-
-
Looks like you have some files in here (the documentation ending with a
~
) that you probably didn't mean to have. -
-
A couple things:
1) When showing examples like this, we want them in literal blocks.
2) I have no idea what this section is trying to say, so an extension author is going to be even more confused. Saying<html>...</html>
suggests an entire HTML page will be in there.It's better to use more concrete examples and to explain the structure in words.
-
-
These docs, just like the ones above, will be generated and made available on our site. This needs to be more explanatory, like above.
-
-
This shouldn't take a list of sections. That's going to lock us into a particular design, and it's going to be hard to adapt this to any future changes.
I also don't think it's useful to take pre-defined strings. Infoboxes aren't going to show a single static string. They're going to need to compute things for the given user.
I'd suggest a different design for the hook:
1) Each
UserInfoBoxHook
should be about showing one single thing, not multiple things. Extensions can always instantiate more than one hook.
2) The constructor should take only two things: 1) A section indicator (represented by a constant on this class indicating the section name -- this would be mapped to a string like "header", etc.), and 2) an optional template name.
3) Therender
function below needs to take the user (since an extension will be basing info on the user), and should default to rendering the provided template with the request and user as context. However, the documentation should state thatrender
can be overridden to provide custom rendering.This should not take
is_enabled
, as it makes no sense to instantiate a hook and just keep it disabled.We also need to rethink the sections. "header", "body", "footer" locks us into that model for the infobox, meaning we can't shuffle it later. For instance, say we want to make some of this appear side-by-side. "Footer" no longer makes sense there.
Instead, let's go with "user-identity" (names, e-mail, possibly department, etc.), and "extra-details". I think going with a third doesn't make a lot of sense right now.
-
-
-
-
-
-
-
-
-
On a large deployment, this may produce thousands or tens of thousands of review requests.
Since we're just counting, we want to let the database handle this. We also don't need to re-check the user, since that's already part of the query. So:
review_requests_sent = ReviewRequest.objects.public(user=user).count()
-
-
-
-
- Change Summary:
-
Overhaul of the extension hook code and minor infobox UI improvements.
- Summary:
-
User Infobox ImprovementsWIP: User Infobox Improvements
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests ~ Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook.
~ Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
~ NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
~ NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
+ UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. - Testing Done:
-
Hovering over a test account usernames on a local test server.
~ Unit testing for the extension hook. ~ UPDATE (10/20/2015): Will have to re-test the hook after the architecture overhaul. - Groups:
-
- Diff:
Revision 10 (+241 -10)
- Removed Files:
- Added Files:
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Fixed ReviewBot errors which appeared after the previous post.
- Diff:
-
Revision 11 (+241 -9)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
- Change Summary:
-
Added documentation on extending the UserInfoBoxHook. Minor fixes to issues raised about the code in views.py.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. + + LATEST UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
- Diff:
-
Revision 12 (+226 -9)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
-
- Change Summary:
-
Fixed a whitespace issue in views.py from ReviewBot
- Diff:
-
Revision 13 (+226 -9)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/ui/datagrids.less reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
-
To remove a file from your review request you can do:
git rm <filename> git commit -m "Removed <filename>" rbt post -r 7662
Also, you're going to want to add backup files to your global
.gitignore
or turn them off in your.vimrc
. To do the former (a good idea), add the following to your~/.gitconfig
:[core] excludesfile = ~/.gitignore_global
And then create a
~/.gitignore_global
file with the following:*~
-
-
-
Docstrings should start with a 1-line summary, then a blank line, then additional paragraphs of explanation.
-
We should check that
template_name
is a string, because otherwise we'll callrender_to_string
and pass itNone
. Alternatively, just get rid of the default value for the parameter to force people to pass it in. -
-
-
-
- Change Summary:
-
Minor fixes to extension hook architecture and infobox UI. Changes to extension hook docstring in hooks.py.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
~ UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. ~ ~ UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. ~ UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation. - LATEST UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
- Testing Done:
-
Hovering over a test account usernames on a local test server.
~ UPDATE (10/20/2015): Will have to re-test the hook after the architecture overhaul. ~ UPDATE (10/20/2015): Will have to re-test the hook after the architecture overhaul. + UPDATE (10/28/2015): Tested the hook within the user_infobox function in views.py. - Diff:
-
Revision 14 (+227 -6)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
-
- Change Summary:
-
Removed unused import from views.py
- Diff:
-
Revision 15 (+226 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: reviewboard/templates/accounts/user_infobox.html docs/codebase/generating-documentation.rst~ docs/manual/extending/extensions/hooks/index.rst reviewboard/static/rb/css/common.less docs/codebase/index.rst~ docs/manual/extending/extensions/hooks/user-infobox-hook.rst
-
-
-
-
Can you reformat this as follows?
raise ValueError( 'Invalid UserInfoBox section: %s; must be one of %s' % (section, ', '.join(UserInfoBoxHook.SECTION_OPTIONS))
This avoids the text wrapping. We also prefer
%
-formatting parameters to appear on the next line when the string is long enough to warrant it. -
Can you reformat this as:
return render_to_string(self.template_name, RequestContext(request, context))
It's easier to read this way.
-
-
-
Single quotes. Also, this should be
six.text_type
, notstr
:from django.utils import six
The reason we use this is that we use unicode literals everywhere and
unicode
!=str
. However, in Python 3,unicode
was renamed tostr
andstr
was renamed tobytes
. We usesix.text_type
so that when we eventually transition to Py3, we will have less headaches. -
Can you put
UserInfoBoxHook.render
on one line? that way its clear there is not supposed to be a space between them. -
This should be
'... extension: "', extension.id, e, exc_info=True)
(I know some places use
exc_info=1
, but we aren't doing that moving forward.)
- Change Summary:
-
Removed the files which were accidentally added to the review request.
- Diff:
-
Revision 16 (+205 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
- Change Summary:
-
Removed unnecessary lines and reformatted wrapping text in views.py and hooks.py. Fixed indenting in extension hook documentation.
- Diff:
-
Revision 17 (+204 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
-
-
-
I'm not sure what "custom parameters..." means here, and it's not something that users can change (since
render
chooses what to pass in). We should listuser, request
. -
-
There are fractional time zones that aren't 30 minutes (for example, Kathmandu, Nepal is GMT +5:45). I don't think this will do the right thing for those.
-
-
As is, this won't include any of the arguments because the first argument doesn't have any format specifiers. You can also simplify it using
logging.exception
:logging.exception('Error when running UserInfoBoxHook.render in ' 'extension %s', extension.id)
- Change Summary:
-
Extension hook documentation changes. Also, hour difference calculation now rounds to the nearest quarter of an hour. Minor fixes to code in hooks.py, views.py and infobox template.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation. + + LATEST UPDATE (10/29/2015):
+ * Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. + * Hour difference calculation in views.py now takes quarterly differences into account. - Diff:
-
Revision 18 (+220 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
-
- Change Summary:
-
ReviewBot fixes to views.py.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation. ~ LATEST UPDATE (10/29/2015):
~ * Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. ~ * Hour difference calculation in views.py now takes quarterly differences into account. ~ LATEST UPDATE (10/29/2015):
~ - Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. ~ - Hour difference calculation in views.py now takes quarterly differences into account. - Diff:
-
Revision 19 (+220 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
-
How about the following:
# We round the timezones while minutes >= 10: if ahead: hr_diff += 0.25 else: hr_diff -= 0.25 minutes -= 15
This will have the same effect, but be much shorter.
Also, personally I'd much rather see
5:45 hours ahead of you
instead of5.75 hours ahead of you
. -
-
-
So string additions are slow. How about:
custom_info_parts = [] for hook in UserInfoBoxHooks.hooks: try: custom_info_parts.append(hook.render(user, request)) except Exception: # ... custom_info = ''.join(custom_info_parts)
-
We want to make sure that this isn't going to be escaped incorrectly. We should be checking if the result of
hook.render
is aSafeString
or not. If not, it should beescaped
so that we only deal withSafeString
s. -
- Change Summary:
-
Changes to hour difference display formatting and hook processing.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
~ NOTE: I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
~ NOTE: (FIXED) I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
- UPDATE (10/20/2015): I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch. - UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation. ~ LATEST UPDATE (10/29/2015):
~ UPDATE (10/20/2015): (FIXED) I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch.
+ + UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
+ + UPDATE (10/29/2015 - A):
- Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. - Hour difference calculation in views.py now takes quarterly differences into account. + + UPDATE (10/29/2015 - B):
+ - Hour difference display now shows "4:15 hours ahead" instead of "4.25 hours ahead" (attached screenshot updated). + - Hook processing in views.py now uses a list for joining strings instead of string additions. - Diff:
-
Revision 20 (+175 -5)
- Removed Files:
- Added Files:
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
-
Now that we're showing this using a time notation, we can probably skip the word "hours" ("4:00 hours" seems weird, and "4:30 hours" seems weirder)
-
Can we move all of this computation to happen after the
etag_if_none_match
call? We don't want to do this if the user's browser already has it cached. -
I suspect we should show something else (or not show this at all) if
request.user
is the same asuser
. I know I'm in my own timezone! -
Can we localize this? We also should be able to skip the
six.text_type
call.td_msg = _('Same local time as you (%s)') % requsr_tz
-
I know the existing text in here isn't localized, but we should mark these words (and the others in here) for translation. I think we should also put assigned/posted on separate lines.
- Change Summary:
-
Text localization fixes and rearrangement of code in views.py. Minor infobox UI changes.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: (FIXED) I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): (FIXED) I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch.
UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
UPDATE (10/29/2015 - A):
- Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. - Hour difference calculation in views.py now takes quarterly differences into account. UPDATE (10/29/2015 - B):
- Hour difference display now shows "4:15 hours ahead" instead of "4.25 hours ahead" (attached screenshot updated). - Hook processing in views.py now uses a list for joining strings instead of string additions. + + LATEST UPDATE (11/02/2015):
+ - Time difference calculation and review request statistics code now appears after the etag_if_none_match call. + - UI and text localization changes to the user infobox. - Diff:
-
Revision 21 (+176 -5)
- Removed Files:
- Added Files:
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
-
If you do:
:py:class:`~reviewboard.extensions.hooks.UserInfoHook`
it will still link to the right class, but it will render as
UserInfoHook
. -
-
-
-
-
-
How about:
review_requests_sent = ( ReviewRequest.objects .public(user=request.user) .filter(submitter=user) .count() )
Does this include ALL sent rrs or only the open ones?
-
-
- Change Summary:
-
Minor fixes to extension hook code and documentation, and to text type in views.
- Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: (FIXED) I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): (FIXED) I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch.
UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
UPDATE (10/29/2015 - A):
- Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. - Hour difference calculation in views.py now takes quarterly differences into account. UPDATE (10/29/2015 - B):
- Hour difference display now shows "4:15 hours ahead" instead of "4.25 hours ahead" (attached screenshot updated). - Hook processing in views.py now uses a list for joining strings instead of string additions. ~ LATEST UPDATE (11/02/2015):
~ UPDATE (11/02/2015):
- Time difference calculation and review request statistics code now appears after the etag_if_none_match call. - UI and text localization changes to the user infobox. + + UPDATE (11/14/2015):
+ - Minor fixes to extension hook code and documentation. + - Change an occurrence of unicode
tosix.text_type
in views.py. - Diff:
-
Revision 22 (+179 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
- Change Summary:
-
Hook rendering now does the
mark_safe
. - Description:
-
Adds three pieces of information to the user info box:
1) Hour difference with local computer 2) User's review requests 3) User's assigned requests Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
NOTE: (FIXED) I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
UPDATE (10/20/2015): (FIXED) I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch.
UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
UPDATE (10/29/2015 - A):
- Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. - Hour difference calculation in views.py now takes quarterly differences into account. UPDATE (10/29/2015 - B):
- Hour difference display now shows "4:15 hours ahead" instead of "4.25 hours ahead" (attached screenshot updated). - Hook processing in views.py now uses a list for joining strings instead of string additions. UPDATE (11/02/2015):
- Time difference calculation and review request statistics code now appears after the etag_if_none_match call. - UI and text localization changes to the user infobox. UPDATE (11/14/2015):
- Minor fixes to extension hook code and documentation. - Change an occurrence of unicode
tosix.text_type
in views.py.+ + UPDATE (11/21/2015):
+ - Moved the mark_safe
for the extension hook to be done internally within the hook's render function. - Diff:
-
Revision 23 (+180 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
- Change Summary:
-
Minor fixes to views.py, hooks.py, user_infobox.html, and extension hook documentation. Editted
Description
andTesting Done
sections to be more consistent with commit messages. - Description:
-
~ Adds three pieces of information to the user info box:
~ 1) Hour difference with local computer ~ When hovering over a user's name, an info box appears showing their avatar/photo, name, e-mail address, and some other information. It's somewhat useful, but could be more useful.
~ This change adds a couple new pieces of information: - 2) User's review requests - 3) User's assigned requests ~ Adds a UserInfoBoxHook to allow for more information to be added. Contains documentation on hook (WIP).
~ 1) Their timezone and how many hours ahead/behind you they are (to help determine if they'd be available at the moment).
+ 2) Some review request stats (how many review requests they have been assigned to, and how many they have had out for review). ~ NOTE: (FIXED) I did a git add -A and the index.rst and generating-documentation.rst got added into the review request. Will remove them in the next post.
~ A new
UserInfoExtensionHook
is also created to provide addtional information for this box, should the need arise. That way, third-parties can integrate other services they use with this box. Documentation and example usage for the new hook are also provided.- - UPDATE (10/20/2015): (FIXED) I can't get rid of the generating-documentation.rst file. If all fails, I will have to back everything up and create a new git branch.
- - UPDATE (10/22/2015): Top priority for this review request is feedback on the documentation.
- - UPDATE (10/29/2015 - A):
- - Extension hook documentation: get_extra_context function now returns a dict, and render function now takes the correct params. - - Hour difference calculation in views.py now takes quarterly differences into account. - - UPDATE (10/29/2015 - B):
- - Hour difference display now shows "4:15 hours ahead" instead of "4.25 hours ahead" (attached screenshot updated). - - Hook processing in views.py now uses a list for joining strings instead of string additions. - - UPDATE (11/02/2015):
- - Time difference calculation and review request statistics code now appears after the etag_if_none_match call. - - UI and text localization changes to the user infobox. - - UPDATE (11/14/2015):
- - Minor fixes to extension hook code and documentation. - - Change an occurrence of unicode
tosix.text_type
in views.py.- - UPDATE (11/21/2015):
- - Moved the mark_safe
for the extension hook to be done internally within the hook's render function. - Testing Done:
-
~ Hovering over a test account usernames on a local test server.
~ UPDATE (10/20/2015): Will have to re-test the hook after the architecture overhaul. ~ Moused over usernames to verify that the infobox appears with the new (and old) pieces of information displays correctly.
~ Overrode get_extra_context
to ensure that additional information added via the extension hook displays correctly.- UPDATE (10/28/2015): Tested the hook within the user_infobox function in views.py. - Diff:
-
Revision 24 (+179 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
- Change Summary:
-
Minor ReviewBot under-indent fix.
- Diff:
-
Revision 25 (+179 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
- Change Summary:
-
Added minor
common.less
CSS fix to custom info text on infobox. Added code inviews.py
to split custom context into different sections. - Diff:
-
Revision 26 (+189 -5)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
- Change Summary:
-
Added entity tag updating for timezone info, RR statistics, custom rendering context. Updated extension hook documentation to reflect this change.
- Description:
-
When hovering over a user's name, an info box appears showing their avatar/photo, name, e-mail address, and some other information. It's somewhat useful, but could be more useful.
This change adds a couple new pieces of information: 1) Their timezone and how many hours ahead/behind you they are (to help determine if they'd be available at the moment).
2) Some review request stats (how many review requests they have been assigned to, and how many they have had out for review). ~ A new
UserInfoExtensionHook
is also created to provide addtional information for this box, should the need arise. That way, third-parties can integrate other services they use with this box. Documentation and example usage for the new hook are also provided.~ A new
UserInfoExtensionHook
is also created to provide additional information, and associated entity tag data, for this box, should the need arise. That way, third-parties can integrate other services they use with this box. Documentation and example usage for the new hook are also provided. - Diff:
-
Revision 27 (+211 -8)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
- Change Summary:
-
Removed unnecessary blank lines and commenting, and renamed variables associated with the local user's timezone and datetime, in
views.py
. Readded a blank line inrb_extensions.py
. - Diff:
-
Revision 28 (+201 -8)
-
Tool: Pyflakes Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/extensions/templatetags/rb_extensions.py reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html
- Change Summary:
-
Revised extension hook documentation regarding
get_etag_data
inuser-infobox-hook.rst
. Minor fixes and blank line removals inviews.py
.
-
Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py reviewboard/extensions/hooks.py Ignored Files: docs/manual/extending/extensions/hooks/index.rst docs/manual/extending/extensions/hooks/user-infobox-hook.rst reviewboard/static/rb/css/common.less reviewboard/templates/accounts/user_infobox.html