Commit Graph

695 Commits

Author SHA1 Message Date
decabeza
c98e8a004f Add new 'hide_money' column to the budgets' table
We will use this field to show/hide all price references in the Budgets
with the final voting style: Approval.
2022-02-25 16:22:52 +01:00
taitus
630ea22ece Add new 'subscriptions_token' column to the users' table
Giving any user a direct link to edit another user's account settings doesn't seem like a
great idea. Instead we'll generate a random secure hash string to help keep things
more secure. We'll store these hashes on each user so that we have a way to find
them during this public query. To do this we need to add a column to the user table.
2022-01-17 13:55:31 +01:00
Senén Rodero Rodríguez
7ad838c57d Translate budget and budget phase main link url 2021-11-05 16:40:36 +01:00
Javi Martín
480bb8cd55 Remove link column in dashboard actions
This column wasn't used in any released Consul version since it was only
used during development. For the same reason, the task to migrate the
information in the `link` column to the `links` table isn't needed
either.
2021-10-06 14:13:44 +02:00
Javi Martín
66ef345a2d Create ActiveStorage tables
This migration was generated using the `active_storage:install` task.
2021-09-24 13:39:15 +02:00
Javi Martín
5abd0466e2 Add Rails/AddColumnIndex rubocop rule
The `column` method in ActiveRecord::ConnectionAdapters::TableDefinition
supports adding the `index:` option. The documentation says:

> Instantiates a new column for the table. See connection.add_column for
> available options.
>
> Additional options are:
>
> :index - Create an index for the column. Can be either true or an
> options hash.

So basically the `connection.add_column` method silently ignores the
`index:` option, and whenever we intended to create an index this way,
we didn't.

We're creating a new migration where we properly add the indexes that
weren't added when we intended to.

Thanks to the rubocop-rails team, who added this cop in version 2.11.0
and helped us notice this bug.
2021-09-03 11:49:52 +02:00
Machine Learning
4d27bbebad Add experimental machine learning 2021-08-16 16:31:04 +02:00
Julian Herrero
db9ac79e05 Add main link to each phase of the budget
Co-authored-by: decabeza <alberto@decabeza.es>
2021-06-09 21:51:39 +02:00
decabeza
d78f2e03ad Render link to budget header
- Allow to define a link (text and url) on budget form for render on the budget
header.
- Improve styles

Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2021-06-09 19:16:55 +02:00
Julian Herrero
909071c48b Allow editing the name of budget phases
Co-authored-by: decabeza <alberto@decabeza.es>
2021-03-11 19:37:58 +01:00
Julian Herrero
28caabecdf Refactor participatory budgets in draft mode
Previously the draft mode was a phase of the PB, but that had some
limitations.

Now the phase drafting disappears and therefore the PB can have the
status published or not published (in draft mode).

That will give more flexibility in order to navigate through the
different phases and see how it looks for administrators before
publishing the PB and everybody can see.

By default, the PB is always created in draft mode, so it gives you
the flexibility to adjust and modify anything before publishing it.
2021-02-23 17:05:24 +01:00
taitus
0a3de68206 Add relation between Goal and LocalTarget
This is similar to what we do with investments, which belong to a heading
but also belong to a budget. In our case, the reason is we've been asked
to add local targets which belong to a goal but are not related to any
existing target.
Even though we're not implementing that case right now, we're adding the
relation so we don't have to add data migrations in the future.
2021-01-26 19:10:12 +01:00
Senén Rodero Rodríguez
0368aa459f Add SDG::Review model
and its relation with relatables

Note about sdg_review factory: Cannot use the constantize method on
the relatable_type as long as the relatable classes will be loaded and
this will throw an exception because the database is not available at
factiry definition time.
2021-01-18 13:17:37 +01:00
Javi Martín
13f95e9419 Add SDG phase model
The purpose of this model will be to have different sections in the SDG
index.
2021-01-14 17:38:01 +01:00
Javi Martín
ee29ca43a5 Make widget cards polymorphic
So now we'll be able to add them to other sections.

We're also adding a `dependent: :destroy` relation to models having
cards since it doesn't make sense to have cards around when their page
has been destroyed.
2021-01-14 17:37:58 +01:00
Javi Martín
948a8b2904 Add search method to legislation processes
This way we'll be able to search processes in the SDG Management
section.
2020-12-21 18:04:48 +01:00
Javi Martín
852014e478 Add search method to polls
So far the method does not take questions nor answers into account.

This way we'll be able to search polls in the SDG Management section.
2020-12-21 18:04:48 +01:00
taitus
cd7185f317 Create sdg manager 2020-12-16 11:43:15 +01:00
Senén Rodero Rodríguez
2ad66409e2 Add SDG LocalTarget model 2020-12-08 11:30:46 +01:00
Javi Martín
1740e0ba66 Add SDG::Relation model 2020-12-04 18:27:49 +01:00
Senén Rodero Rodríguez
c39c7213c7 Add SDG target model
and its relation with the SDG goal model.

