-
-
-
-
Is there a need for the intermediate variable "action"? I know it looks better, but you can just attach .save to the Action() init.
-
-
-
the "review_published.send()" can be taken out of the if statement since it will be called anyway. So: verb = 'published a review' if self.is_reply(): verb = 'published a reply' reply_published.send(sender=self.__class__, user=user, reply=self)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
[WIP] Action feed prototype using a separate table for storing actions
Review Request #3151 — Created June 19, 2012 and discarded
In the current stage, the action feed is the default dashboard view and it displays info related to [almost] any update to the requests the user has previously visited. The action-boxes contain the review request id and summary, the name of the user who performed the action and the type of action performed. Still to-do: * restyle the dashboard entries box * make the action boxes expandable and implement ajax calls to display their content
No tests yet - will start running them/ adding new ones once this is a bit more advanced.
Description | From | Last Updated |
---|---|---|
Alphabetical order. |
ME medanat | |
Alphabetical order. |
ME medanat | |
the "review_published.send()" can be taken out of the if statement since it will be called anyway. So: verb = 'published … |
ME medanat | |
intermediate variable again. |
ME medanat | |
I believe this fits on one line. |
ME medanat | |
Alphabetical order. |
ME medanat | |
Keep this empty line before the return. |
ME medanat | |
No need for this empty line. |
ME medanat | |
No need for this empty line. |
ME medanat | |
No need for this empty line. |
ME medanat | |
No need for this empty line. |
ME medanat | |
May I ask why you are using !important here? |
ME medanat | |
No need for those empty lines. |
ME medanat | |
No need for the empty lines here. |
ME medanat | |
Indent all by one. |
ME medanat | |
No need for this extra line. |
ME medanat | |
indent "compressed_css" |
ME medanat | |
indent "include" and "{{datagrid...}}" |
ME medanat | |
No need for space between 'view' and : |
ME medanat | |
Remove space before ':' |
ME medanat | |
Space after ':' |
ME medanat | |
Remove space before the ':'. |
ME medanat | |
Indent inside the '{%', not outside. i.e.: {% for {% if {% definevar ... {% endif {% endfor |
ME medanat | |
One more level of indentation here. |
ME medanat | |
Alphabetical order. |
ME medanat | |
No need for this empty line. |
ME medanat | |
Indent within the '{%'. |
ME medanat | |
Indent within the '{%'. |
ME medanat | |
Indent within the '{%'. |
ME medanat | |
Tiny optimization: _request = self.request Since self.request is being called three times within the method body. Less .'s means faster … |
ME medanat | |
Add an empty line here. |
ME medanat | |
Wouldn't it be easier to do this calculation before hand and leave the reasoning in a comment? i.e.: = 31536000 … |
ME medanat | |
Alphabetical order. |
ME medanat | |
Translate: Review request. Remove the trailing white space. |
ME medanat | |
You can shift the the {% %} logic all the way to the left. That saves on white space being … |
ME medanat | |
Translate: Posted. |
ME medanat | |
Translate: Updated. |
ME medanat | |
Translate: Ago. |
ME medanat | |
We're probably not doing great about alphabetical order here, but might as well place this above the others. |
chipx86 | |
Just for readability, put each parameter on its own line (and start with the Action.objects.create) line. |
chipx86 | |
Same as above. Actually, given that we do this twice, can we just set a couple common variables and then … |
chipx86 | |
Same here. |
chipx86 | |
Same here. Blank line after this. I prefer blank lines between blocks and other code (like around an if, for, … |
chipx86 | |
Was this intentional? It looks like a mistake. |
chipx86 | |
Same. |
chipx86 | |
Generally, (and I know a lot of older code doesn't do this), docs should be in this format: """One-line summary. … |
chipx86 | |
No blank line. |
chipx86 | |
Instead of this, do this above: @property def request_display_id(self): ... |
chipx86 | |
Are we expecting that the action feed will now be the default view? I'd be a little concerned about that, … |
chipx86 | |
No blank line. This should subclass from object. |
chipx86 | |
Can you document why we need this? |
chipx86 | |
In general, we should use "pk" instead of "id" when referring to the primary key of the model. Same with … |
chipx86 | |
Add a trailing comma. |
chipx86 | |
Alignment is off. |
chipx86 | |
Space before { |
chipx86 | |
All indentation should be 2 lines instead of 4. |
chipx86 | |
Another case of {. Same with others in this file. |
chipx86 | |
No blank line. |
chipx86 | |
No spaces around = |
chipx86 | |
One space indentation. |
chipx86 | |
No spaces inside {{..}} |
chipx86 | |
Let's go ahead and use 'action-feed'. '-' is nicer in URLs. |
chipx86 | |
No blank line. |
chipx86 | |
We should avoid queries on these objects. So instead, do: if self.review_id: return self.review_id elif self.changedesc_id: return self.changedesc_id This should … |
chipx86 | |
No blank line. |
chipx86 | |
Should also check review_id and changedesc_id, and return some default. |
chipx86 | |
action-feed. |
chipx86 | |
Add a trailing comma. |
chipx86 | |
local_site_id |
chipx86 | |
Indentation looks wrong. This map should only be defined once, outside the function. |
chipx86 | |
You should only have one var statement, formatted like: var body = ..., request_url = ...; |
chipx86 | |
Best as: var changeitems = $('') .appendTo(body); |
chipx86 | |
This var needs to also be before. In JavaScript, all variables when compiling in the VM are moved to the … |
chipx86 | |
One var statemnet. |
chipx86 | |
Best to append changeitem after you've completely populated it, at the end of the loop. |
chipx86 | |
Best done as: field_name = field_name_map[field] || field |
chipx86 | |
Should be: changeitem.append($('').text(field_name)); This will do the right thing if there are characters in field_name that need escaping (such as … |
chipx86 | |
In general, instead of 'in', it's best to do field_changed.hasOwnProperty('added'). The reason being that if anything were to populate the … |
chipx86 | |
Hmm, not sure what you're doing here? I don't know that an object for added/removed is correct. |
chipx86 | |
In JavaScript, always use braces. Given that we do field_changed[type] a lot, I would just pull that value out once … |
chipx86 | |
vars must be at the top of the scope. |
chipx86 | |
===. Avoids a cast. |
chipx86 | |
Build this with jQuery's methods to ensure there aren't HTML encoding issues. |
chipx86 | |
No blank line. |
chipx86 | |
Braces. Why the length check? |
chipx86 | |
One var, top of scope. |
chipx86 | |
No blank lines. For the field_changed length check, you'll want to pull the length out into a variable first. Saves … |
chipx86 | |
hasOwnProperty. |
chipx86 | |
Build with jQuery. |
chipx86 | |
hasOwnProperty. |
chipx86 | |
Build with jQuery. |
chipx86 | |
Blank line. |
chipx86 | |
hasOwnProperty. |
chipx86 | |
Alignment for multiline is wrong. Should use === for comparison. One set of var statements. |
chipx86 | |
Maybe oldValue/newValue? |
chipx86 | |
=== |
chipx86 | |
All this should be built with jQuery. |
chipx86 | |
=== Alignment is wrong. |
chipx86 | |
Move var out of the for, since it's really going to be promoted to the top of the "else if" … |
chipx86 | |
Build with jQuery. Make sure to always use braces. |
chipx86 | |
If so, maybe we should log that. |
chipx86 | |
Blank line. |
chipx86 | |
Build with jQuery. |
chipx86 | |
Blank line. |
chipx86 | |
Alignment is off. The whole function should build with jQuery. |
chipx86 | |
Same. |
chipx86 | |
One var. |
chipx86 | |
Same. |
chipx86 | |
Alignment is off. |
chipx86 | |
$('') .appendTo(body); |
chipx86 | |
One var. |
chipx86 | |
Move this into the declaration above, before my proposed appendTo. |
chipx86 | |
Move var up, and pull the length out. |
chipx86 | |
vars go first. comment can probably just be defined in each loop that needs it. |
chipx86 | |
Build with jQuery. These comments apply to everywhere else in the JavaScript. |
chipx86 | |
No blank line. |
chipx86 | |
No blank line. The resource needs a description. This will be auto-generated for our API docs page. Make sure to … |
chipx86 | |
I've noticed this a couple times now. Instead of repeating it, you should define a Manager class that the Action … |
chipx86 | |
You can combine these. |
chipx86 | |
You can do: if field in ('screenshot_captions, 'file_captions'): |
chipx86 |
- Change Summary:
-
Changes: Implemented Yazan's feedback. Added a request summary field to the actions table Join Action and ReviewRequestVisit tables (to only display updates for the requests the user visited) UI improvements (expandable boxes, Review request id and summary displayed on top, id links to the actual request, boxes colored different for reviews and changedescs) Next steps: Figure out how LocalSites affect the action feed Implement AJAX calls for expanded boxes
- Diff:
-
Revision 2 (+262 -12)
- Change Summary:
-
Added local sites logic Fixed some issues raised during past meetings Removed the expanding box functionality
- Description:
-
~ This is meant to be the starting point for the actual implementation.
~ Next steps (speaking in very general terms): ~ * restyle the action-boxes in the UI ~ * add the request summary as a field in the actions table ~ * implement the expansion functionality for the UI boxes ~ In the current stage, the action feed is the default dashboard view and it displays info related to [almost] any update to the requests the user has previously visited.
~ The action-boxes contain the review request id and summary, the name of the user who performed the action and the type of action performed. ~ ~ Still to-do:
~ * restyle the dashboard entries box + * make the action boxes expandable and implement ajax calls to display their content - Diff:
-
Revision 5 (+305 -36)
-
Quick review, mostly style.
-
Tiny optimization: _request = self.request Since self.request is being called three times within the method body. Less .'s means faster code.
-
-
Wouldn't it be easier to do this calculation before hand and leave the reasoning in a comment? i.e.: = 31536000 # 365 * 24 * 60 * 60 (1 year)
-
-
-
You can shift the the {% %} logic all the way to the left. That saves on white space being sent to the client.
-
-
-
- Change Summary:
-
Minor change to the html
- Diff:
-
Revision 8 (+305 -36)
- Added Files:
- Screenshots:
-
current lookcurrent lookcurrent look
-
-
We're probably not doing great about alphabetical order here, but might as well place this above the others.
-
Just for readability, put each parameter on its own line (and start with the Action.objects.create) line.
-
Same as above. Actually, given that we do this twice, can we just set a couple common variables and then create the action after this if/else?
-
-
Same here. Blank line after this. I prefer blank lines between blocks and other code (like around an if, for, etc.)
-
-
-
Generally, (and I know a lot of older code doesn't do this), docs should be in this format: """One-line summary. Multi-line content. """ Or in this case, just """One-line summary."""
-
-
-
Are we expecting that the action feed will now be the default view? I'd be a little concerned about that, as it changes everybody's workflow. Instead, I'd rather we keep the existing default, and then later we should add some easier way to select a default or quickly jump to the desired node from any page.
-
-
-
In general, we should use "pk" instead of "id" when referring to the primary key of the model. Same with the user above.
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Added the expandable box functionality for changedescs
- Diff:
-
Revision 10 (+648 -36)
- Change Summary:
-
Added the Action resource and the javascript for expanding the action boxes for reviews and changedescs. Open issues: * Creating the links for reviewed items feels a bit wrong, but I was trying to minimize the number of queries and make do with the available info * The file attachment comment resource doesn't provide a link to the actual file, so I'm just displaying the title, for now * The boxes containing replies are still ToDo
- Diff:
-
Revision 11 (+835 -38)
- Screenshots:
-
Expanded changedescsExpanded reviewsExpanded review (with top and bottom)
-
-
-
-
-
We should avoid queries on these objects. So instead, do: if self.review_id: return self.review_id elif self.changedesc_id: return self.changedesc_id This should return something when neither of the above conditionals match.
-
-
-
-
-
-
-
-
-
This var needs to also be before. In JavaScript, all variables when compiling in the VM are moved to the top of the scope.
-
-
-
-
Should be: changeitem.append($('<label/>').text(field_name)); This will do the right thing if there are characters in field_name that need escaping (such as when localized).
-
In general, instead of 'in', it's best to do field_changed.hasOwnProperty('added'). The reason being that if anything were to populate the base object with 'added' or whatever, this check could fail. By using hasOwnProperty, you ensure you're only looking up in field_changed. It also won't nest into the prototype, so it's a little quicker.
-
-
In JavaScript, always use braces. Given that we do field_changed[type] a lot, I would just pull that value out once up-front and reuse it.
-
-
-
-
-
-
-
No blank lines. For the field_changed length check, you'll want to pull the length out into a variable first. Saves on a recompute every iteration.
-
-
-
-
-
-
-
-
-
-
-
-
Move var out of the for, since it's really going to be promoted to the top of the "else if" block anyway.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
No blank line. The resource needs a description. This will be auto-generated for our API docs page. Make sure to follow the styles for other resources.
-
I've noticed this a couple times now. Instead of repeating it, you should define a Manager class that the Action uses, which will define a function for this. So: class Action(...): ... objects = ActionManager() Then in managers.py: class ActionManager(...): def from_visits(self): # That query here
-
-
- Change Summary:
-
Added the action resource to the docs.
- Diff:
-
Revision 13 (+908 -37)
-
This looks fine with the exception being the one I noted about the Manager (I don't mind this being a separate cleanup change on top of this), and the unit test failures where Action.submitter doesn't allow null. That needs to be fixed before this goes in. I'll be committing all these changes when done onto an action-feed branch, which will later be merged into master.