Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Decidim Initiatives into Decidim #3125

Merged
merged 24 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6d5a8ff
Decidim initiatives added to project
jsperezg Apr 3, 2018
a6119fe
Several fixes
jsperezg Apr 3, 2018
3dfd851
Fixed locale issues
jsperezg Apr 3, 2018
254295a
Fixed reference to PR in changelog
jsperezg Apr 3, 2018
1799bdb
Fixed codeclimate offenses
jsperezg Apr 3, 2018
bd29de9
Fixed more codeclimate offenses
jsperezg Apr 3, 2018
084664e
Fixed core specs
jsperezg Apr 4, 2018
08afdc1
Fixed issue with ability in initiatives
jsperezg Apr 4, 2018
c5e0abe
CircleCI configuration updated after rebase with master
jsperezg Apr 4, 2018
a9dc548
Fixed failing test after rebasing with master
jsperezg Apr 4, 2018
3343551
Added specs for initiatives mailer.
jsperezg Apr 4, 2018
c619570
Added tests when filtering manageable initiatives per title or
jsperezg Apr 4, 2018
76df2c6
Added specs for create initiative helper
jsperezg Apr 4, 2018
499ad79
Rake tasks excluded from coverage report
jsperezg Apr 5, 2018
3579bfd
Merge branch 'master' into issue_3118
jsperezg Apr 5, 2018
a1a181c
Decidim initiatives is an optional feature.
jsperezg Apr 11, 2018
03c9bf0
Merge branch 'master' into issue_3118
jsperezg Apr 12, 2018
778f2a4
Fixed rubocop offenses
jsperezg Apr 12, 2018
f2eddc2
Controller test turned into system test to prevent issues
jsperezg Apr 12, 2018
6336544
Merge branch 'master' into issue_3118
josepjaume Apr 18, 2018
121ae07
Update design app bundle
josepjaume Apr 18, 2018
f99cd7f
Merge remote-tracking branch 'origin/master' into issue_3118
josepjaume Apr 19, 2018
471e5ec
Merge remote-tracking branch 'origin/master' into issue_3118
josepjaume Apr 23, 2018
ed352b6
Bump CC reports number
mrcasals Apr 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@ jobs:
root: coverage
paths:
- codeclimate.assemblies.json
initiatives:
<<: *defaults
steps:
- attach_workspace:
at: /app
- restore_cache:
keys:
- bundler-dependencies-{{ checksum "Gemfile.lock" }}
- run:
name: Wait for db
command: dockerize -wait tcp://localhost:5432 -timeout 2m
- run:
name: Create test DB
command: cd spec/decidim_dummy_app && RAILS_ENV=test bundle exec rails db:create db:schema:load
- run:
name: Run initiatives RSpec
command: mkdir ~/rspec && cd decidim-initiatives && rake
- run:
name: Format CodeClimate test coverage
command: ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.initiatives.json coverage/.resultset.json
- store_artifacts:
path: /app/spec/decidim_dummy_app/tmp/screenshots
- store_test_results:
path: ~/rspec
- persist_to_workspace:
root: coverage
paths:
- codeclimate.initiatives.json
api:
<<: *defaults
steps:
Expand Down Expand Up @@ -642,7 +670,7 @@ jobs:
- run:
name: Upload coverage results to Code Climate
command: |
./cc-test-reporter sum-coverage codeclimate.*.json -p 18 -o codeclimate.total.json
./cc-test-reporter sum-coverage codeclimate.*.json -p 19 -o codeclimate.total.json
./cc-test-reporter upload-coverage -i codeclimate.total.json

workflows:
Expand Down Expand Up @@ -679,6 +707,9 @@ workflows:
- assemblies:
requires:
- build_test_app
- initiatives:
requires:
- build_test_app
- api:
requires:
- build_test_app
Expand Down Expand Up @@ -733,6 +764,7 @@ workflows:
- generators
- core
- assemblies
- initiatives
- api
- processes
- admin
Expand Down
1 change: 1 addition & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SimpleCov.start do
add_filter "/spec/decidim_dummy_app/"
add_filter "bundle.js"
add_filter "/vendor/"
add_filter ".rake"
end

