decidim-access_requests 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39f6bf880aa8e8201ecc2fc599011fec5f389cd7aba67482d05dacc6967be035
4
- data.tar.gz: bce4365cdb074cd3c67e34ad3ab770862c9c5650307a271ba66fa7ac4bcbeeb5
3
+ metadata.gz: 91eed9a9b7e634c1588f106f7b444c9a698953f10b8a3a6ffe00ed65b130ad74
4
+ data.tar.gz: dbf8ac7c5068bfcec1e58fb4b70ed461e4424a73d07b1b8dbd8ced9ba0ac5e05
5
5
  SHA512:
6
- metadata.gz: 7ba0ace71992061a8cab9e51a97e167f1f21ac2ec363a8edd632b3f054fc580e5f558f28a405a10b2e54cc787ac30e28d850a6bfe2d49c4dbc40d8055325ec45
7
- data.tar.gz: d3c1f00075f32d7f510a576ba7cc38fdeb6fcc7e1f3899486a40c9b3ac475d3acf005479d6a649ab8340518c9b0cb67927f9a074cd41b009a630ffcf7a1447b0
6
+ metadata.gz: 23c776bd1de10ceb68312c21159841268b06db22467ba1895212cd0c3f5e04433629b4b283c5088060b9e2ee799837a7b7b040e7cd423911defa9f99ce161fa9
7
+ data.tar.gz: db55e41c202e1cd493821ae1e743c544854bf4c5c30adad869652beb24ea6d25ca23751a9b5a21990ea845dd4924167a206492cd321c9bdbd0c356225be21766
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Decidim::AccessRequests
2
2
 