Add comparable module be able to sort collections of targets
by code attribute.

Co-Authored-By: Javi Martín <35156+javierm@users.noreply.github.com>
2020-12-04 15:15:32 +01:00
Javi Martín
428644cd3e Add SDG goal model
Since data for this model (title and description) is not generated in
CONSUL but by the United Nations, we aren't storing it in the database
but in our YAML translation files.

The reasoning is as follows. Suppose that, a few months after CONSUL
gets SDG support, a new language is added to CONSUL.

With YAML files, getting the texts in the new language would mean
updating CONSUL to include the new language.

But if we store these texts in the database, it means we have to update
the databases of all existing CONSUL installations, either each
installation by themselves (duplicating efforts) or running a rake task
(which we would have to write each time).

So we believe using translations works better in this case.

We're still storing records in the database with the code, so they can
be easily referenced via `has_many` or `has_many :through` associations.
2020-12-02 12:13:02 +01:00
Javi Martín
2d9f679105 Use Rails 5.2 schema format 2020-10-15 14:46:20 +02:00
taitus
f90c09bea7 Remove deprecated attributes from Proposals
Some fields from Proposals are deprecated and we no longer need them.
2020-09-08 12:13:21 +02:00
taitus
086b0366a2 Remove deprecated attributes from Debates
Some fields from Debates are deprecated and we no longer need them.
2020-09-08 12:13:13 +02:00
taitus
5eed36ca8e Remove deprecated attribute from Comments
A field from Comment is deprecated and we no longer need it.
2020-09-08 12:13:01 +02:00
taitus
e39b72d945 Remove deprecated attributes from Investments
Some fields from Investment are deprecated and we no longer need them.
2020-09-08 12:12:43 +02:00
taitus
819e2c82ce Add migration to change columns type of attachments
As suggested in the paperclip update discussed in the previous commit,
we force the type of these fields to be bigint.
2020-09-08 11:02:13 +02:00
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00
Javi Martín
d7d421b88f Rename columns with a slash in their names
These columns were causing Rails 5.2 to throw a warning when ordering by
them, as if they weren't valid column names:

DEPRECATION WARNING: Dangerous query method (method whose arguments are
used as raw SQL) called with non-attribute argument(s):
:"budget/investments_count". Non-attribute arguments will be disallowed
in Rails 6.0. This method should not be called with user-provided
values, such as request parameters or model attributes. Known-safe
values can be passed by wrapping them in Arel.sql().

This change also makes their names consistent with the rest of our
tables and columns.
2020-07-08 18:34:58 +02:00
Javi Martín
1118c732f1 Bump acts-as-taggable-on to 6.0.0
Rails 5.1 introduced certain changes in the way a record is touched when
the counter cache option is enabled in a belongs to association.

We need to upgrade acts-as-taggable-on so it keeps changing the
`updated_at` attribute when a new tag is added to a record.

Note we now need to reload the records in some cases to get the
`context_tag_list` method to return what we expect. Methods like
`context_tags` however work properly with no need to reload the record.
2020-04-23 18:49:43 +02:00
Javi Martín
1de1cb0353 Use Rails 5.1 schema file format
Rails 5.1 doesn't align the columns in the schema file anymore, so
there aren't unrelated changes when we add or remove columns to a table:

https://github.com/rails/rails/pull/25675

We're sorry for developers who are really concerned about code
alignment.
2020-04-23 18:49:43 +02:00
Cassiano Sampaio
1e4f539104 Add title to differentiate signature sheets 2020-04-09 07:11:52 +10:00
Javi Martín
56c797348c Remove old milestone tables
These tables are obsolete since commit c0f6fa18, and their content was
migrated in version 0.18 with the task added in commit 4c3dadf1.
2019-11-08 18:57:54 +01:00
Javi Martín
7a78776569 Bring back removal of translatable columns
Globalize does not support having translatable columns with the same
name in the original table and the translations table. We were planning
to migrate to Mobility, but we aren't doing so before releasing version
1.1.

We've also found a gotcha regarding having both columns: if we use the
`update_column` method, which we use in rake tasks to speed up the
process and in tests where we want to skip validations and callbacks, we
update the column in the original table and no exception is raised. If
we remove the column in the original table, we get an exception, which
is what we want since our intention is to update the column in the
translations table.

With this change we're following the advice given by the Mobility lead
developer: "If you don't need the columns, I think it would make sense
to just remove them to avoid any edge case issues."

