decidim-lausanne-budgets 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +141 -0
- data/Rakefile +93 -0
- data/app/cells/decidim/lausanne/budgets/base_cell.rb +24 -0
- data/app/cells/decidim/lausanne/budgets/budget_cell.rb +23 -0
- data/app/cells/decidim/lausanne/budgets/budget_information_modal/show.erb +21 -0
- data/app/cells/decidim/lausanne/budgets/budget_information_modal_cell.rb +24 -0
- data/app/cells/decidim/lausanne/budgets/budget_list_item/show.erb +21 -0
- data/app/cells/decidim/lausanne/budgets/budget_list_item_cell.rb +43 -0
- data/app/cells/decidim/lausanne/budgets/budget_m/data.erb +12 -0
- data/app/cells/decidim/lausanne/budgets/budget_m/footer.erb +5 -0
- data/app/cells/decidim/lausanne/budgets/budget_m_cell.rb +18 -0
- data/app/cells/decidim/lausanne/budgets/budgets_header/show.erb +7 -0
- data/app/cells/decidim/lausanne/budgets/budgets_header_cell.rb +16 -0
- data/app/cells/decidim/lausanne/budgets/budgets_list/card_list.erb +7 -0
- data/app/cells/decidim/lausanne/budgets/budgets_list/highlighted.erb +11 -0
- data/app/cells/decidim/lausanne/budgets/budgets_list/show.erb +20 -0
- data/app/cells/decidim/lausanne/budgets/budgets_list/voted.erb +43 -0
- data/app/cells/decidim/lausanne/budgets/budgets_list_cell.rb +40 -0
- data/app/cells/decidim/lausanne/budgets/limit_announcement_cell.rb +47 -0
- data/app/cells/decidim/lausanne/budgets/project_cell.rb +23 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item/project_data.erb +19 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item/project_data_vote_button.erb +22 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item/project_image.erb +5 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item/project_text.erb +23 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item/show.erb +5 -0
- data/app/cells/decidim/lausanne/budgets/project_list_item_cell.rb +75 -0
- data/app/cells/decidim/lausanne/budgets/project_m/data.erb +12 -0
- data/app/cells/decidim/lausanne/budgets/project_m/footer.erb +5 -0
- data/app/cells/decidim/lausanne/budgets/project_m_cell.rb +24 -0
- data/app/cells/decidim/lausanne/budgets/project_selected_status_cell.rb +30 -0
- data/app/cells/decidim/lausanne/budgets/project_tags/show.erb +4 -0
- data/app/cells/decidim/lausanne/budgets/project_tags_cell.rb +20 -0
- data/app/cells/decidim/lausanne/budgets/project_voted_hint_cell.rb +35 -0
- data/app/cells/decidim/lausanne/budgets/project_votes_count_cell.rb +46 -0
- data/app/commands/decidim/lausanne/budgets/add_line_item.rb +54 -0
- data/app/commands/decidim/lausanne/budgets/admin/create_budget.rb +50 -0
- data/app/commands/decidim/lausanne/budgets/admin/create_project.rb +71 -0
- data/app/commands/decidim/lausanne/budgets/admin/destroy_budget.rb +44 -0
- data/app/commands/decidim/lausanne/budgets/admin/destroy_project.rb +44 -0
- data/app/commands/decidim/lausanne/budgets/admin/import_proposals_to_budgets.rb +87 -0
- data/app/commands/decidim/lausanne/budgets/admin/update_budget.rb +50 -0
- data/app/commands/decidim/lausanne/budgets/admin/update_project.rb +79 -0
- data/app/commands/decidim/lausanne/budgets/cancel_order.rb +46 -0
- data/app/commands/decidim/lausanne/budgets/checkout.rb +43 -0
- data/app/commands/decidim/lausanne/budgets/command.rb +16 -0
- data/app/commands/decidim/lausanne/budgets/create_user_record.rb +39 -0
- data/app/commands/decidim/lausanne/budgets/remove_line_item.rb +40 -0
- data/app/commands/decidim/lausanne/budgets/update_user_record.rb +40 -0
- data/app/controllers/concerns/decidim/lausanne/budgets/needs_current_order.rb +52 -0
- data/app/controllers/concerns/decidim/lausanne/budgets/orderable.rb +54 -0
- data/app/controllers/decidim/lausanne/budgets/admin/application_controller.rb +34 -0
- data/app/controllers/decidim/lausanne/budgets/admin/attachment_collections_controller.rb +27 -0
- data/app/controllers/decidim/lausanne/budgets/admin/attachments_controller.rb +28 -0
- data/app/controllers/decidim/lausanne/budgets/admin/lausanne_budgets_controller.rb +105 -0
- data/app/controllers/decidim/lausanne/budgets/admin/projects_controller.rb +98 -0
- data/app/controllers/decidim/lausanne/budgets/admin/proposals_imports_controller.rb +43 -0
- data/app/controllers/decidim/lausanne/budgets/application_controller.rb +77 -0
- data/app/controllers/decidim/lausanne/budgets/lausanne_budgets_controller.rb +29 -0
- data/app/controllers/decidim/lausanne/budgets/line_items_controller.rb +63 -0
- data/app/controllers/decidim/lausanne/budgets/orders_controller.rb +59 -0
- data/app/controllers/decidim/lausanne/budgets/projects_controller.rb +103 -0
- data/app/controllers/decidim/lausanne/budgets/user_records_controller.rb +121 -0
- data/app/forms/decidim/lausanne/budgets/admin/component_form.rb +93 -0
- data/app/forms/decidim/lausanne/budgets/admin/lausanne_budget_form.rb +41 -0
- data/app/forms/decidim/lausanne/budgets/admin/project_form.rb +96 -0
- data/app/forms/decidim/lausanne/budgets/admin/project_import_proposals_form.rb +52 -0
- data/app/forms/decidim/lausanne/budgets/user_record_form.rb +61 -0
- data/app/helpers/decidim/lausanne/budgets/admin/application_helper.rb +15 -0
- data/app/helpers/decidim/lausanne/budgets/application_helper.rb +26 -0
- data/app/helpers/decidim/lausanne/budgets/projects_helper.rb +103 -0
- data/app/jobs/decidim/lausanne/budgets/send_order_summary_job.rb +17 -0
- data/app/mailers/decidim/lausanne/budgets/order_summary_mailer.rb +38 -0
- data/app/models/decidim/lausanne/budgets/application_record.rb +12 -0
- data/app/models/decidim/lausanne/budgets/lausanne_budget.rb +37 -0
- data/app/models/decidim/lausanne/budgets/line_item.rb +23 -0
- data/app/models/decidim/lausanne/budgets/order.rb +204 -0
- data/app/models/decidim/lausanne/budgets/project.rb +129 -0
- data/app/models/decidim/lausanne/budgets/user_record.rb +28 -0
- data/app/packs/entrypoints/decidim_lausanne_budgets.js +2 -0
- data/app/packs/images/decidim/lausanne/budgets/icon.svg +1 -0
- data/app/packs/images/decidim/lausanne/budgets/lausanneparticipe.gif +0 -0
- data/app/packs/src/decidim/lausanne/budgets/index.js +1 -0
- data/app/packs/src/decidim/lausanne/budgets/progressFixed.js.es6 +23 -0
- data/app/packs/src/decidim/lausanne/budgets/projects.js.es6 +66 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/_budgets.scss +13 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_budget-list.scss +195 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_budget-meter.scss +85 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_print.scss +73 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_progress.scss +25 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_proposal_link.scss +38 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_share_buttons.scss +15 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_user_record_form.scss +8 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_votation-progress.scss +100 -0
- data/app/packs/stylesheets/decidim/lausanne/budgets/budget/_voting-rules.scss +20 -0
- data/app/permissions/decidim/lausanne/budgets/admin/permissions.rb +49 -0
- data/app/permissions/decidim/lausanne/budgets/permissions.rb +63 -0
- data/app/presenters/decidim/lausanne/budgets/admin_log/budget_presenter.rb +44 -0
- data/app/presenters/decidim/lausanne/budgets/admin_log/project_presenter.rb +44 -0
- data/app/queries/decidim/lausanne/budgets/filtered_projects.rb +47 -0
- data/app/queries/decidim/lausanne/budgets/metrics/budget_followers_metric_measure.rb +34 -0
- data/app/queries/decidim/lausanne/budgets/metrics/budget_participants_metric_measure.rb +29 -0
- data/app/queries/decidim/lausanne/budgets/query.rb +16 -0
- data/app/serializers/decidim/lausanne/budgets/data_portability_budgets_order_serializer.rb +46 -0
- data/app/services/decidim/lausanne/budgets/project_search.rb +65 -0
- data/app/services/decidim/lausanne/budgets/project_search_rs.rb +13 -0
- data/app/views/decidim/lausanne/budgets/admin/lausanne_budgets/_form.html.erb +23 -0
- data/app/views/decidim/lausanne/budgets/admin/lausanne_budgets/edit.html.erb +7 -0
- data/app/views/decidim/lausanne/budgets/admin/lausanne_budgets/index.html.erb +75 -0
- data/app/views/decidim/lausanne/budgets/admin/lausanne_budgets/new.html.erb +7 -0
- data/app/views/decidim/lausanne/budgets/admin/projects/_form.html.erb +47 -0
- data/app/views/decidim/lausanne/budgets/admin/projects/edit.html.erb +7 -0
- data/app/views/decidim/lausanne/budgets/admin/projects/index.html.erb +82 -0
- data/app/views/decidim/lausanne/budgets/admin/projects/new.html.erb +7 -0
- data/app/views/decidim/lausanne/budgets/admin/projects/proposals_picker.html.erb +1 -0
- data/app/views/decidim/lausanne/budgets/admin/proposals_imports/new.html.erb +32 -0
- data/app/views/decidim/lausanne/budgets/lausanne_budgets/index.html.erb +5 -0
- data/app/views/decidim/lausanne/budgets/line_items/update_budget.js.erb +41 -0
- data/app/views/decidim/lausanne/budgets/order_summary_mailer/order_summary.html.erb +22 -0
- data/app/views/decidim/lausanne/budgets/orders/show.html.erb +71 -0
- data/app/views/decidim/lausanne/budgets/projects/_budget_confirm.html.erb +37 -0
- data/app/views/decidim/lausanne/budgets/projects/_budget_excess.html.erb +14 -0
- data/app/views/decidim/lausanne/budgets/projects/_budget_summary.html.erb +95 -0
- data/app/views/decidim/lausanne/budgets/projects/_count.html.erb +1 -0
- data/app/views/decidim/lausanne/budgets/projects/_filters.html.erb +34 -0
- data/app/views/decidim/lausanne/budgets/projects/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/lausanne/budgets/projects/_linked_projects.html.erb +12 -0
- data/app/views/decidim/lausanne/budgets/projects/_order_progress.html.erb +32 -0
- data/app/views/decidim/lausanne/budgets/projects/_order_selected_projects.html.erb +27 -0
- data/app/views/decidim/lausanne/budgets/projects/_order_total_budget.html.erb +7 -0
- data/app/views/decidim/lausanne/budgets/projects/_project.html.erb +1 -0
- data/app/views/decidim/lausanne/budgets/projects/_project_budget_button.html.erb +46 -0
- data/app/views/decidim/lausanne/budgets/projects/_projects.html.erb +13 -0
- data/app/views/decidim/lausanne/budgets/projects/_user_record_form.html.erb +40 -0
- data/app/views/decidim/lausanne/budgets/projects/_votation_banner.html.erb +71 -0
- data/app/views/decidim/lausanne/budgets/projects/index.html.erb +36 -0
- data/app/views/decidim/lausanne/budgets/projects/index.js.erb +10 -0
- data/app/views/decidim/lausanne/budgets/projects/show.html.erb +81 -0
- data/app/views/decidim/lausanne/budgets/user_records/edit.html.erb +6 -0
- data/app/views/decidim/proposals/proposals/show.html.erb +172 -0
- data/app/views/layouts/lausanne_budgets/print.erb +12 -0
- data/config/assets.rb +11 -0
- data/config/initializers/social_share.rb +3 -0
- data/config/locales/fr.yml +381 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20170127114122_create_lausanne_projects.rb +15 -0
- data/db/migrate/20170127114123_create_lausanne_user_records.rb +14 -0
- data/db/migrate/20170130095615_create_lausanne_orders.rb +16 -0
- data/db/migrate/20170130101825_create_lausanne_line_items.rb +12 -0
- data/db/migrate/20170215132708_add_lausanne_reference_to_projects.rb +13 -0
- data/db/migrate/20200617105120_create_decidim_lausanne_budgets.rb +15 -0
- data/db/migrate/20200629134013_add_lausanne_budget_reference_to_project.rb +7 -0
- data/db/migrate/20200706142609_add_lausanne_budget_reference_to_order.rb +7 -0
- data/db/migrate/20200714103519_move_lausanne_budgets_to_own_model.rb +109 -0
- data/db/migrate/20200717140012_add_lausanne_scope_to_budgets.rb +7 -0
- data/db/migrate/20200728075039_add_lausanne_selected_at_to_project.rb +7 -0
- data/db/migrate/20200804175222_lausanne_votes_enabled_to_votes_choices.rb +35 -0
- data/db/migrate/20200827154129_add_lausanne_commentable_counter_cache_to_projects.rb +9 -0
- data/db/migrate/20210310120613_add_lausanne_followable_counter_cache_to_budgets.rb +16 -0
- data/db/migrate/20210508180613_add_checkboxes_to_user_record.rb +9 -0
- data/db/migrate/20221001151237_add_excerpt_to_decidim_lausanne_budgets_project.rb +7 -0
- data/lib/decidim/lausanne/budgets/admin.rb +12 -0
- data/lib/decidim/lausanne/budgets/admin_engine.rb +40 -0
- data/lib/decidim/lausanne/budgets/component.rb +107 -0
- data/lib/decidim/lausanne/budgets/current_user_record_middleware.rb +17 -0
- data/lib/decidim/lausanne/budgets/engine.rb +57 -0
- data/lib/decidim/lausanne/budgets/project_serializer.rb +83 -0
- data/lib/decidim/lausanne/budgets/seeds/Exampledocument.pdf +0 -0
- data/lib/decidim/lausanne/budgets/seeds/city.jpeg +0 -0
- data/lib/decidim/lausanne/budgets/test/factories.rb +169 -0
- data/lib/decidim/lausanne/budgets/version.rb +15 -0
- data/lib/decidim/lausanne/budgets/workflows/all.rb +22 -0
- data/lib/decidim/lausanne/budgets/workflows/base.rb +140 -0
- data/lib/decidim/lausanne/budgets/workflows/one.rb +35 -0
- data/lib/decidim/lausanne/budgets/workflows.rb +19 -0
- data/lib/decidim/lausanne/budgets.rb +17 -0
- metadata +372 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 36a36d8d561f2ddd1be74dc244b39b5185a0b69ed24af6a2842eaca0992af3b7
|
4
|
+
data.tar.gz: 58c89964eb1be6b066ba4079ad74acb68a88556faf7b0d7365db35143057b17c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 192e193d94b61ba2774bd9df51731da31c8f8bc7024ae899c614d706e7ac67319cdb2ac95ba1ab7df93f46d7c277e616645e8052ad0c74afd6bc3eccf72f24ec
|
7
|
+
data.tar.gz: 3b2fb8897f35352b3dea61f696c42b05ba9ee588842d3ae02a3725b8db3e1a452b9b84ae496c744fa2c0fab8518173a0b4fc05459d4dd2fb534300225001733f
|
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
<h1 align="center">
|
2
|
+
<img
|
3
|
+
src="https://github.com/octree-gva/meta/blob/main/decidim/static/header.png?raw=true"
|
4
|
+
alt="Decidim - Octree Participatory democracy on a robust and open source solution" />
|
5
|
+
</h1>
|
6
|
+
<h4 align="center">
|
7
|
+
<a href="https://www.octree.ch">Octree</a> |
|
8
|
+
<a href="https://octree.ch/en/contact-us/">Contact Us</a> |
|
9
|
+
<a href="https://blog.octree.ch">Our Blog (FR)</a><br/><br/>
|
10
|
+
<a href="https://decidim.org">Decidim</a> |
|
11
|
+
<a href="https://docs.decidim.org/en/">Decidim Docs</a> |
|
12
|
+
<a href="https://meta.decidim.org">Participatory Governance (META DECIDIM)</a><br/><br/>
|
13
|
+
<a href="https://matrix.to/#/+decidim:matrix.org">Decidim Community (Matrix+Element.io)</a>
|
14
|
+
</h4>
|
15
|
+
<p align="center">
|
16
|
+
<a href="https://participer.lausanne.ch">
|
17
|
+
<img
|
18
|
+
src="https://github.com/octree-gva/meta/blob/main/decidim/static/participer_lausanne/chip.png?raw=true"
|
19
|
+
alt="Lausanne Participe — Une plateforme de participation pour imaginer et réaliser ensemble" />
|
20
|
+
</a>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
# Public Participatory Budgeting
|
24
|
+
|
25
|
+
This repository create a new participatory component, cloned from participatory budgets. It is done on decidim version 0.24.3 exclusively for now.
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
* As a non-connected user, I can insert my personal data, and use it to vote. This data will be checked oveer the official residentship database.
|
30
|
+
* As a non-connected user, I have a clear view on the vote process. First insert my personal data, then vote, then finalize my vote.
|
31
|
+
|
32
|
+
## Restrictions
|
33
|
+
From the original budget component, the following features are not implemented:
|
34
|
+
|
35
|
+
1. Authorizations: You can not define authorizations for this component (as it authorized only registered user)
|
36
|
+
2. Percentage rules: we improve the flow for `minimu_project` vote flow only. The others rules are un-tested and highly volatile
|
37
|
+
|
38
|
+
## Warning
|
39
|
+
This repository was done for the very specific use case of Lausanne City, you probably won't find any usage of this module.
|
40
|
+
|
41
|
+
## Why
|
42
|
+
The data-protection law in Switzerland is clear: save the minimal data for a limited amount of time.
|
43
|
+
|
44
|
+
As at Lausanne we see PB have somehow lower participation rates, we decide to experiment around public access. We go through a another strategy than Authorization in order to:
|
45
|
+
|
46
|
+
- Keep the submissions in the context of a PB
|
47
|
+
- Be able to remove user data without affecting behaviour
|
48
|
+
- Having a nicer UX flow as we now know there is a first step process in PB.
|
49
|
+
|
50
|
+
## Installation
|
51
|
+
|
52
|
+
Add this line to your application's Gemfile:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
gem "decidim-lausanne-budgets", git: "https://github.com/octree-gva/decidim-lausanne-budgets"
|
56
|
+
```
|
57
|
+
|
58
|
+
Then execute:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
bundle
|
62
|
+
bundle exec rails decidim_lausanne_budgets:install:migrations
|
63
|
+
bundle exec rails db:migrate
|
64
|
+
```
|
65
|
+
|
66
|
+
## Testing
|
67
|
+
|
68
|
+
The [Rakefile](Rakefile) is shipped with a
|
69
|
+
`test_app` using `docker-compose` to run a database.
|
70
|
+
If you haven't done it already, [install](https://docs.docker.com/get-docker/) docker](https://docs.docker.com/get-docker/).
|
71
|
+
|
72
|
+
```bash
|
73
|
+
bundle exec rake test_app
|
74
|
+
```
|
75
|
+
## Local development
|
76
|
+
For decidim version 0.27, use Gemfile.0.27. For version 0.26, use Gemfile.0.26
|
77
|
+
```
|
78
|
+
cp Gemfile.0.27 Gemfile
|
79
|
+
```
|
80
|
+
|
81
|
+
First, you need to run an empty database with a decidim dev container which runs nothing.
|
82
|
+
```
|
83
|
+
docker-compose down -v --remove-orphans
|
84
|
+
docker-compose up -d
|
85
|
+
```
|
86
|
+
|
87
|
+
Once created, you access the decidim container
|
88
|
+
```
|
89
|
+
# Get the id of the decidim dev container
|
90
|
+
docker ps --format {{.ID}} --filter=label=org.label-schema.name=decidim
|
91
|
+
# 841ae977c7da
|
92
|
+
docker exec -it 841ae977c7da bash
|
93
|
+
```
|
94
|
+
You are now in bash, run manually. This will check your environment and do migrations if needed
|
95
|
+
```
|
96
|
+
bundle exec rake decidim_lausanne_budgets:install:migrations
|
97
|
+
docker-entrypoint
|
98
|
+
```
|
99
|
+
|
100
|
+
You are now ready to use your container in the way you want for development:
|
101
|
+
|
102
|
+
* Run a rails seed: `bundle exec rails db:seed`
|
103
|
+
* Have live-reload on your assets: `bin/webpack-dev-server`
|
104
|
+
* Execute tasks, like `bundle exec rails g migration AddSomeColumn`
|
105
|
+
* Run the rails server: `bundle exec rails s -b 0.0.0.0`
|
106
|
+
* etc.
|
107
|
+
|
108
|
+
To stop everything, uses:
|
109
|
+
- `docker-compose down` to stop the containers
|
110
|
+
- `docker-compose down -v` to stop the containers and remove all previously saved data.
|
111
|
+
|
112
|
+
### Debugging
|
113
|
+
To debug something on the container:
|
114
|
+
1. Ensure `decidim-app` is running
|
115
|
+
```bash
|
116
|
+
docker ps --all
|
117
|
+
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
118
|
+
# 0517244cbdde decidim-module-lausanne_budgets-decidim-app "sleep infinity" 20 hours ago Up 20 hours 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp, 0.0.0.0:3035->3035/tcp, :::3035->3035/tcp decidim-lausanne-budgets-app
|
119
|
+
# 5399fc0c0866 postgres:14-alpine "docker-entrypoint.s…" 20 hours ago Up 20 hours (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp decidim-module-lausanne_budgets-pg-1
|
120
|
+
```
|
121
|
+
|
122
|
+
2. In another terminal, run `docker exec -it 0517244cbdde bash`
|
123
|
+
3. Run
|
124
|
+
- `tail -f $ROOT/log/development.log` to **access logs**
|
125
|
+
- `bundle exec rails restart` to **restart rails server AND keeps webpacker running**
|
126
|
+
- `cd $ROOT` to access the `development_app`
|
127
|
+
- `cd $ROOT/../decidim_module_lausanne_budgets` to access the module directory
|
128
|
+
|
129
|
+
## Contributing
|
130
|
+
|
131
|
+
This repository is not yet ready for contributions.
|
132
|
+
|
133
|
+
## License
|
134
|
+
|
135
|
+
This engine is distributed under the [GNU AFFERO GENERAL PUBLIC LICENSE](LICENSE.md).
|
136
|
+
|
137
|
+
<br /><br />
|
138
|
+
|
139
|
+
<p align="center">
|
140
|
+
<img src="https://raw.githubusercontent.com/octree-gva/meta/main/decidim/static/octree_and_decidim.png" height="90" alt="Decidim Installation by Octree" />
|
141
|
+
</p>
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/dev/common_rake"
|
4
|
+
|
5
|
+
def install_module(path)
|
6
|
+
Dir.chdir(path) do
|
7
|
+
# system("bundle exec rake decidim_vocacity_gem_tasks:install:migrations")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def seed_db(path)
|
12
|
+
Dir.chdir(path) do
|
13
|
+
system("bundle exec rake db:seed")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare_database(app_path)
|
18
|
+
# Remove previous existing db, and recreate one.
|
19
|
+
disable_docker_compose = ENV.fetch("DISABLED_DOCKER_COMPOSE", "false") == "true"
|
20
|
+
unless disable_docker_compose
|
21
|
+
system("docker-compose -f docker-compose.yml down -v")
|
22
|
+
system("docker-compose -f docker-compose.yml up -d --remove-orphans")
|
23
|
+
end
|
24
|
+
databaseYml = {
|
25
|
+
"development" => {
|
26
|
+
"adapter" => "postgresql",
|
27
|
+
"encoding" => "unicode",
|
28
|
+
"host" => ENV.fetch("DATABASE_HOST", "localhost"),
|
29
|
+
"port" => ENV.fetch("DATABASE_PORT", "5432").to_i,
|
30
|
+
"username" => ENV.fetch("DATABASE_USERNAME", "decidim"),
|
31
|
+
"password" => ENV.fetch("DATABASE_PASSWORD", "TEST-insecure-password"),
|
32
|
+
"database" => "decidim_dev"
|
33
|
+
},
|
34
|
+
"test" => {
|
35
|
+
"adapter" => "postgresql",
|
36
|
+
"encoding" => "unicode",
|
37
|
+
"host" => ENV.fetch("DATABASE_HOST", "localhost"),
|
38
|
+
"port" => ENV.fetch("DATABASE_PORT", "5432").to_i,
|
39
|
+
"username" => ENV.fetch("DATABASE_USERNAME", "decidim"),
|
40
|
+
"password" => ENV.fetch("DATABASE_PASSWORD", "TEST-insecure-password"),
|
41
|
+
"database" => "decidim_test"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
config_file = File.expand_path("#{app_path}/config/database.yml", __dir__)
|
45
|
+
File.open(config_file, "w") { |f| YAML.dump(databaseYml, f) }
|
46
|
+
Dir.chdir("#{app_path}") do
|
47
|
+
system("bundle exec rails db:create")
|
48
|
+
system("bundle exec rails decidim_lausanne_budgets:install:migrations")
|
49
|
+
system("bundle exec rails db:migrate")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Generates a dummy app for testing"
|
54
|
+
task :test_app do
|
55
|
+
ENV["RAILS_ENV"] = "test"
|
56
|
+
Bundler.with_original_env do
|
57
|
+
generate_decidim_app(
|
58
|
+
"spec/dummy",
|
59
|
+
"--app_name",
|
60
|
+
"decidim_test",
|
61
|
+
"--path",
|
62
|
+
"../..",
|
63
|
+
"--skip_spring",
|
64
|
+
"--demo",
|
65
|
+
"--force_ssl",
|
66
|
+
"false",
|
67
|
+
"--locales",
|
68
|
+
"en,fr,es"
|
69
|
+
)
|
70
|
+
prepare_database("spec/dummy")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Generates a development app"
|
75
|
+
task :development_app do
|
76
|
+
ENV["RAILS_ENV"] = "development"
|
77
|
+
Bundler.with_original_env do
|
78
|
+
generate_decidim_app(
|
79
|
+
"development_app",
|
80
|
+
"--app_name",
|
81
|
+
"decidim_dev",
|
82
|
+
"--path",
|
83
|
+
"..",
|
84
|
+
"--skip_spring",
|
85
|
+
"--demo",
|
86
|
+
"--force_ssl",
|
87
|
+
"false",
|
88
|
+
"--locales",
|
89
|
+
"en,fr,es"
|
90
|
+
)
|
91
|
+
prepare_database("development_app")
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell has the commons for the budgets cells
|
7
|
+
class BaseCell < Decidim::ViewModel
|
8
|
+
include Decidim::LayoutHelper
|
9
|
+
include Decidim::SanitizeHelper
|
10
|
+
include Decidim::ComponentPathHelper
|
11
|
+
include Decidim::Lausanne::Budgets::Engine.routes.url_helpers
|
12
|
+
|
13
|
+
delegate :current_user, :current_settings, :current_component, :current_workflow, to: :controller
|
14
|
+
delegate :settings, to: :current_component
|
15
|
+
|
16
|
+
def budgets_link_list(budgets)
|
17
|
+
budgets.map { |budget| link_to(translated_attribute(budget.title), resource_locator(budget).path) }
|
18
|
+
.to_sentence
|
19
|
+
.html_safe
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the budget card for an instance of a budget
|
7
|
+
# the default size is the Medium Card (:m)
|
8
|
+
class BudgetCell < Decidim::ViewModel
|
9
|
+
include Cell::ViewModel::Partial
|
10
|
+
|
11
|
+
def show
|
12
|
+
cell card_size, model, options
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def card_size
|
18
|
+
"decidim/lausanne/budgets/budget_m"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div id="budget-modal-info">
|
2
|
+
<div class="info__header">
|
3
|
+
<h3 class="info__title"><%= decidim_sanitize(component_name) %></h3>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<%= content_tag(:p, more_information) if more_information %>
|
7
|
+
|
8
|
+
<% unless current_workflow.single? %>
|
9
|
+
<p>
|
10
|
+
<%= link_to t(:back_to, scope: i18n_scope, component_name: component_name), lausanne_budgets_path %>
|
11
|
+
</p>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="row">
|
15
|
+
<div class="columns medium-8 medium-offset-2">
|
16
|
+
<button class="button expanded" data-close>
|
17
|
+
<%= t(:continue, scope: i18n_scope) %>
|
18
|
+
</button>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the Budgets component "More information" modal dialog
|
7
|
+
class BudgetInformationModalCell < BaseCell
|
8
|
+
alias budget model
|
9
|
+
|
10
|
+
def more_information
|
11
|
+
translated_attribute(current_settings.more_information_modal).presence || translated_attribute(settings.more_information_modal)
|
12
|
+
end
|
13
|
+
|
14
|
+
def component_name
|
15
|
+
translated_attribute(current_component.name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def i18n_scope
|
19
|
+
"decidim.lausanne_budgets.budget_information_modal"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="<%= card_class %>">
|
2
|
+
<div class="card--list__text">
|
3
|
+
<%= link_to lausanne_budget_path(budget), class: link_class do %>
|
4
|
+
<% if voted? && !voting_finished? %>
|
5
|
+
<strong>
|
6
|
+
<%= translated_attribute(title) %>
|
7
|
+
</strong>
|
8
|
+
<span class="button tiny success card--list__check card--list__check--disabled">
|
9
|
+
<%= icon "check", class: "icon--small", role: "img" %>
|
10
|
+
</span>
|
11
|
+
<% else %>
|
12
|
+
<%= translated_attribute(title) %>
|
13
|
+
<% if progress? && !voting_finished? %>
|
14
|
+
<span class="button tiny hollow secondary card--list__check card--list__check--disabled">
|
15
|
+
<%= icon "bookmark", class: "icon--small", role: "img" %>
|
16
|
+
</span>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the budget item list in the budgets list
|
7
|
+
class BudgetListItemCell < BaseCell
|
8
|
+
delegate :voting_finished?, to: :controller
|
9
|
+
|
10
|
+
property :title
|
11
|
+
property :excerpt
|
12
|
+
alias budget model
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def card_class
|
17
|
+
["card--list__item"].tap do |list|
|
18
|
+
unless voting_finished?
|
19
|
+
list << "card--list__data-added" if voted?
|
20
|
+
list << "card--list__data-progress" if progress?
|
21
|
+
end
|
22
|
+
end.join(" ")
|
23
|
+
end
|
24
|
+
|
25
|
+
def link_class
|
26
|
+
"card__link card--list__heading"
|
27
|
+
end
|
28
|
+
|
29
|
+
def voted?
|
30
|
+
current_user && status == :voted
|
31
|
+
end
|
32
|
+
|
33
|
+
def progress?
|
34
|
+
current_user && status == :progress
|
35
|
+
end
|
36
|
+
|
37
|
+
def status
|
38
|
+
@status ||= current_workflow.status(budget)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="card__icondata">
|
2
|
+
<ul class="card-data">
|
3
|
+
<li class="card-data__item">
|
4
|
+
<%= icon "euro-outline", class: "icon--big", role: "img", "aria-hidden": true %>
|
5
|
+
</li>
|
6
|
+
<li class="card-data__item">
|
7
|
+
<div class="text-left">
|
8
|
+
<strong class="heading4"><%= budget_to_currency model.total_budget %></strong>
|
9
|
+
</div>
|
10
|
+
</li>
|
11
|
+
</ul>
|
12
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the Medium (:m) budget card
|
7
|
+
# for an given instance of a Decidim::Lausanne::Budgets::LausanneBudget
|
8
|
+
class BudgetMCell < Decidim::CardMCell
|
9
|
+
include ActiveSupport::NumberHelper
|
10
|
+
include Decidim::Lausanne::Budgets::ProjectsHelper
|
11
|
+
|
12
|
+
def statuses
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the Budgets component header
|
7
|
+
class BudgetsHeaderCell < BaseCell
|
8
|
+
private
|
9
|
+
|
10
|
+
def landing_page_content
|
11
|
+
translated_attribute(current_settings.landing_page_content).presence || translated_attribute(settings.landing_page_content)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if highlighted? %>
|
2
|
+
<p id="highlighted-budget">
|
3
|
+
<% highlighted.each do |budget| %>
|
4
|
+
<%= link_to(
|
5
|
+
t("highlighted_cta", scope: i18n_scope,
|
6
|
+
name: translated_attribute(budget.title)),
|
7
|
+
resource_locator(budget).path,
|
8
|
+
class: :button ) %>
|
9
|
+
<% end %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="columns medium-7 mediumlarge-8">
|
3
|
+
<% if !voting_finished? && (highlighted? || voted?) %>
|
4
|
+
<div class="section">
|
5
|
+
<h3 class="section-heading">
|
6
|
+
<%= t(:my_budgets, scope: i18n_scope) %>
|
7
|
+
</h3>
|
8
|
+
|
9
|
+
<%= render :highlighted %>
|
10
|
+
<%= render :voted %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="row">
|
15
|
+
<div class="columns mediumlarge-6">
|
16
|
+
<%= render :card_list %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% if voted? %>
|
2
|
+
<div id="voted-budgets">
|
3
|
+
<p class="lead">
|
4
|
+
<%= t(:voted_on, scope: i18n_scope, links: budgets_link_list(voted)) %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% if finished? %>
|
8
|
+
<p class="lead">
|
9
|
+
<%= t(:finished_message, scope: i18n_scope) %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if voting_open? %>
|
14
|
+
<div>
|
15
|
+
<p>
|
16
|
+
<%= t(:if_change_opinion, scope: i18n_scope) %>
|
17
|
+
<%= link_to(
|
18
|
+
t("cancel_order.only_one", scope: i18n_scope),
|
19
|
+
budget_order_path(voted.first),
|
20
|
+
method: :delete,
|
21
|
+
data: { confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.lausanne_budgets") }) if voted.one? %>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<% if !voted.one? && voted.any? %>
|
25
|
+
<ul>
|
26
|
+
<% voted.each do |budget| %>
|
27
|
+
<li>
|
28
|
+
<%= link_to(
|
29
|
+
t("cancel_order.more_than_one", scope: i18n_scope, name: translated_attribute(budget.title)),
|
30
|
+
budget_order_path(budget),
|
31
|
+
method: :delete,
|
32
|
+
class: "cancel-order",
|
33
|
+
data: {
|
34
|
+
confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.lausanne_budgets")
|
35
|
+
}) %>
|
36
|
+
</li>
|
37
|
+
<% end %>
|
38
|
+
</ul>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
43
|
+
<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the budgets list of a Budget component
|
7
|
+
class BudgetsListCell < BaseCell
|
8
|
+
alias current_workflow model
|
9
|
+
|
10
|
+
delegate :allowed, :budgets, :highlighted, :voted, to: :current_workflow
|
11
|
+
delegate :voting_open?, :voting_finished?, to: :controller
|
12
|
+
|
13
|
+
def show
|
14
|
+
return unless budgets
|
15
|
+
render
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def highlighted?
|
21
|
+
current_user && highlighted.any?
|
22
|
+
end
|
23
|
+
|
24
|
+
def voted?
|
25
|
+
current_user && voted.any?
|
26
|
+
end
|
27
|
+
|
28
|
+
def finished?
|
29
|
+
return unless budgets.any?
|
30
|
+
|
31
|
+
current_user && (allowed - voted).none?
|
32
|
+
end
|
33
|
+
|
34
|
+
def i18n_scope
|
35
|
+
"decidim.lausanne_budgets.budgets_list"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders information when current user can't create more budgets orders.
|
7
|
+
class LimitAnnouncementCell < BaseCell
|
8
|
+
alias budget model
|
9
|
+
delegate :voted?, :vote_allowed?, :discardable, :limit_reached?, to: :current_workflow
|
10
|
+
delegate :voting_open?, to: :controller
|
11
|
+
|
12
|
+
def show
|
13
|
+
cell("decidim/announcement", announcement_message, callout_class: "warning") if announce?
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def announce?
|
19
|
+
return unless voting_open?
|
20
|
+
return unless current_user
|
21
|
+
return if vote_allowed?(budget)
|
22
|
+
return if voted?(budget)
|
23
|
+
|
24
|
+
discardable.any? || !vote_allowed?(budget, consider_progress: false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def announcement_message
|
28
|
+
if discardable.any?
|
29
|
+
t(:limit_reached, scope: i18n_scope,
|
30
|
+
links: budgets_link_list(discardable),
|
31
|
+
landing_path: lausanne_budgets_path)
|
32
|
+
else
|
33
|
+
t(:cant_vote, scope: i18n_scope, landing_path: lausanne_budgets_path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def should_discard_to_vote?
|
38
|
+
limit_reached? && discardable.any?
|
39
|
+
end
|
40
|
+
|
41
|
+
def i18n_scope
|
42
|
+
"decidim.lausanne_budgets.limit_announcement"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Lausanne
|
5
|
+
module Budgets
|
6
|
+
# This cell renders the budget project card for an instance of a project
|
7
|
+
# the default size is the Medium Card (:m)
|
8
|
+
class ProjectCell < Decidim::ViewModel
|
9
|
+
include Cell::ViewModel::Partial
|
10
|
+
|
11
|
+
def show
|
12
|
+
cell card_size, model, options
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def card_size
|
18
|
+
"decidim/lausanne/budgets/project_m"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|