We want to provide functionality so we can adequately replace the Ideatorrent hosted app: https://sourceforge.net/apps/ideatorrent/sourceforge/
See also discussion at [79bed0f2].
- create a
VotableArtifact class (will be later used as a mixin with other artifact classes). It should have
Fields for votes_up (int), votes_down (int), votes_up_users (list), votes_down_users (list), and methods
vote_down which require a User as an argument. You can only vote once, so changing your vote would remove it from the other list.
- In ForgeTracker, make
VotableArtifact also. We are not 100% sure how ming handles Fields from mixins, but it should work automatically. It does for single inheritance.
- Include the votes_up_i and votes_down_i in the
Ticket.index() method. Also add
votes_total_i which is
down. (The _i suffix makes them an int in solr schema). Document them in the tracker's search help text.
- Make sure every time a vote occurs, the object is saved to solr. This can happen in either VotableArtifact or the Ticket class, whichever makes most sense.
- Add a ForgeTracker admin option so that project admins can enable/disable voting on tickets.
- If that is enabled for a tracker, any visitor with 'post' permission on a ticket should be able to click to vote up or down. However, a visitor must also be logged in (i.e. anonymous with 'post' access cannot vote).
- The UI should look like http://screencast.com/t/T2rvuefPa6F See the notes for the HTML and CSS. If the user has already voted, the current vote should show up in red. (The appearance may end up somewhat different from the screenshot, since that is using our non-OSS theme)
- Use AJAX to POST to a URL like /p/allura/tickets/1234/vote. Our CSRF protection will automatically be added to any html form (a _session_id hidden field), but you should make sure it is submitted with ajax too.
- If voting is enabled for a tracker, show the
votes_total field as a column in the ticket listing pages. You should be able to click on it to sort by it.