3
+ [![Build Status](https://travis-ci.com/mainio/decidim-module-access_requests.svg?branch=master)](https://travis-ci.com/mainio/decidim-module-access_requests)
4
+ [![codecov](https://codecov.io/gh/mainio/decidim-module-access_requests/branch/master/graph/badge.svg)](https://codecov.io/gh/mainio/decidim-module-access_requests)
5
+
6
+ The gem has been developed by [Mainio Tech](https://www.mainiotech.fi/).
7
+
3
8
  A [Decidim](https://github.com/decidim/decidim) module that provides a new
4
9
  verification method that allows system administrators to define new verification
5
10
  workflows where the admins can provide access to specific users.
@@ -23,14 +28,15 @@ from the admin panel. This way, the users won't have to create the access
23
28
  requests themselves and they are automatically granted the access once the admin
24
29
  has given it.
25
30
 
26
- The gem has been developed by [Mainio Tech](https://www.mainiotech.fi/).
31
+ Development of this gem has been sponsored by the
32
+ [City of Helsinki](https://www.hel.fi/).
27
33
 
28
34
  ## Installation
29
35
 
30
36
  Add this line to your application's Gemfile:
31
37
 
32
38
  ```ruby
33
- gem 'decidim-access_requests', :git => 'git@github.com:mainio/decidim-module-access_requests.git'
39
+ gem "decidim-access_requests"
34
40
  ```
35
41
 
36
42
  And then execute:
@@ -63,12 +69,104 @@ en:
63
69
 
64
70
  ## Usage
65
71
 
66
- TODO
72
+ For enabling the verifcation method:
73
+
74
+ - Follow the installation instructions above.
75
+ - Login to the system management section of Decidim at `/system`.
76
+ - Enable the newly added verification method.
77
+
78
+ After enabled, you can now send authorization requests for admins:
79
+
80
+ - Login to Decidim.
81
+ - Go to My account > Authorizations.
82
+ - Click the newly added authorization ("Your access requests").
83
+ - Click "Send request".
84
+
85
+ After the request is sent, you can now login as admin to approve the request:
86
+
87
+ - Login to Decidim as an admin user.
88
+ - Go to Admin dashboard > Users > Verifications > Access requests.
89
+ - You will see a list of received requests.
90
+ - Click the check icon to approve an access request.
91
+
92
+ After this, you can now control the access to certain functionality using
93
+ Decidim's permissions (e.g. component permssions). For example, you can limit
94
+ the creation of new proposals only for approved users.
95
+
96
+ You are not limited for waiting for the users to send the requests. Another way
97
+ to grant access is to directly grant it for the users. To do this:
98
+
99
+ - Login to Decidim as an admin user.
100
+ - Go to Admin dashboard > Users > Verifications > Access requests.
101
+ - Click "Granted requests" from the top right corner of the view.
102
+ - You will see a list of granted access requests if any are available.
103
+ - Click "New" from the top right corner of the view.
104
+ - Search the user you want to grant access to.
105
+ - Click the check icon in the "Actions" column of the users listing.
106
+
107
+ After this, the user is directly authorized to access the limited actions.
67
108
 
68
109
  ## Contributing
69
110
 
70
111
  See [Decidim](https://github.com/decidim/decidim).
71
112
 
113
+ ### Developing
114
+
115
+ To start contributing to this project, first:
116
+
117
+ - Install the basic dependencies (such as Ruby and PostgreSQL)
118
+ - Clone this repository
119
+
120
+ Decidim's main repository also provides a Docker configuration file if you
121
+ prefer to use Docker instead of installing the dependencies locally on your
122
+ machine.
123
+
124
+ You can create the development app by running the following commands after
125
+ cloning this project:
126
+
127
+ ```bash
128
+ $ bundle
129
+ $ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake development_app
130
+ ```
131
+
132
+ Note that the database user has to have rights to create and drop a database in
133
+ order to create the dummy test app database.
134
+
135
+ Then to test how the module works in Decidim, start the development server:
136
+
137
+ ```bash
138
+ $ cd development_app
139
+ $ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s
140
+ ```
141
+
142
+ In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
143
+ [rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
144
+ can add the environment variables to the root directory of the project in a file
145
+ named `.rbenv-vars`. If these are defined for the environment, you can omit
146
+ defining these in the commands shown above.
147
+
148
+ #### Code Styling
149
+
150
+ Please follow the code styling defined by the different linters that ensure we
151
+ are all talking with the same language collaborating on the same project. This
152
+ project is set to follow the same rules that Decidim itself follows.
153
+
154
+ [Rubocop](https://rubocop.readthedocs.io/) linter is used for the Ruby language.
155
+
156
+ You can run the code styling checks by running the following commands from the
157
+ console:
158
+
159
+ ```
160
+ $ bundle exec rubocop
161
+ ```
162
+
163
+ To ease up following the style guide, you should install the plugin to your
164
+ favorite editor, such as:
165
+
166
+ - Atom - [linter-rubocop](https://atom.io/packages/linter-rubocop)
167
+ - Sublime Text - [Sublime RuboCop](https://github.com/pderichs/sublime_rubocop)
168
+ - Visual Studio Code - [Rubocop for Visual Studio Code](https://github.com/misogi/vscode-ruby-rubocop)
169
+
72
170
  ### Testing
73
171
 
74
172
  To run the tests run the following in the gem development path:
@@ -94,12 +192,19 @@ If you want to generate the code coverage report for the tests, you can use
94
192
  the `SIMPLECOV=1` environment variable in the rspec command as follows:
95
193
 
96
194
  ```bash
97
- SIMPLECOV=1 bundle exec rspec
195
+ $ SIMPLECOV=1 bundle exec rspec
98
196
  ```
99
197
 
100
198
  This will generate a folder named `coverage` in the project root which contains
101
199
  the code coverage report.
102
200
 
201
+ ### Localization
202
+
203
+ If you would like to see this module in your own language, you can help with its
204
+ translation at Crowdin:
205
+
206
+ https://crowdin.com/project/decidim-access-requests
207
+
103
208
  ## License
104
209
 
105
210
  See [LICENSE-AGPLv3.txt](LICENSE-AGPLv3.txt).
data/Rakefile CHANGED
@@ -6,10 +6,40 @@ desc "Generates a dummy app for testing"
6
6
  task test_app: "decidim:generate_external_test_app"
7
7
 
8
8
  desc "Generates a development app."
9
- task development_app: "decidim:generate_external_development_app"
9
+ task :development_app do
10
+ Bundler.with_original_env do
11
+ generate_decidim_app(
12
+ "development_app",
13
+ "--app_name",
14
+ "#{base_app_name}_development_app",
15
+ "--path",
16
+ "..",
17
+ "--recreate_db",
18
+ "--demo"
19
+ )
20
+ end
21
+
22
+ # Copy the initializer and translation file to the development app folder
23
+ base_path = __dir__
24
+ source_path = "#{base_path}/lib/decidim/access_requests/generators/app_templates"
25
+ target_path = "#{base_path}/development_app/config"
26
+ FileUtils.cp(
27
+ "#{source_path}/initializer.rb",
28
+ "#{target_path}/initializers/decidim_verifications_access_requests.rb"
29
+ )
30
+ FileUtils.cp(
31
+ "#{source_path}/en.yml",
32
+ "#{target_path}/locales/decidim-access_requests.en.yml"
33
+ )
34
+
35
+ # Seed the DB after the initializer has been installed
36
+ Dir.chdir("development_app") do
37
+ system("bundle exec rake db:seed")
38
+ end
39
+ end
10
40
 
11
41
  # Run all tests, include all
12
- RSpec::Core::RakeTask.new(:spec) do |t, task_args|
42
+ RSpec::Core::RakeTask.new(:spec) do |t|
13
43
  t.verbose = false
14
44
  end
15
45
 
@@ -18,9 +18,7 @@ module Decidim
18
18
  def index
19
19
  enforce_permission_to :index, :authorization
20
20
 
21
- @granted_authorizations = AuthorizationPresenter.for_collection(
22
- granted_authorizations
23
- )
21
+ @granted_authorizations = granted_authorizations
24
22
  end
25
23
 
26
24
  def new
@@ -90,7 +88,7 @@ module Decidim
90
88
  organization: current_organization,
91
89
  name: verification_manifest.name,
92
90
  granted: true
93
- )
91
+ ).query.page(params[:page]).per(15)
94
92
  end
95
93
 
96
94
  def authorization
@@ -12,9 +12,7 @@ module Decidim
12
12
  def index
13
13
  enforce_permission_to :index, :authorization
14
14
 
15
- @pending_authorizations = AuthorizationPresenter.for_collection(
16
- pending_authorizations
17
- )
15
+ @pending_authorizations = pending_authorizations
18
16
  end
19
17
 
20
18
  def update
@@ -60,7 +58,7 @@ module Decidim
60
58
  organization: current_organization,
61
59
  name: verification_manifest.name,
62
60
  granted: false
63
- )
61
+ ).query.page(params[:page]).per(15)
64
62
  end
65
63
 
66
64
  def authorization
@@ -40,5 +40,6 @@
40
40
  <% end %>
41
41
  </tbody>
42
42
  </table>
43
+ <%= paginate @granted_authorizations, theme: "decidim" %>
43
44
  </div>
44
45
  </div>
@@ -44,5 +44,6 @@
44
44
  <% end %>
45
45
  </tbody>
46
46
  </table>
47
+ <%= paginate @pending_authorizations, theme: "decidim" %>
47
48
  </div>
48
49
  </div>
@@ -58,7 +58,8 @@ fi:
58
58
  description: Odota pyynnön tarkastusta.
59
59
  step3:
60
60
  title: Vaihe 3
61
- description: Saat ilmoituksen, kun pyyntösi on käsitelty.
61
+ description: >
62
+ Saat ilmoituksen, kun pyyntösi on käsitelty.
62
63
  events:
63
64
  access_requests:
64
65
  confirmed:
@@ -59,8 +59,7 @@ sv:
59
59
  step3:
60
60
  title: Step 3
61
61
  description: >
62
- You will get notified once the request review has been
63
- completed.
62
+ You will get notified once the request review has been completed.
64
63
  events:
65
64
  access_requests:
66
65
  confirmed:
@@ -0,0 +1,6 @@
1
+ en:
2
+ decidim:
3
+ authorization_handlers:
4
+ access_requests:
5
+ explanation: An admin will approve or deny access
6
+ name: Access requests
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim::Verifications.register_workflow(:access_requests) do |workflow|
4
+ workflow.engine = Decidim::AccessRequests::Verification::Engine
5
+ workflow.admin_engine = Decidim::AccessRequests::Verification::AdminEngine
6
+ end
@@ -18,6 +18,13 @@ module Decidim
18
18
  app.config.assets.precompile += %w(decidim_access_requests_manifest.css
19
19
  decidim/access_requests/verification.scss)
20
20
  end
21
+
22
+ def load_seed
23
+ # Enable the `:access_requests` authorization
24
+ org = Decidim::Organization.first
25
+ org.available_authorizations << :access_requests
26
+ org.save!
27
+ end
21
28
  end
22
29
  end
23
30
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module AccessRequests
5
- VERSION = "0.16.0"
5
+ VERSION = "0.16.1"
6
6
  DECIDIM_VERSION = "~> 0.16.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-access_requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
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-02-06 00:00:00.000000000 Z
11
+ date: 2019-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-admin
@@ -100,6 +100,8 @@ files:
100
100
  - config/locales/fi.yml
101
101
  - config/locales/sv.yml
102
102
  - lib/decidim/access_requests.rb
103
+ - lib/decidim/access_requests/generators/app_templates/en.yml
104
+ - lib/decidim/access_requests/generators/app_templates/initializer.rb
103
105
  - lib/decidim/access_requests/verification.rb
104
106
  - lib/decidim/access_requests/verification/admin.rb
105
107
  - lib/decidim/access_requests/verification/admin_engine.rb
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
127
  version: '0'
126
128
  requirements: []
127
129
  rubyforge_project:
128
- rubygems_version: 2.7.7
130
+ rubygems_version: 2.7.6
129
131
  signing_key:
130
132
  specification_version: 4
131
133
  summary: Allows admins to add new access request authorizations.