Commit Graph

52 Commits

Author SHA1 Message Date
Javi Martín
c5018e4a53 Remove obsolete video_url column in poll_questions table
This column isn't used since commit 4c0deb0ec because administrators can
associate videos to the answers since commit 5862eea51. The value of
this attribute isn't used in the public area since commit 8277e3cc2.
2025-03-26 16:42:04 +01:00
Javi Martín
5fa6db2226 Rename HTML attributes referencing poll options
Since now poll question answers have been renamed to poll question
options, using HTML IDs, classes and data attributes named `answer` was
confusing.
2024-06-13 19:13:05 +02:00
Javi Martín
8997ed316c Rename variables describing poll options as answers
Since we've renamed the class to `Option`, having variables, methods and
texts refering to it as `answer` was confusing.
2024-06-13 19:13:05 +02:00
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
decabeza
815a526d78 Add VotationType fields to admin poll question form 2022-10-18 10:38:59 +02:00
Julian Herrero
3a6e99cb8c Don't allow changing answers if the poll has started
Just like we did with questions.
2022-09-20 17:50:49 +02:00
Julian Herrero
8a26954bc5 Don't allow to modify questions for started polls
Adding, modifiying, and/or deleting questions for an already started
poll is far away from being democratic and can lead to unwanted side
effects like missing votes in the results or stats.

So, from now on, only modifiying questions will be possible only if
the poll has not started yet.
2022-09-20 17:50:35 +02:00
taitus
86ff4eeff9 Add consistency to back_links
In some cases (e.g. after editing or creating a resource
with errors) the default back_link did not redirect to the
expected page.

Now we force the back_links to the index pages, so we
always get the desired redirect.
2022-09-14 14:56:27 +02:00
Julian Herrero
24276a201e Remove useless answers show view
Until now, in order to edit an answer, we had to click on its title on
the table and then on the "Edit answer" link.

That was tedious and different from what we usually do in the admin
section. Furthermore, the code for the answers table was written twice
and when we modified it we forgot to update the one in the `show`
action, meaning the table here provided less information than the
information present in the answers tables.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2022-09-14 14:45:35 +02:00
Javi Martín
78ed5a8bfc Use caption instead of tr to label the answers table
We might change the style of this caption or remove it completely in the
future. In the meantime, we use the right HTML tag for the task to give
information regarding what the table is about, and that tag is
`<caption>`.
2022-09-14 14:45:35 +02:00
taitus
405b37f605 Load answer through question in answers controller
We are simplifying the load answer and we can remove the ambiguous
hidden field from answer form.
2022-09-14 14:45:33 +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
7bf4e4d611 Sanitize descriptions in the views
Sanitizing descriptions before saving a record has a few drawbacks:

1. It makes the application rely on data being safe in the database. If
somehow dangerous data enters the database, the application will be
vulnerable to XSS attacks
2. It makes the code complicated
3. It isn't backwards compatible; if we decide to disallow a certain
HTML tag in the future, we'd need to sanitize existing data.

On the other hand, sanitizing the data in the view means we don't need
to triple-check dangerous HTML has already been stripped when we see the
method `auto_link_already_sanitized_html`, since now every time we use
it we sanitize the text in the same line we call this method.

We could also sanitize the data twice, both when saving to the database
and when displaying values in the view. However, doing so wouldn't make
the application safer, since we sanitize text introduced through
textarea fields but we don't sanitize text introduced through input
fields.

