Javi Martín
42d2e5b3ad
Apply Rails/InverseOf rubocop rule
...
Not doing so has a few gotchas when working with relations, particularly
with records which are not stored in the database.
I'm excluding the related content file because it's got a very peculiar
relationship with itself: the `has_one :opposite_related_content` has no
inverse; the relation itself is its inverse. It's a false positive since
the inverse condition is true:
```
content.opposite_related_content.opposite_related_content.object_id ==
content.object_id
```
2019-10-25 19:29:12 +02:00
Javi Martín
94d2496f8f
Add missing has_many relations for users
...
Usually when we specify a `belongs_to` relations, we also specify its
equivalent `has_many`. That allows us to write, for example:
`topic.user.topics`.
2019-10-25 19:27:30 +02:00
Javi Martín
27ed26d6f2
Remove unnecessary class names in relations
...
Just like we do in the Budget module, and in some places in the Poll and
Legislation modules, we don't need to specify the class name when the
name of the relation matches the name of a class in the same module.
2019-10-25 19:03:14 +02:00
Javi Martín
fda53a0a2a
Remove unnecessary foreign_key options
...
When we specify `belongs_to :author`, ActiveRecord automatically uses
`author_id` as the foreign key.
2019-10-25 19:03:10 +02:00
Javi Martín
d0d681a44b
Add and apply EmptyLineAfterGuardClause rule
...
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.
In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
70a07c095f
Add and apply Style/BlockDelimiters rubocop rule
...
We were already using it most of the time, but there were a few places
were we used brackets for multiline blocks.
2019-10-05 14:44:14 +02:00
Javi Martín
d42b9ff4a5
Extract method to get valid answers to a question
...
This way we remove duplication and we avoid a multi-line block in a
validation rule, which made the code hard to read.
2019-10-05 14:34:52 +02:00
Javi Martín
9fe8c47528
Apply Rails/SafeNavigation rubocop rule
2019-09-10 21:43:39 +02: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
lalo
7c9c50f4c6
Add Model changes to work with votation_types
2019-06-12 19:32:41 +02:00
Javier Martín
d57025696f
Merge pull request #3503 from consul/backport-blank_votes
...
Improve poll stats
2019-05-21 14:23:13 +02:00
Bertocq
b8dbdaf9a7
Move question most voted answer from boolean to a enumerable max by total_votes
2019-05-21 13:26:44 +02:00
Bertocq
f4260788eb
Add Partial Results counts to question answers
2019-05-21 13:26:44 +02:00
decabeza
e026412389
Add button to delete a poll
2019-05-14 16:46:56 +02:00
decabeza
cb22e6cbfb
Merge branch 'master' into proposal-dashboard
2019-04-23 17:12:47 +02:00
Juanjo Bazán
7ab602175a
makes models inherit from ApplicationRecord
2019-04-17 17:40:56 +02:00
decabeza
eda6ea7f12
Merge branch 'master' into dashboard
2019-03-26 16:45:48 +01:00
Julian Herrero
3ba961a2d7
Use double quotes in models
2019-03-14 17:25:43 +01:00
Javi Martín
ccdbdb26ba
Fix poll question with non-underscored locales
...
Ruby can't have hyphens in method names, so sending something like
`title_pt-BR=` would raise an exception.
2018-10-23 14:23:10 +02:00
Javi Martín
863b326142
Validate both the model and its translations
...
This way we guarantee there will be at least one translation for a model
and we keep compatibility with the rest of the application, which
ideally isn't aware of globalize.
2018-10-22 16:30:28 +02:00
Javi Martín
2ab49a1832
Refactor globalize models code using a concern
...
I've chosen the name "Globalizable" because "Translatable" already
existed.
2018-10-22 16:28:53 +02:00
Javi Martín
d1249d0b4f
Update poll questions translatable fields
...
We need to replace ".title=" by ".title_#{locale}=" in one place because
for some reason globalize builds a new translation record when using the
latter but it doesn't build one when using the former.
2018-10-22 16:13:30 +02:00
decabeza
546105d989
Merge branch 'master' into dashboard-master
2018-10-19 01:48:37 +02:00
Julian Herrero
5e6248d2ac
Make questions translatable
2018-09-20 17:11:53 +02:00
Juan Salvador Pérez García
50f73abb0c
Fixes #voodoorai2000 comments
...
Fixes some comments from #voodoorai2000 for the PR to consul
2018-07-27 16:30:03 +02:00
Juan Salvador Pérez García
2be107f4da
Specs
...
Added specs and fixed some issues found after executing them
2018-07-17 17:57:30 +02:00
Juan Salvador Pérez García
2ce9f95283
Polls in the dashboard
...
A reduced version of polls has been added to the dashboard
2018-07-17 17:57:30 +02:00
María Checa
35f24b519d
Merge branch 'master' into 1786-poll_results
2017-10-18 17:33:16 +02:00
Bertocq
0a5ee3f861
Remove valid_answers usage on Poll Question model
2017-10-18 01:30:21 +02:00
María Checa
610aea2c72
Added new methods to Poll question and Poll answers
2017-10-17 18:30:20 +02:00
Bertocq
0b5eed090e
Fix no-answer scenario for question valid answers
2017-10-16 19:54:07 +02:00
iagirre
943c1f23af
Spects added to test the order of answers. Default order for question_answers set.
2017-10-10 16:38:55 +02:00
iagirre
5b129b933f
Removed documents from questions (documentable from model and uploader from _form in views)
2017-10-05 13:38:19 +02:00
rgarcia
4aaf681d2d
uses new answer model in user facing interface
2017-10-04 17:45:51 +02:00
rgarcia
461410a79d
adds consistency to answer's namespace
2017-10-04 17:06:29 +02:00
Raimond Garcia
44d0c04e38
Merge branch 'master' into aperez-admin-questions-section
2017-10-04 14:13:20 +02:00
Angel Perez
1d1b861ddf
Create 'poll_question_answers' table
2017-10-03 23:04:50 -04:00
María Checa
348e4e54f3
Removed question description
2017-10-03 19:11:54 +02:00
Angel Perez
0611e0f4ea
Validate presence of 'poll_id' attribute on Poll::Question model
...
Fixes #1831
On branch aperez-validate-poll-question-is-selected
Changes to be committed:
modified: app/models/poll/question.rb
modified: spec/models/poll/question_spec.rb
modified: spec/features/admin/poll/polls_spec.rb
2017-09-14 11:52:19 -04:00
María Checa
4af44a45a1
Documents upload for questions working
2017-09-06 12:00:46 +02:00
Bertocq
beb4bc119c
Fix Rails/Delegate rubocop issue
2017-07-10 23:02:27 +02:00
Bertocq
2888c20489
Fix all Style/RedundantSelf rubocop issues
2017-07-05 11:55:52 +02:00
Bertocq
c9bc028524
Remove all unnecesary extra spacing and Layout/ExtraSpacing list from rubocop file
2017-06-28 14:12:51 +02:00
Juanjo Bazán
db9ee74828
removes max restriction on title length
2017-02-12 13:08:26 +01:00
kikito
043e2e3586
Removes summary from poll::Question model
2017-01-30 18:41:24 +01:00
kikito
499f9b51e2
makes it possible to create orphan poll questions
2017-01-25 11:19:18 +01:00
kikito
2be88cb316
Adds missing validation to poll::question. Fixes specs
2017-01-25 10:46:57 +01:00
kikito
d024505960
moves geozones from poll question to poll in models
2017-01-20 18:58:03 +01:00
Juanjo Bazán
f0156c5b5a
adds admin search/add/remove question to poll
2016-12-26 16:19:35 +01:00
rgarcia
20cb044015
adds search and filter for poll questions
2016-11-29 11:46:30 +01:00