Commit Graph

24 Commits

Author SHA1 Message Date
Javi Martín
38b38d1fcc Rename Poll::Question::Answer to Poll::Question::Option
Having a class named `Poll::Question::Answer` and another class named
`Poll::Answer` was so confusing that no developer working on the project
has ever been capable of remembering which is which for more than a few
seconds.

Furthermore, we're planning to add open answers to polls, and we might
add a reference from the `poll_answers` table to the
`poll_question_answers` table to property differentiate between open
answers and closed answers. Having yet another thing named answer would
be more than what our brains can handle (we know it because we did this
once in a prototype).

So we're renaming `Poll::Question::Answer` to `Poll::Question::Option`.
Hopefully that'll make it easier to remember. The name is also (more or
less) consistent with the `Legislation::QuestionOption` class, which is
similar.

We aren't changing the table or columns names for now in order to avoid
possible issues when upgrading (old code running with the new database
tables/columns after running the migrations but before deployment has
finished, for instance). We might do it in the future.

I've tried not to change the internationalization keys either so
existing translations would still be valid. However, since we have to
change the keys in `activerecord.yml` so methods like
`human_attribute_name` keep working, I'm also changing them in places
where similar keys were used (like `poll_question_answer` or
`poll/question/answer`).

Note that it isn't clear whether we should use `option` or
`question_option` in some cases. In order to keep things simple, we're
using `option` where we were using `answer` and `question_option` where
we were using `question_answer`.

Also note we're adding tests for the admin menu component, since at
first I forgot to change the `answers` reference there and all tests
passed.
2024-06-13 19:13:01 +02:00
Javi Martín
af7c37634d Remove poll votation types
Unfortunately this feature wasn't properly reviewed and tested, and it
had many bugs, some of them critical and hard to fix, like validations
being skipped in concurrent requests.

So we're removing it before releasing version 1.1. We might add it back
in the future if we manage to solve the critical issues.

This commit reverts commit 836f9ba7.
2019-10-30 18:48:55 +01:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
lalo
23d36835d7 Add Admin changes to create Poll:Questions with votation type 2019-06-12 19:44:14 +02:00
Javi Martín
eb13994999 Extract partial for form to show results and stats 2019-05-22 11:50:03 +02:00
Javi Martín
354b183e17 Create reports
This table will store which reports (stats, results, ...) will be shown
for a certain process (polls, budgets, ...).

Note Rails fails to save a poll and its report when both are new records
if we add a `validate :process, presence: true` rule. Since it caused a
lot of trouble when creating records for tests during factories rule
completely. Instead, I've created the `results_enabled=` and
`stats_enabled=` methods, so tests are easier to set up, while also
automatically creating a report if it doesn't already exist. This also
decouples form structure and database implemenation.

Originally I named this table `enabled_reports` and instead of having
`stats` and `results` columns, it had an `enabled` column and a `kind`
column, which would be set to "stats" or "results". However, although
that table would allow us to add arbitrary reports easily, I found the
way we had to handle the `has_many` relationship was a bit too complex.
2019-05-22 11:50:03 +02:00
Julian Herrero
18bd2c7de8 Refactor (improve readability) 2019-03-15 09:55:12 +01:00
João Lutz
47a33ea86c Enable options to show stats and results with any type of voter 2019-01-05 14:08:47 -02:00
decabeza
608f1996ce Fixes admin layout 2018-05-23 08:08:54 -04:00
Angel Perez
44b1eb929a Move 'Show stats and results' form to Admin::Poll#results tab 2018-05-23 07:27:12 -04:00
Bertocq
3daf957813 Fix table tag indentation 2017-10-19 13:35:04 +02:00
rgarcia
7ddc225d8b fixes alignment for link params 2017-10-19 11:28:09 +02:00
rgarcia
1ae91017b4 adds heading to results by booth table 2017-10-19 11:28:09 +02:00
rgarcia
5d3654f92f refactors recounts into partial 2017-10-19 11:28:09 +02:00
rgarcia
fcbcca3b60 sorts booths by name 2017-10-19 11:28:09 +02:00
rgarcia
0e8dc55b1b updates translations 2017-10-19 11:28:09 +02:00
rgarcia
6b98bc0086 displays links to results by booth 2017-10-19 11:28:09 +02:00
rgarcia
cf400f3082 refactors poll results into partial 2017-10-19 11:28:09 +02:00
Bertocq
e9294f2a22 Switch from valid_answers to question_answers usage for Poll Questions 2017-10-18 01:32:15 +02:00
Bertocq
b5cf28cb35 Swap Poll White/Null/Total usage for Poll Recount 2017-10-02 15:46:49 +02:00
Bertocq
e8d748a881 Add Poll Total recount to officing and admin 2017-09-14 15:33:58 +02:00
Juanjo Bazán
2d722f1ad4 redux admin poll subnav 2017-02-14 14:57:49 +01:00
Juanjo Bazán
0bd87c7e43 extracts results from admin's poll/show 2017-02-14 14:26:46 +01:00