Finally, we could also overwrite the `description` method so it
sanitizes the text. But we're already introducing Globalize which
overwrites that method, and overwriting it again is a bit too confusing
in my humble opinion. It can also lead to hard-to-debug behaviour.
2019-10-21 21:32:02 +02:00
Javi Martín
bbbd0820c1 Use active record translations in votation types
We need to build a votation type object in the form so translations are
applied automatically.
2019-10-07 01:56:24 +02:00
Javi Martín
6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00
lalo
23d36835d7 Add Admin changes to create Poll:Questions with votation type 2019-06-12 19:44:14 +02:00
Julian Herrero
e63a862882 Use double quotes in app/views/admin/poll 2019-03-19 12:16:50 +01:00
decabeza
6f324c6931 Unifies styles and views for admin polls 2018-07-31 12:48:01 +02:00
decabeza
bdc3538100 Merge branch 'master' into polls-admin-polish 2017-10-11 19:12:34 +02:00
iagirre
2b10b59e2a Order in the admin page using jquery-ui sortable widget. 2017-10-10 16:38:29 +02:00
decabeza
9dc8a0fb34 fixes questions table with long links on description 2017-10-09 19:44:12 +02:00
decabeza
36d39503e8 improves admin poll questions show 2017-10-09 19:42:53 +02:00
decabeza
9ec57f68c2 changes list of videos links on polls question admin 2017-10-07 14:49:36 +02:00
Raimond Garcia
23ef9ded1d Merge branch 'master' into aperez-edit-poll-question-answers 2017-10-06 18:47:04 +02:00
Raimond Garcia
8576f59af1 Merge branch 'master' into aperez-edit-poll-question-answers 2017-10-06 18:14:00 +02:00
Angel Perez
63eaa0bef6 Allow Poll::Question::Answer edit
As requested by #1992
2017-10-06 09:48:17 -04:00
decabeza
dd69401477 Merge branch 'master' into question-answer-documents 2017-10-06 15:18:42 +02:00
Raimond Garcia
108d4104e8 Merge pull request #1986 from wairbut-m2c/iagirre-remove-documents-questions
Iagirre remove documents questions
2017-10-06 14:07:21 +02:00
decabeza
de9b599578 Merge branch 'master' into question-answer-documents 2017-10-06 13:55:49 +02:00
decabeza
3ce98b6cdf fixes answer documents path on polls questions show 2017-10-06 02:09:01 +02:00
María Checa
284fdea2e6 Improved answer documents and question summary views 2017-10-06 01:23:41 +02:00
Raimond Garcia
c72f95c72b Merge branch 'master' into aperez-admin-question-videos 2017-10-06 01:12:22 +02:00
Raimond Garcia
3d100d1e93 Merge branch 'master' into iagirre-remove-documents-questions 2017-10-06 01:02:56 +02:00
Angel Perez
5862eea516 Add controllers/views for Poll::Question::Answer::Video 2017-10-05 12:34:20 -04:00
iagirre
75d841e2fe Fixed the correct specs and views to make the test pass. 2017-10-05 15:31:21 +02:00
decabeza
ea4b534ee9 improves layout for poll questions views 2017-10-05 11:06:00 +02:00
rgarcia
1cf9bc4ad1 adds images to anwers 2017-10-04 23:56:09 +02:00
Angel Perez
f4774894e7 Adapt Admin::Poll::Question 'show' action to new design
Changes required as per issues #1855 and #1951

Fixes PR #1977, note n° 2
2017-10-04 16:59:23 -04:00
rgarcia
1f2aa301d4 adds specs for answer's index and create 2017-10-04 16:33:52 +02:00
Raimond Garcia
44d0c04e38 Merge branch 'master' into aperez-admin-questions-section 2017-10-04 14:13:20 +02:00
Angel Perez
1cc0816dcd Create 'poll_question_answers' controller and views 2017-10-03 23:23:50 -04:00
María Checa
9871503c5e Restored views 2017-10-03 21:00:40 +02:00
Angel Perez
d9d03079e1 Adapt Poll::Question 'show' action to mockup 2017-10-03 13:29:07 -04:00
María Checa
355d68c7f8 Added video URL and document to poll question preview 2017-09-07 17:15:20 +02:00
decabeza
6c5513ab38 replaces back_link partial to back_link_to helper 2017-07-26 18:22:45 +02:00
kikito
bc763c34c2 Removes Poll::Question.summary from views 2017-01-30 18:41:24 +01:00
kikito
ab63c18d01 Moves geozones from questions to polls in admin show views 2017-01-24 18:08:48 +01:00
Alberto Garcia Cabeza
241ddcb163 polish styles for tables, assignments and searches on polls admin 2016-12-28 13:45:36 +01:00
Alberto Garcia Cabeza
71fa9afab8 adds edit button on questions show 2016-12-16 14:09:22 +01:00
Alberto Garcia Cabeza
596cf1dc38 adds styles to admin question show 2016-11-18 13:13:40 +01:00