This commit reverts commit 251326ea.
2019-11-07 22:01:43 +01:00
Javi Martín
5ed308c6f7 Remove obsolete report columns from polls
These columns are obsolete since commit 354b183e, and its content was
migrated in version 1.0 with the task defined in commit 9ae0cbb2.
2019-11-07 20:36:43 +01:00
Javi Martín
82b0a6a92d Remove new CSV report generation
The new CSV report was more configurable and could work on proposals,
processes and comments. However, it had several issues.

In the public area, by default it generated a blank file.

In the admin section, the report was hard to configure and it generated
a file with less quality than the old system.

So until we improve this system, we're bringing back the old investment
CSV exporter.

This commit reverts most of commit 9d1ca3bf.
2019-11-06 00:04:02 +01:00
Javi Martín
ed223e0bd1 Use audited to track investment changes
Our manual implementation had a few issues. In particular, it didn't
track changes related to associations, which became more of an issue
when we made investments translatable.

Using audited gives us more functionality while at the same time
simplifies our code. However, it adds one more external dependency to
our project.

The reason for choosing audited over paper trail is audited seems to
make it easier to handle associations.
2019-11-05 13:02:37 +01:00
Javi Martín
ac6d50e06b Remove tracker role
The current tracking section had a few issues:

* When browsing as an admin, this section becomes useless since no
investments are shown
* Browsing investments in the admin section, you're suddenly redirected
to the tracking section, making navigation confusing
* One test related to the officing dashboard failed due to these changes
and had been commented
* Several views and controller methods were copied from other sections,
leading to duplication and making the code harder to maintain
* Tracking routes were defined for proposals and legislation processes,
but in the tracking section only investments were shown
* Probably many more things, since these issues were detected after only
an hour reviewing and testing the code

So we're removing this untested section before releasing version 1.1. We
might add it back afterwards.
2019-11-01 20:08:46 +01:00
Javi Martín
62c4d41af4 Remove unused budget attributes
Tags and help links can be edited, but aren't used anywhere. Since we
don't know what the intended behavior was, I'm removing them for now.

My best guess is tags were supposed to be used so investments for a
budget can only be assigned tags present in the budget. Achieving that
behavior wouldn't be a trivial task.
2019-11-01 17:12:42 +01:00
Javi Martín
20001824e5 Use acts_as_taggable for budget tags
We were adding columns to the budgets table instead of using the same
logic we use everywhere else.
2019-11-01 17:12:42 +01:00
Javi Martín
184d5fc504 Remove unused model
It was added in commit 74083df1; we're not sure why.
2019-11-01 16:49:14 +01: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
f3df3f4fbc Remove people proposal model
This model isn't used anywhere, since it was created as part of a
feature which couldn't be completed.

This commit reverts commit 46e5d6a9.
2019-10-30 02:26:42 +01:00
Javi Martín
904917e568 Fix typo in pair answers column name 2019-10-25 18:05:59 +02:00
Javi Martín
68ca29fa8b Convert markdown to HTML on demand
We were converting markdown to HTML every time we saved a record, which
has the same problems as sanitizing HTML before saving it to the
database, particularly because the body of a legislation draft is stored
in a translations table.

Performance-wise this isn't a problem: converting a text with more than
200_000 characters takes about a milisecond on my machine.

Note we need to modify a migration generated by globalize, since the
method `create_translation_table!` would fail now that we don't define
`translates :body_html` in the model.
2019-10-21 21:32:43 +02:00
Shaun Schwartz
04b1bc9fca Add timestamps to Budget::Heading & Budget::Group 2019-10-20 17:36:36 +02:00
voodoorai2000
488e19f8a0 Add original_heading_id to investments
Investments can be reclassified to a different heading during the participatory budget process.

Whilst we are recording this change of heading in the `previous_heading_id` attribute, we are only keeping the _last_ heading. If there are multiple reclassifications we lose this chain of reclassifications.

In this commit we are adding an `original_heading_id` attribute, that will only be set once, when creating the investment, and will not get lost with multiple reclassificaitons of an investment.
2019-09-12 16:49:01 +02:00
Javi Martín
765d405df1 Use Rails 5 conventions in migrations and models
We forgot to add these changes to pull requests which were in
development before we upgraded to Rails 5.

We're also moving the rubocop rules to the basic files, so we're
notified when we inherit from `ActiveRecord::Base`.
2019-08-07 13:53:27 +02:00
taitus
5d68e1a43d Add new fields to signature
- Add :date_of_birth and :postal_code to Signature to allow send these
  fields to CustomCensusAPI

- Add new model presence validates: Only validate :date_of_birth and
  :postal_code presence when the application has configured Remote Census
  and their alias fields has values.
2019-07-29 13:10:09 +02:00