-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record delegated votes #67
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3ae0d2f
to
298b83e
Compare
sauloperez
commented
Oct 30, 2020
on(:ok) do | ||
current_question.reload | ||
render :update_vote_button | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs serious refactoring extracting UnvoteDelegation to start with. We also should give it a crack at extracting the DelegationVotesController
5c8437d
to
be2e4cb
Compare
sauloperez
commented
Oct 30, 2020
5672425
to
66ed023
Compare
sauloperez
commented
Nov 2, 2020
The extra encapsulation this brings reduces complexity, makes things more changeable and less brittle. Code within a `class_eval` is in a very shaky ground. Next step is to have a separate controller to vote delegation and call this command instead of monkey patching `Decidim::Consultations::VoteQuestion`. We're one step closer.
This keeps track of every change on a vote in the `versions` table. We'll have things like: ```sql decidim_module_action_delegator_development_app_development=# select * from versions order by id desc limit 2; -[ RECORD 1 ]--+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- id | 2006 item_type | Decidim::Consultations::Vote item_id | 134 event | destroy whodunnit | Ø object | {"id": 134, "created_at": "2020-10-28T17:48:44.453Z", "updated_at": "2020-10-28T17:48:44.453Z", "decidim_author_id": 2, "decidim_user_group_id": null, "decidim_consultation_question_id": 8, "decidim_consultations_response_id": 15} created_at | 2020-10-28 17:49:18.02389 object_changes | (...) -[ RECORD 2 ]--+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- id | 2005 item_type | Decidim::Consultations::Vote item_id | 134 event | create whodunnit | Ø object | Ø created_at | 2020-10-28 17:48:44.453978 object_changes | (...) ``` Note the specs use PaperTrail's RSpec helpers documented in https://github.com/paper-trail-gem/paper_trail#7b-rspec and enabled by https://github.com/decidim/decidim/blob/16e96597d961efa7d9698bc537dcb9508cff7b3a/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb#L22.
Extracting a new WhodunnitVote model.
This makes it painfully obvious there's a conditional branch depending on the delegation that would be better off as a separate controller. We simply make the two ifs look alike to point out they are part of the same issue.
This brings more confidence and greater control over the tests.
31c17e0
to
6d30f7f
Compare
sauloperez
commented
Nov 5, 2020
fa36537
to
01bb832
Compare
01bb832
to
509ec8e
Compare
This lets us trace which vote version was related to a delegation.
This is intended to be used to fetch all versions of votes performed through a delegation in case a court asks us to do so.
We pass it from the command or controller instead of assuming it was used and fetch it from DB.
509ec8e
to
831bd17
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #66
This keeps track of every change on a delegated vote in the
versions
table. We'll have things like:(some columns were excluded from the output)
Missing