SimpleCov.merge_timeout 1800
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ controller or added a new module you need to rename `feature` to `component`.

**Added**:

- **decidim-initiatives**: Decidim Initiatives Gem has been integrated into the main repository. [\#3125](https://github.com/decidim/decidim/pull/3125)
- **decidim-blogs**: Decidim Blogs gem has been integrated into the main repository. [\#3221](https://github.com/decidim/decidim/pull/3221)
- **decidim-meetings** Add services offered in the meeting. [\#3150](https://github.com/decidim/decidim/pull/3150)
- **decidim-assemblies**: Adding news fields into assembly in terms of database [\#2942](https://github.com/decidim/decidim/pull/2942)
Expand All @@ -19,7 +20,7 @@ controller or added a new module you need to rename `feature` to `component`.
- **decidim-core**: Decidim as OAuth provider [\#3057](https://github.com/decidim/decidim/pull/3057)
- **decidim-consultations**: Decidim Consultations Gem has been integrated into the main repository. [\#3106](https://github.com/decidim/decidim/pull/3106)
- **decidim-debates**: Fix debates times. [\#3071](https://github.com/decidim/decidim/pull/3071)
- **decidim-sortitions**: Decidim Sortitions Gem has been integrated into the main repository. [\#3077](https://github.com/decidim/decidim/pull/3077)
- **decidim-sortitions**: Decidim Sortitions Gem has been integrated into the main repository. [\#3077](https://github.com/decidim/decidim/pull/3077)
- **decidim-meetings**: Allows admins to duplicate or copy face-to-face meetings. [\#3051](https://github.com/decidim/decidim/pull/3051)
- **decidim**: Added private_space and participatory space private users. [\#2618](https://github.com/decidim/decidim/pull/2618)
- **decidim-core**: Add ParticipatorySpaceResourceable between Assemblies and ParticipatoryProcesses [\#2851](https://github.com/decidim/decidim/pull/2851)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ruby RUBY_VERSION

gem "decidim", path: "."
gem "decidim-consultations", path: "decidim-consultations"
gem "decidim-initiatives", path: "decidim-initiatives"

gem "puma", "~> 3.0"
gem "uglifier", "~> 4.1"
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ PATH
simplecov (~> 0.13)
webmock (~> 3.0)
wisper-rspec (~> 1.0)
decidim-initiatives (0.11.0.pre)
decidim-admin (= 0.11.0.pre)
decidim-comments (= 0.11.0.pre)
decidim-core (= 0.11.0.pre)
decidim-verifications (= 0.11.0.pre)
kaminari (~> 1.0)
rectify
social-share-button (~> 1.0)
truncato
wicked
decidim-generators (0.11.0.pre)
decidim-core (= 0.11.0.pre)
decidim-meetings (0.11.0.pre)
Expand Down Expand Up @@ -651,6 +661,8 @@ GEM
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
wicked (1.3.2)
railties (>= 3.0.7)
wisper (2.0.0)
wisper-rspec (1.0.1)
xpath (3.0.0)
Expand All @@ -664,6 +676,7 @@ DEPENDENCIES
decidim!
decidim-consultations!
decidim-dev!
decidim-initiatives!
faker (~> 1.8)
letter_opener_web (~> 1.3)
listen (~> 3.1)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ Also, if you want to verify yourself against the default authorization handler u
| [System](https://github.com/decidim/decidim/tree/master/decidim-system) | Multitenant Admin to manage multiple organizations in a single installation. |
| [Sortitions](https://github.com/decidim/decidim/tree/master/decidim-sortitions) | This component makes possible to select randomly a number of proposals among a set of proposals (or a category of proposals within a set) maximizing guarantees of randomness and avoiding manipulation of results by the administrator. |
| [Consultations](https://github.com/decidim/decidim/tree/master/decidim-consultations) | This module creates a new space for decidim to host consultations: debates around critical questions and a proxy for eVoting |
| [Initiatives](https://github.com/decidim/decidim/tree/master/decidim-initiatives) | Initiatives is the place on Decidim's where citizens can promote a civic initiative. Unlike participatory processes that must be created by an administrator, Civic initiatives can be created by any user of the platform. |
| [Blogs](https://github.com/decidim/decidim-module-blogs) | This component makes possible to add posts ordered by publication time to spaces. |

### Official (on development)

| Module | Description |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------
| [Initiatives](https://github.com/decidim/decidim-initiatives) | Initiatives is the place on Decidim's where citizens can promote a civic initiative. Unlike participatory processes that must be created by an administrator, Civic initiatives can be created by any user of the platform. |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Blogs](https://github.com/decidim/decidim-module-blogs) | This component makes possible to add posts ordered by publication time to spaces. |

### Community

Expand Down
4 changes: 4 additions & 0 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ ignore_unused:
- decidim.sortitions.sortitions.orders.*
- decidim.consultations.admin_log.*
- decidim.consultations.consultations.orders.*
- decidim.initiatives.admin_log.*
- decidim.initiatives.initiatives.orders.*
- decidim.initiatives.states.*
- decidim.initiatives.admin_states.*
- decidim.events.*
- doorkeeper.scopes.*

Expand Down
3 changes: 2 additions & 1 deletion decidim-admin/spec/helpers/menu_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ module Admin

it "renders the default main menu" do
expect(default_main_menu).to \
have_selector("li", count: 11) &
have_selector("li", count: 12) &
have_link("Dashboard", href: "/admin/") &
have_link("Processes", href: "/admin/participatory_processes") &
have_link("Process groups", href: "/admin/participatory_process_groups") &
have_link("Assemblies", href: "/admin/assemblies") &
have_link("Consultations", href: "/admin/consultations") &
have_link("Initiatives", href: "/admin/initiatives") &
have_link("Pages", href: "/admin/static_pages") &
have_link("Users", href: "/admin/users") &
have_link("Newsletters", href: "/admin/newsletters") &
Expand Down
3 changes: 2 additions & 1 deletion decidim-core/spec/system/menu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
it "renders the default main menu" do
within ".main-nav" do
expect(page).to \
have_selector("li", count: 2) &
have_selector("li", count: 3) &
have_link("Home", href: "/") &
have_link("Initiatives", href: "/initiatives") &
have_link("More information", href: "/pages")
end
end
Expand Down
1 change: 1 addition & 0 deletions decidim-generators/lib/decidim/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def gemfile
end

gsub_file "Gemfile", /gem "#{current_gem}".*/, "gem \"#{current_gem}\", #{gem_modifier}"
gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}" if current_gem == "decidim"
gsub_file "Gemfile", /gem "decidim-([A-z]+)".*/, "# gem \"decidim-\\1\", #{gem_modifier}"
gsub_file "Gemfile", /(# )?gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}" if current_gem == "decidim"

Expand Down
5 changes: 5 additions & 0 deletions decidim-initiatives/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

inherit_from:
- ../.rubocop.yml
- .rubocop_rails.yml
1 change: 1 addition & 0 deletions decidim-initiatives/.rubocop_rails.yml
118 changes: 118 additions & 0 deletions decidim-initiatives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Decidim::Initiatives

Initiatives is the place on Decidim's where citizens can promote a civic initiative. Unlike
participatory processes that must be created by an administrator, Civic initiatives can be
created by any user of the platform.

An initiative will contain attachments and comments from other users as well.

Prior to be published an initiative must be technically validated. All the validation
process and communication between the platform administrators and the sponsorship
committee is managed via an administration UI.

## Usage

This plugin provides:

* A CRUD engine to manage initiatives.

* Public views for initiatives via a high level section in the main menu.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'decidim-initiatives'
```

And then execute:

```bash
bundle
bundle exec rails decidim_initiatives:install:migrations
bundle exec rails db:migrate
```

## Database

The database requires the extension pg_trgm enabled. Contact your DBA to enable it.

```sql
CREATE EXTENSION pg_trgm;
```

## Rake tasks

This engine comes with three rake tasks that should be executed on daily basis. The best
way to execute these tasks is using cron jobs. You can manage this cron jobs in your
Rails application using the [Whenever GEM](https://github.com/javan/whenever) or even
creating them by hand.

### decidim_initiatives:check_validating

This task move all initiatives in validation phase without changes for the amount of
time defined in __Decidim::Initiatives::max_time_in_validating_state__. These initiatives
will be moved to __discarded__ state.

### decidim_initiatives:check_published

This task retrieves all published initiatives whose support method is online and the support
period has expired. Initiatives that have reached the minimum supports required will pass
to state __accepted__. The initiatives without enough supports will pass to __rejected__ state.

Initiatives with offline support method enabled (pure offline or mixed) will get its status updated
after the presential supports have been registered into the system.

### decidim_initiatives:notify_progress

This task sends notification mails when initiatives reaches the support percentages defined in
__Decidim::Initiatives.first_notification_percentage__ and __Decidim::Initiatives.second_notification_percentage__.

Author, members of the promoter committee and followers will receive it.

## Exporting online votes

When the supporting method is set to any or face to face it may be necessary to implement
a mechanism to validate that do not exist duplicated supports. To do so the engine provides
a functionality that allows exporting the online votes to validate them against physical
votes.

The votes are exported as a hash string in order to preserve the identity of the voter.
Each hash is composed with the following criteria:

* Algorithm used: SHA1
* Format of the string hashed: "#{unique_id}#{title}#{description}"

There are some considerations that you must keep in mind:

* Title and description will be hashed using the same format included in the database, this is including html tags.
* Title and description will be hashed using the same locale used by the initiative author. In case there is more
than one locale available be sure that you change your locale settings to be inline with
the locale used to generate the hashes outside Decidim.

## Seeding example data

In order to populate the database with example data proceed as usual in rails:

```bash
bundle exec rails db:seed
```

## Aditional considerations

### Cookies

This engine makes use of cookies to store large form data. You should change the
default session store or you might experience problems.

Check the [Rails configuration guide](http://guides.rubyonrails.org/configuring.html#rails-general-configuration)
in order to get instructions about changing the default session store.

## Contributing

See [Decidim](https://github.com/decidim/decidim).

## License

See [Decidim](https://github.com/decidim/decidim).
3 changes: 3 additions & 0 deletions decidim-initiatives/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require "decidim/dev/common_rake"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link decidim/initiatives/admin/invite_users.js
//= link decidim/initiatives/scoped_type.js
//= link decidim/initiatives/print-initiative.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//= link decidim/initiatives/social_share.js
//= link decidim/initiatives/application.js
//= link decidim/initiatives/application.css
//= link decidim/initiatives/social_share.css
//= link decidim/initiatives/identity_selector_dialog.js
//= link decidim/initiatives/scoped_type.js
//= link decidim/initiatives/admin/invite_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable no-empty */

(function () {
let inviteUsersButton = document.querySelector(".invite-users-link");

if (inviteUsersButton !== null) {
inviteUsersButton.addEventListener("click", function (event) {
let link = document.querySelector("#committee_link"),
range = document.createRange();

event.preventDefault();

range.selectNode(link);
window.getSelection().addRange(range);

try {
document.execCommand("copy");
} catch (err) { }

window.getSelection().removeAllRanges();
});
}
}());
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// = require decidim/editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$(document).ready(function () {
let button = $("#select-identity-button"),
userIdentitiesDialog = $("#user-identities");

if (userIdentitiesDialog.length) {
let refreshUrl = userIdentitiesDialog.data("refresh-url");

button.click(function () {
$.ajax(refreshUrl).done(function(response) {
userIdentitiesDialog.html(response).foundation("open");
});
});
}
});
Loading