Commit Graph

2273 Commits

Author SHA1 Message Date
taitus
7fa594e3e3 Rename sdg_related_list to related_sdg_list
To maintain consistency with the current names in the database with fields:
:related_sdg_type and :related_sdg_id
2021-01-26 19:18:11 +01:00
Javi Martín
8542e3e3cf Merge pull request #4323 from consul/sdg_stats
Add SDG stats page to admin section
2021-01-25 15:18:03 +01:00
Senén Rodero Rodríguez
9b2d349e21 Create SDG stats page 2021-01-23 12:23:29 +01:00
Javi Martín
e96f45ba39 Merge pull request #4325 from consul/add_related_list_selector
Add related list selector component to forms
2021-01-22 16:34:10 +01:00
taitus
7d2b940ad9 Add SDG::RelatedListSelectorComponent to Legislation Process
Allow to relate SDG and Targets to Legislation Process
2021-01-22 16:14:50 +01:00
taitus
920631c5b3 Add SDG::RelatedListSelectorComponent to Polls
Allow to relate SDG and Targets to Polls
2021-01-22 16:14:50 +01:00
taitus
6d3782b4a0 Add SDG::RelatedListSelectorComponent to Budget Investments
Allow to relate SDG and Targets to Budget Investments
2021-01-22 16:14:47 +01:00
taitus
95c1f36bdd Add SDG::RelatedListSelectorComponent to Proposals
Allow to relate SDG and Targets to Proposals
2021-01-22 16:05:16 +01:00
taitus
e6bfeef58d Add SDG::RelatedListSelectorComponent to Debates 2021-01-22 16:04:40 +01:00
Javi Martín
a979a2225d Merge pull request #4315 from consul/sdg_relation_tags
Add SDG goal/target selector
2021-01-20 19:33:32 +01:00
taitus
7b1821fc9b Prepare relatable concern and relations controller
Allow send Goals and Targets from edit component input field
2021-01-20 19:17:59 +01:00
Javi Martín
a7bbdb1bd0 Simplify rendering a banner
Now the banner component accepts either a banner or a section and loads
the banner if it's a section, so we don't have to add the `@banners`
variable in several controllers.
2021-01-20 17:22:05 +01:00
Senén Rodero Rodríguez
739d23fe73 Mark relatable as reviewed when updating its relations
Show a notice only once when the user updates the relatable.
2021-01-19 14:56:30 +01:00
Senén Rodero Rodríguez
c6407d82e3 Add filters to SDG relations controller
We have three filters: "pending", "all" and "reviewed". Where "pending"
is the default one.

Now we are rendering the `shared/_filter_subnav` partial we need to stub
helper methods defined at the controller and the helper methods that
rely on the request parameters to test the component.
2021-01-19 14:56:30 +01:00
Senén Rodero Rodríguez
94a4b67675 Use local variables at shared/filter_subnav partial
So we can use it from components too.
2021-01-19 13:51:06 +01:00
Javi Martín
c3e60ff514 Add cards to SDG homepage 2021-01-14 17:47:21 +01:00
Javi Martín
7aee4f6241 Add SDG phases cards management
These cards will be displayed in the SDG homepage.

Note there seems to be a strange behavior in cancancan. If we define
these rules:

can :manage, Widget::Card, page_type: "SDG::Phase"
can :manage, Widget::Card

The expected behavior is the first rule will always be ignored because
the second one overwrites it. However, when creating a new card with
`load_and_authorize_resource` will automatically add `page_type:
"SDG::Phase"`.

Similarly, if we do something like:

can :manage, Widget::Card, id: 3
can :manage, Widget::Card

Then the new card will have `3` as an ID.

