decidim-process_groups_content_block 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +75 -1
- data/app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups/show.erb +36 -6
- data/app/cells/decidim/process_groups_content_block/content_blocks/highlighted_process_groups_cell.rb +27 -12
- data/config/locales/en.yml +3 -2
- data/config/locales/fi.yml +3 -2
- data/lib/decidim/process_groups_content_block/engine.rb +3 -1
- data/lib/decidim/process_groups_content_block/version.rb +3 -1
- data/lib/decidim/process_groups_content_block.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d7d1dc8bfb5244bfcb6d553c752f7e5c3af18b90b35a68af834f862e56aefddf
|
|
4
|
+
data.tar.gz: 9156032a3a4c28596ea5a0a9bd763d11e4c101ee58ecffe46257248ce7be49c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ebe1a7585e5038d27166c6a4225362086728fdbeb9caf2caabacee519c108415151568636b316699ae030a323ed598c80736f48a3e082d66fd3ec0893a3d018
|
|
7
|
+
data.tar.gz: d8c072c223ec648ac9b1b19353993a3eeeefe4b51af8e00b2b95fe58ed818c81e7933533261b8c9d1cbccee1efa44441fb1ffa6fcba72be873e7441c9cfa9773
|
data/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Decidim::ProcessGroupsContentBlock
|
|
2
2
|
|
|
3
|
+
[](https://travis-ci.com/mainio/decidim-module-process_groups_content_block)
|
|
4
|
+
[](https://codecov.io/gh/mainio/decidim-module-process_groups_content_block)
|
|
5
|
+
|
|
6
|
+
The gem has been developed by [Mainio Tech](https://www.mainiotech.fi/).
|
|
7
|
+
|
|
3
8
|
Adds a process groups content block to your Decidim instance to be used on the
|
|
4
9
|
home page of the app.
|
|
5
10
|
|
|
@@ -8,7 +13,7 @@ home page of the app.
|
|
|
8
13
|
Add this line to your application's Gemfile:
|
|
9
14
|
|
|
10
15
|
```ruby
|
|
11
|
-
gem
|
|
16
|
+
gem "decidim-process_groups_content_block"
|
|
12
17
|
```
|
|
13
18
|
|
|
14
19
|
And then execute:
|
|
@@ -28,6 +33,63 @@ $ bundle
|
|
|
28
33
|
|
|
29
34
|
See [Decidim](https://github.com/decidim/decidim).
|
|
30
35
|
|
|
36
|
+
### Developing
|
|
37
|
+
|
|
38
|
+
To start contributing to this project, first:
|
|
39
|
+
|
|
40
|
+
- Install the basic dependencies (such as Ruby and PostgreSQL)
|
|
41
|
+
- Clone this repository
|
|
42
|
+
|
|
43
|
+
Decidim's main repository also provides a Docker configuration file if you
|
|
44
|
+
prefer to use Docker instead of installing the dependencies locally on your
|
|
45
|
+
machine.
|
|
46
|
+
|
|
47
|
+
You can create the development app by running the following commands after
|
|
48
|
+
cloning this project:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ bundle
|
|
52
|
+
$ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake development_app
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note that the database user has to have rights to create and drop a database in
|
|
56
|
+
order to create the dummy test app database.
|
|
57
|
+
|
|
58
|
+
Then to test how the module works in Decidim, start the development server:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
$ cd development_app
|
|
62
|
+
$ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
|
|
66
|
+
[rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
|
|
67
|
+
can add the environment variables to the root directory of the project in a file
|
|
68
|
+
named `.rbenv-vars`. If these are defined for the environment, you can omit
|
|
69
|
+
defining these in the commands shown above.
|
|
70
|
+
|
|
71
|
+
#### Code Styling
|
|
72
|
+
|
|
73
|
+
Please follow the code styling defined by the different linters that ensure we
|
|
74
|
+
are all talking with the same language collaborating on the same project. This
|
|
75
|
+
project is set to follow the same rules that Decidim itself follows.
|
|
76
|
+
|
|
77
|
+
[Rubocop](https://rubocop.readthedocs.io/) linter is used for the Ruby language.
|
|
78
|
+
|
|
79
|
+
You can run the code styling checks by running the following commands from the
|
|
80
|
+
console:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
$ bundle exec rubocop
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To ease up following the style guide, you should install the plugin to your
|
|
87
|
+
favorite editor, such as:
|
|
88
|
+
|
|
89
|
+
- Atom - [linter-rubocop](https://atom.io/packages/linter-rubocop)
|
|
90
|
+
- Sublime Text - [Sublime RuboCop](https://github.com/pderichs/sublime_rubocop)
|
|
91
|
+
- Visual Studio Code - [Rubocop for Visual Studio Code](https://github.com/misogi/vscode-ruby-rubocop)
|
|
92
|
+
|
|
31
93
|
### Testing
|
|
32
94
|
|
|
33
95
|
To run the tests run the following in the gem development path:
|
|
@@ -47,6 +109,18 @@ can add these environment variables to the root directory of the project in a
|
|
|
47
109
|
file named `.rbenv-vars`. In this case, you can omit defining these in the
|
|
48
110
|
commands shown above.
|
|
49
111
|
|
|
112
|
+
### Test code coverage
|
|
113
|
+
|
|
114
|
+
If you want to generate the code coverage report for the tests, you can use
|
|
115
|
+
the `SIMPLECOV=1` environment variable in the rspec command as follows:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
$ SIMPLECOV=1 bundle exec rspec
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This will generate a folder named `coverage` in the project root which contains
|
|
122
|
+
the code coverage report.
|
|
123
|
+
|
|
50
124
|
## License
|
|
51
125
|
|
|
52
126
|
See [LICENSE-AGPLv3.txt](LICENSE-AGPLv3.txt).
|
|
@@ -2,19 +2,49 @@
|
|
|
2
2
|
<div class="row" id="highlighted-process-groups">
|
|
3
3
|
<h3 class="section-heading"><%= t("active_processes", scope: i18n_scope) %></h3>
|
|
4
4
|
<div class="row collapse">
|
|
5
|
-
<div class="row small-up-1
|
|
6
|
-
large-up-4 card-grid">
|
|
5
|
+
<div class="row small-up-1 medium-up-2 large-up-3 card-grid">
|
|
7
6
|
<% highlighted_groups.each do |group| %>
|
|
8
7
|
<div class="column">
|
|
9
8
|
<article class="card card--process card--stack card--mini">
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
<% if group.hero_image.url.present? %>
|
|
10
|
+
<%= link_to decidim_participatory_processes.participatory_process_group_path(group), class: "card__link" do %>
|
|
11
|
+
<%= image_tag group.hero_image.url, alt: title_for(group), class: "card__image" %>
|
|
12
|
+
<% end %>
|
|
13
13
|
<% end %>
|
|
14
|
+
|
|
14
15
|
<div class="card__content">
|
|
15
16
|
<%= link_to decidim_participatory_processes.participatory_process_group_path(group), class: "card__link" do %>
|
|
16
|
-
<h4 class="card__title"><%=
|
|
17
|
+
<h4 class="card__title"><%= title_for(group) %></h4>
|
|
17
18
|
<% end %>
|
|
19
|
+
<div class="card__text">
|
|
20
|
+
<div class="card__text--paragraph">
|
|
21
|
+
<%= description_for(group) %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="card__icondata">
|
|
27
|
+
<ul class="card-data">
|
|
28
|
+
<li class="card-data__item">
|
|
29
|
+
<%= icon "process" %>
|
|
30
|
+
</li>
|
|
31
|
+
<li class="card-data__item">
|
|
32
|
+
<div>
|
|
33
|
+
<strong><%= t("layouts.decidim.participatory_process_groups.participatory_process_group.processes_count") %></strong>
|
|
34
|
+
<%= group.participatory_processes.published.count.to_s %>
|
|
35
|
+
</div>
|
|
36
|
+
</li>
|
|
37
|
+
</ul>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div class="card__footer">
|
|
41
|
+
<div class="card__support">
|
|
42
|
+
<%= link_to(
|
|
43
|
+
t("layouts.decidim.participatory_process_groups.participatory_process_group.browse"),
|
|
44
|
+
decidim_participatory_processes.participatory_process_group_path(group),
|
|
45
|
+
class: "card__button button hollow primary"
|
|
46
|
+
) %>
|
|
47
|
+
</div>
|
|
18
48
|
</div>
|
|
19
49
|
</article>
|
|
20
50
|
</div>
|
|
@@ -4,26 +4,30 @@ module Decidim
|
|
|
4
4
|
module ProcessGroupsContentBlock
|
|
5
5
|
module ContentBlocks
|
|
6
6
|
class HighlightedProcessGroupsCell < Decidim::ViewModel
|
|
7
|
-
include Decidim::
|
|
7
|
+
include Decidim::ApplicationHelper # html_truncate
|
|
8
|
+
include Decidim::LayoutHelper # If icons are needed in the (customized) view
|
|
9
|
+
include Decidim::SanitizeHelper # decidim_sanitize
|
|
8
10
|
|
|
9
11
|
delegate :current_organization, to: :controller
|
|
10
12
|
delegate :current_user, to: :controller
|
|
11
13
|
|
|
12
14
|
def show
|
|
13
|
-
if highlighted_groups.any?
|
|
14
|
-
render
|
|
15
|
-
end
|
|
15
|
+
render if highlighted_groups.any?
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def highlighted_groups
|
|
19
|
-
Decidim::ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcessGroups
|
|
20
|
-
current_organization
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
Decidim::ParticipatoryProcesses::OrganizationPrioritizedParticipatoryProcessGroups
|
|
20
|
+
.new(current_organization)
|
|
21
|
+
.query
|
|
22
|
+
.joins(:participatory_processes)
|
|
23
|
+
.where.not(decidim_participatory_processes: { published_at: nil })
|
|
24
|
+
.where(
|
|
25
|
+
"decidim_participatory_processes.end_date IS NULL "\
|
|
26
|
+
"OR decidim_participatory_processes.end_date > ?",
|
|
27
|
+
Time.current
|
|
28
|
+
)
|
|
29
|
+
.group("decidim_participatory_process_groups.id")
|
|
30
|
+
.having("COUNT(decidim_participatory_processes.id) > 0")
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
def i18n_scope
|
|
@@ -33,6 +37,17 @@ module Decidim
|
|
|
33
37
|
def decidim_participatory_processes
|
|
34
38
|
Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
|
|
35
39
|
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def title_for(group)
|
|
44
|
+
translated_attribute(group.name)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def description_for(group)
|
|
48
|
+
text = translated_attribute(group.description)
|
|
49
|
+
decidim_sanitize(html_truncate(text, length: 100))
|
|
50
|
+
end
|
|
36
51
|
end
|
|
37
52
|
end
|
|
38
53
|
end
|
data/config/locales/en.yml
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
---
|
|
1
2
|
en:
|
|
2
3
|
decidim:
|
|
3
4
|
process_groups_content_block:
|
|
@@ -7,5 +8,5 @@ en:
|
|
|
7
8
|
pages:
|
|
8
9
|
home:
|
|
9
10
|
highlighted_process_groups:
|
|
10
|
-
active_processes:
|
|
11
|
-
see_all_processes:
|
|
11
|
+
active_processes: Active processes
|
|
12
|
+
see_all_processes: Show all processes
|
data/config/locales/fi.yml
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
---
|
|
1
2
|
fi:
|
|
2
3
|
decidim:
|
|
3
4
|
process_groups_content_block:
|
|
@@ -7,5 +8,5 @@ fi:
|
|
|
7
8
|
pages:
|
|
8
9
|
home:
|
|
9
10
|
highlighted_process_groups:
|
|
10
|
-
active_processes:
|
|
11
|
-
see_all_processes:
|
|
11
|
+
active_processes: Aktiiviset prosessit
|
|
12
|
+
see_all_processes: Näytä kaikki prosessit
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Decidim
|
|
2
4
|
module ProcessGroupsContentBlock
|
|
3
5
|
class Engine < ::Rails::Engine
|
|
@@ -7,7 +9,7 @@ module Decidim
|
|
|
7
9
|
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::ProcessGroupsContentBlock::Engine.root}/app/cells")
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
initializer
|
|
12
|
+
initializer "decidim_process_groups_content_block.content_blocks" do
|
|
11
13
|
Decidim.content_blocks.register(:homepage, :highlighted_process_groups) do |content_block|
|
|
12
14
|
content_block.cell = "decidim/process_groups_content_block/content_blocks/highlighted_process_groups"
|
|
13
15
|
content_block.public_name_key = "decidim.process_groups_content_block.content_blocks.highlighted_process_groups.name"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-process_groups_content_block
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.16.
|
|
4
|
+
version: 0.16.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Antti Hukkanen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: decidim-core
|
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
118
118
|
version: '0'
|
|
119
119
|
requirements: []
|
|
120
120
|
rubyforge_project:
|
|
121
|
-
rubygems_version: 2.6
|
|
121
|
+
rubygems_version: 2.7.6
|
|
122
122
|
signing_key:
|
|
123
123
|
specification_version: 4
|
|
124
124
|
summary: Process groups content block for Decidim.
|