Maybe upgrading cancancan solves the issue; we haven't tried it. For now
we're defining a different rule when creating widget cards.
2021-01-14 17:40:02 +01:00
Javi Martín
2968275a1c Add empty SDG homepage configuration page
Here we'll eventually display links to edit the homepage and the cards
in it.
2021-01-14 17:35:38 +01:00
Senén Rodero Rodríguez
3aaf5ce151 Add back link to cards form
As we normally do in other places.
2021-01-12 15:34:55 +01:00
Javi Martín
4c0bb894eb Use polymorphic routes to manage cards
We use a different logic to load the card depending on the controller
we're using, and then share the rest of the code. This way we simplify
the code a bit, since we don't have to check for the page_id parameter.
2021-01-12 14:50:37 +01:00
Javi Martín
52d71b8432 Remove unneeded namespace methods
These methods are not necessary since we changed the `namespace` helper
method in commit 13b3d9ceb.
2021-01-12 14:50:36 +01:00
Javi Martín
c06f14fa65 Remove unused method in cards controller
This method isn't necessary since commit 71601bd3f.
2021-01-12 14:50:36 +01:00
Javi Martín
0762c66855 Don't skip authorization check managing cards
I'm not sure why we were skipping this check.
2021-01-12 14:50:36 +01:00
Javi Martín
ded5a8d468 Use cancancan to load pages and cards
Like we do in most places in the application.
2021-01-12 14:50:33 +01:00
Javi Martín
73e605232e Merge pull request #4292 from consul/sdg_view
Add SDG view with related content
2020-12-28 21:01:14 +01:00
Senén Rodero Rodríguez
db06bb2c9e Load records using cancancan load_and_authorize_resource method 2020-12-23 16:53:39 +01:00
Javi Martín
910acff624 Add empty SDG goal show page
Note we're using the code instead of the ID to get the goal in the URL.
IMHO this is what most people would expect; visiting a URL with a "7"
takes you to SDG number 7, and not to the one with "7" as a database ID.

In order to avoid tests (either automated tests or manual tests) passing
by coincidence due to the goal ID and the goal code being the same, I'm
shuffling the codes before entering them in the databse.

I've tried using `resolve` in the routes so the code is automatically
taken into account, but it doesn't work since `resolve` cannot be used
inside a namespace, and here we're within the `sdg` namespace.
2020-12-23 13:18:17 +01:00
Javi Martín
de4be15a8d Add empty SDG index 2020-12-23 13:18:10 +01:00
Javi Martín
74962ef05f Add filter by target 2020-12-21 18:27:27 +01:00
Javi Martín
c9362ffeb4 Add filter by goal 2020-12-21 18:27:27 +01:00
Javi Martín
cb183b6e15 Add search to SDG managed content 2020-12-21 18:27:27 +01:00
Javi Martín
ee06dcc05a Disable SDG sections when settings are disabled 2020-12-21 18:04:48 +01:00
Javi Martín
f76279a4dd Add form to assign targets to a record 2020-12-21 18:04:48 +01:00
Javi Martín
11c3b3db13 Add link to an (empty) edit action 2020-12-21 18:04:48 +01:00
Javi Martín
ed51c5dcd3 Add basic SDG Management content section
Note using `params[:relatable_type].classify` is recognized as a
security risk by some tools. However, it's a false positive, since we've
added constraints to the URL so that paramenter can only have the values
we trust.
2020-12-21 18:04:48 +01:00
taitus
9521d87d03 Remove unneeded for_render
for_render does is including organizations and there is no need to
 render organizations on these controllers
2020-12-16 13:16:48 +01:00
taitus
9fe24aec9d Add sdg manager section to admin
Allow a user to become an sdg manager
2020-12-16 13:16:45 +01:00
taitus
fb5965fe63 Add cancancan to SDG content
Only allow access to the SDG content section to administrators and sdg managers
2020-12-16 11:43:17 +01:00
taitus
65d6282b51 Allow sdg_manager access to sdg management section 2020-12-16 11:43:17 +01:00
Javi Martín
599332f26e Merge pull request #4271 from consul/sdg_local_targets
Add SDG local targets
2020-12-16 11:35:12 +01:00
Senén Rodero Rodríguez
8f7809ddb4 Allow to destroy SDG local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
a211937744 Add SDG page to update local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
5611f58909 Add SDG page to create local targets 2020-12-11 16:10:37 +01:00
Senén Rodero Rodríguez
88bcf527d8 Add local_targets index to the administration 2020-12-11 16:09:42 +01:00
Javi Martín
e33794e45e Reuse admin search component in other sections
There are some sections where we are not reusing it:

* The budget investments search is completely different, so this
  component isn't appropriate there
* Booth assignment and officers are slightly different, and I'm not
  entirely sure it's safe to refactor these cases
2020-12-04 19:57:05 +01:00
Javi Martín
155da08cf0 Use a generic name for the search parameter
This way we can use it for any model.
2020-12-04 19:57:05 +01:00
Senén Rodero Rodríguez
7fb3f1920e Add targets index to the administration
Co-authored-by: Javi Martín <javim@elretirao.net>
2020-12-04 15:15:32 +01:00
taitus
cb63185837 Render SDG content sidebar when sdg feature setting is enabled 2020-12-03 18:26:00 +01:00
taitus
0abc82d520 Add new sdg settings on sdg-tab 2020-12-03 18:00:10 +01:00
Javi Martín
a42cb050a7 Add SDG content section 2020-12-02 12:38:03 +01:00