godmin 1.5.0 → 2.0.0
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/.gitignore +1 -0
- data/.travis.yml +8 -5
- data/Appraisals +4 -4
- data/CHANGELOG.md +51 -2
- data/Gemfile +1 -1
- data/README.md +38 -5
- data/Rakefile +2 -2
- data/gemfiles/rails_5.gemfile +2 -2
- data/gemfiles/rails_6.gemfile +8 -0
- data/godmin.gemspec +18 -15
- data/lib/generators/godmin/resource/resource_generator.rb +7 -1
- data/lib/generators/godmin/resource/templates/resource_model.rb +4 -0
- data/lib/godmin/application_controller.rb +10 -11
- data/lib/godmin/authentication.rb +11 -11
- data/lib/godmin/authentication/sessions_controller.rb +1 -0
- data/lib/godmin/authorization.rb +6 -20
- data/lib/godmin/engine_wrapper.rb +10 -1
- data/lib/godmin/generators/base.rb +4 -4
- data/lib/godmin/generators/named_base.rb +4 -4
- data/lib/godmin/helpers/application.rb +3 -3
- data/lib/godmin/resolver.rb +20 -5
- data/lib/godmin/resources/resource_controller/batch_actions.rb +1 -1
- data/lib/godmin/resources/resource_service.rb +1 -5
- data/lib/godmin/version.rb +1 -1
- data/template.rb +3 -3
- data/test/dummy/admin/app/controllers/admin/authorized_articles_controller.rb +15 -0
- data/test/dummy/admin/app/models/admin/article.rb +4 -0
- data/test/dummy/admin/app/policies/admin/article_policy.rb +7 -0
- data/test/dummy/admin/config/routes.rb +1 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/controllers/another_admin_sessions_controller.rb +0 -2
- data/test/dummy/db/migrate/20150717121532_create_articles.rb +1 -1
- data/test/dummy/db/migrate/20150907133753_create_admin_users.rb +1 -1
- data/test/dummy/db/migrate/20160713134238_create_comment.rb +1 -1
- data/test/dummy/db/schema.rb +17 -16
- data/test/fakes/article.rb +1 -1
- data/test/fakes/article_service.rb +3 -7
- data/test/generators/resource_generator_test.rb +77 -0
- data/test/integration/authentication_test.rb +3 -8
- data/test/integration/authorization_test.rb +5 -0
- data/test/{lib/godmin → unit}/engine_wrapper_test.rb +0 -0
- data/test/{lib/godmin → unit}/helpers/filters_test.rb +0 -0
- data/test/{lib/godmin → unit}/paginator_test.rb +0 -0
- data/test/{lib/godmin → unit}/resolver_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/batch_actions_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/filters_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/ordering_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/pagination_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/scopes_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service_test.rb +0 -0
- metadata +139 -85
- data/gemfiles/rails_4.gemfile +0 -8
- data/lib/godmin/authorization/policy_finder.rb +0 -31
- data/lib/tasks/godmin_tasks.rake +0 -4
- data/test/lib/godmin/policy_finder_test.rb +0 -55
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 67092da8f88553787c49e63ffee072d0a6c3a726c8daec0f36b1f9e85db399b9
         | 
| 4 | 
            +
              data.tar.gz: 04ed7ef417dbf573a0d882395a92cb8af1cf969a562c82b1b9d03710c23ad75d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d65bdb37843317f059d2ff74fc240e64fbfa91f8670f2c1a47982abcd6bc2d6598f51dbe80b245ff6d195c7bd388eda6db901c4c99ef986d37036c11aa089df7
         | 
| 7 | 
            +
              data.tar.gz: 30b1c04eda1aa9990c2f6279db72de486f32787cea0ed2ce1d35e94b5b3c66a577e1b87b4beaba222c4066a5b12043ecf56547d28f1cf96b5341191e70dcbb90
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | @@ -4,17 +4,20 @@ script: "bundle exec rake test" | |
| 4 4 | 
             
            sudo: false
         | 
| 5 5 |  | 
| 6 6 | 
             
            rvm:
         | 
| 7 | 
            -
              - 2. | 
| 8 | 
            -
              - 2.3. | 
| 7 | 
            +
              - 2.2.2
         | 
| 8 | 
            +
              - 2.3.5
         | 
| 9 | 
            +
              - 2.5.1
         | 
| 9 10 |  | 
| 10 11 | 
             
            gemfile:
         | 
| 11 | 
            -
              - gemfiles/rails_4.gemfile
         | 
| 12 12 | 
             
              - gemfiles/rails_5.gemfile
         | 
| 13 | 
            +
              - gemfiles/rails_6.gemfile
         | 
| 13 14 |  | 
| 14 15 | 
             
            matrix:
         | 
| 15 16 | 
             
              exclude:
         | 
| 16 | 
            -
                - rvm: 2. | 
| 17 | 
            -
                  gemfile: gemfiles/ | 
| 17 | 
            +
                - rvm: 2.2.2
         | 
| 18 | 
            +
                  gemfile: gemfiles/rails_6.gemfile
         | 
| 19 | 
            +
                - rvm: 2.3.5
         | 
| 20 | 
            +
                  gemfile: gemfiles/rails_6.gemfile
         | 
| 18 21 |  | 
| 19 22 | 
             
            addons:
         | 
| 20 23 | 
             
              code_climate:
         | 
    
        data/Appraisals
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,10 +1,33 @@ | |
| 1 1 | 
             
            # Changelog
         | 
| 2 2 |  | 
| 3 | 
            +
            ### 2.0.0 - 2019-12-06
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Features
         | 
| 6 | 
            +
            - Allow skipping authorization per action (https://github.com/varvet/godmin/pull/231)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Bug fixes
         | 
| 9 | 
            +
            - Support namespaced models when generating resources (https://github.com/varvet/godmin/issues/181)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Other
         | 
| 12 | 
            +
            - Drop support for Rails 4 (https://github.com/varvet/godmin/pull/239)
         | 
| 13 | 
            +
            - Better policy lookups for namespaced models (https://github.com/varvet/godmin/pull/180)
         | 
| 14 | 
            +
            - Use Pundit for authorization (https://github.com/varvet/godmin/pull/180)
         | 
| 15 | 
            +
            - Rails 6 support (https://github.com/varvet/godmin/pull/248) and (https://github.com/varvet/godmin/pull/250)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            In order to upgrade
         | 
| 18 | 
            +
            - Upgrade to at least Rails 5 and Ruby 2.2.2
         | 
| 19 | 
            +
            - If using an admin engine, create a namespaced model for every resource, inheriting from the main app model
         | 
| 20 | 
            +
            - Replace any `authenticate_admin_user` with `authenticate`
         | 
| 21 | 
            +
            - Replace any `skip_before_action :authenticate_admin_user` with `prepend_before_action :disable_authentication`
         | 
| 22 | 
            +
            - Replace any `rescue_from NotAuthorizedError` with `rescue_from Pundit::NotAuthorizedError`
         | 
| 23 | 
            +
             | 
| 3 24 | 
             
            ### 1.5.0 - 2017-02-17
         | 
| 25 | 
            +
             | 
| 4 26 | 
             
            Features
         | 
| 5 27 | 
             
            - Support for nested resources (https://github.com/varvet/godmin/pull/189)
         | 
| 6 28 |  | 
| 7 29 | 
             
            ### 1.4.0 - 2017-02-15
         | 
| 30 | 
            +
             | 
| 8 31 | 
             
            Features
         | 
| 9 32 | 
             
            - Support group queries in scopes and filters (https://github.com/varvet/godmin/pull/208)
         | 
| 10 33 | 
             
            - Change color of remove buttons, so they're not grabbing all the attention (https://github.com/varvet/godmin/pull/212)
         | 
| @@ -17,6 +40,7 @@ Other | |
| 17 40 | 
             
            - Add table caption for tests (https://github.com/varvet/godmin/pull/187)
         | 
| 18 41 |  | 
| 19 42 | 
             
            ### 1.3.1 - 2016-09-27
         | 
| 43 | 
            +
             | 
| 20 44 | 
             
            Bug fixes
         | 
| 21 45 | 
             
            - Fix FileSystemResolver issue (https://github.com/varvet/godmin/pull/202)
         | 
| 22 46 |  | 
| @@ -24,6 +48,7 @@ Other | |
| 24 48 | 
             
            - Update template for Rails 5 (https://github.com/varvet/godmin/commit/95e0a7917dd9767d77c3bfc876ebbf0a6036f347)
         | 
| 25 49 |  | 
| 26 50 | 
             
            ### 1.3.0 - 2016-07-11
         | 
| 51 | 
            +
             | 
| 27 52 | 
             
            Features
         | 
| 28 53 | 
             
            - Increased batch action checkbox click area (https://github.com/varvet/godmin/pull/183)
         | 
| 29 54 | 
             
            - Adds titles to action links (https://github.com/varvet/godmin/pull/185)
         | 
| @@ -39,6 +64,7 @@ Other | |
| 39 64 | 
             
            - Adds caching partial overrides to increase table rendering speed (https://github.com/varvet/godmin/pull/184)
         | 
| 40 65 |  | 
| 41 66 | 
             
            ### 1.2.0 - 2016-02-02
         | 
| 67 | 
            +
             | 
| 42 68 | 
             
            Features
         | 
| 43 69 | 
             
            - Adds support for custom ordering of columns (https://github.com/varvet/godmin/pull/168)
         | 
| 44 70 | 
             
            - Adds passing of options to association form helper (https://github.com/varvet/godmin/pull/172)
         | 
| @@ -48,6 +74,7 @@ Bug fixes | |
| 48 74 | 
             
            - Fixes an issue with the template resolver and Rails 4.2.5.1 (https://github.com/varvet/godmin/pull/175)
         | 
| 49 75 |  | 
| 50 76 | 
             
            ### 1.1.0 - 2015-12-08
         | 
| 77 | 
            +
             | 
| 51 78 | 
             
            Features
         | 
| 52 79 | 
             
            - Adds locale for pt-BR (Brazilian Portuguese) (https://github.com/varvet/godmin/pull/141)
         | 
| 53 80 | 
             
            - New sandbox template with with more examples (https://github.com/varvet/godmin/pull/135)
         | 
| @@ -60,22 +87,27 @@ Bug fixes | |
| 60 87 | 
             
            - Fixes a namespace issue with the authentication generator (https://github.com/varvet/godmin/pull/150)
         | 
| 61 88 |  | 
| 62 89 | 
             
            ### 1.0.0 - 2015-11-13
         | 
| 90 | 
            +
             | 
| 63 91 | 
             
            Release of 1.0.0 :tada:
         | 
| 64 92 |  | 
| 65 93 | 
             
            ### 0.12.4 - 2015-10-21
         | 
| 94 | 
            +
             | 
| 66 95 | 
             
            Bug fixes
         | 
| 67 96 | 
             
            - Fixes a bug which made it impossible to override the datetimepicker locale (https://github.com/varvet/godmin/issues/132)
         | 
| 68 97 |  | 
| 69 98 | 
             
            ### 0.12.3 - 2015-09-18
         | 
| 99 | 
            +
             | 
| 70 100 | 
             
            Bug fixes
         | 
| 71 101 | 
             
            - Adds support for plural engines (https://github.com/varvet/godmin/pull/128)
         | 
| 72 102 | 
             
            - Remove turbolinks from application.js if present (https://github.com/varvet/godmin/issues/129)
         | 
| 73 103 |  | 
| 74 104 | 
             
            ### 0.12.2 - 2015-09-07
         | 
| 105 | 
            +
             | 
| 75 106 | 
             
            Bug fixes
         | 
| 76 107 | 
             
            - Fixes broken sign in page
         | 
| 77 108 |  | 
| 78 109 | 
             
            ### 0.12.1 - 2015-09-07
         | 
| 110 | 
            +
             | 
| 79 111 | 
             
            Bug fixes
         | 
| 80 112 | 
             
            - Fixes issue where column ordering on index table didn't work (https://github.com/varvet/godmin/issues/124)
         | 
| 81 113 |  | 
| @@ -83,17 +115,18 @@ Other | |
| 83 115 | 
             
            - Adds integration tests
         | 
| 84 116 | 
             
            - Removes the namespace config in `initializers/godmin.rb`
         | 
| 85 117 |  | 
| 86 | 
            -
            In order to upgrade | 
| 118 | 
            +
            In order to upgrade
         | 
| 87 119 | 
             
            - Remove the `initializers/godmin.rb` file
         | 
| 88 120 |  | 
| 89 121 | 
             
            ### 0.12.0 - 2015-06-30
         | 
| 122 | 
            +
             | 
| 90 123 | 
             
            Features
         | 
| 91 124 | 
             
            - Adds new navigation helpers for building a custom navbar (https://github.com/varvet/godmin/issues/54)
         | 
| 92 125 |  | 
| 93 126 | 
             
            Other
         | 
| 94 127 | 
             
            - Removes the godmin router method
         | 
| 95 128 |  | 
| 96 | 
            -
            In order to upgrade | 
| 129 | 
            +
            In order to upgrade
         | 
| 97 130 | 
             
            - Remove the `godmin do` block from the `config/routes.rb` file
         | 
| 98 131 | 
             
            - Specify a root route if there is none already
         | 
| 99 132 | 
             
            - Create a `shared/_navigation.html.erb` partial if there is none already
         | 
| @@ -102,10 +135,12 @@ Bug fixes | |
| 102 135 | 
             
            - Fixes issue with authentication generator not modifying the application controller
         | 
| 103 136 |  | 
| 104 137 | 
             
            ### 0.11.2 - 2015-06-22
         | 
| 138 | 
            +
             | 
| 105 139 | 
             
            Bug fixes
         | 
| 106 140 | 
             
            - Fixes broken collection select helper
         | 
| 107 141 |  | 
| 108 142 | 
             
            ### 0.11.1 - 2015-05-20
         | 
| 143 | 
            +
             | 
| 109 144 | 
             
            Features
         | 
| 110 145 | 
             
            - Adds `destroy_resource` method to `ResourceService`
         | 
| 111 146 | 
             
            - Adds query param to authorize
         | 
| @@ -119,6 +154,7 @@ Bug fixes | |
| 119 154 | 
             
            - Fixes a regression where filter labels were not translated
         | 
| 120 155 |  | 
| 121 156 | 
             
            ### 0.11.0 - 2015-04-13
         | 
| 157 | 
            +
             | 
| 122 158 | 
             
            Other
         | 
| 123 159 | 
             
            - Split resources into controllers and service objects (https://github.com/varvet/godmin/pull/79)
         | 
| 124 160 | 
             
            - Renames the following modules:
         | 
| @@ -127,18 +163,22 @@ Other | |
| 127 163 | 
             
              - Godmin::Sessions -> Godmin::SessionsController
         | 
| 128 164 |  | 
| 129 165 | 
             
            ### 0.10.3 - 2015-02-18
         | 
| 166 | 
            +
             | 
| 130 167 | 
             
            Bug fixes
         | 
| 131 168 | 
             
            - Adds the possibility to pass options to the `date_field` and `datetime_field` form helpers
         | 
| 132 169 |  | 
| 133 170 | 
             
            ### 0.10.2 - 2015-02-16
         | 
| 171 | 
            +
             | 
| 134 172 | 
             
            Bug fixes
         | 
| 135 173 | 
             
            - Fixes standard resource params for multi-word models
         | 
| 136 174 |  | 
| 137 175 | 
             
            ### 0.10.1 - 2015-02-13
         | 
| 176 | 
            +
             | 
| 138 177 | 
             
            Bug fixes
         | 
| 139 178 | 
             
            - Fixes multi-select selectize issue (https://github.com/varvet/godmin/issues/71)
         | 
| 140 179 |  | 
| 141 180 | 
             
            ### 0.10.0 - 2015-02-11
         | 
| 181 | 
            +
             | 
| 142 182 | 
             
            Features
         | 
| 143 183 | 
             
            - Shows the number of items in each scope in the scope tab (https://github.com/varvet/godmin/issues/16)
         | 
| 144 184 | 
             
            - Two new overridable methods for resources: `build_resource` and `find_resource`
         | 
| @@ -155,21 +195,25 @@ Other | |
| 155 195 | 
             
            - Restructured the locale files a bit
         | 
| 156 196 |  | 
| 157 197 | 
             
            ### 0.9.9 - 2015-01-23
         | 
| 198 | 
            +
             | 
| 158 199 | 
             
            Features
         | 
| 159 200 | 
             
            - Bump bootstrap to 3.3.3
         | 
| 160 201 | 
             
            - Extracted button actions partial
         | 
| 161 202 |  | 
| 162 203 | 
             
            ### 0.9.8 - 2015-01-12
         | 
| 204 | 
            +
             | 
| 163 205 | 
             
            Bug fixes
         | 
| 164 206 | 
             
            - Created resources are now properly scoped by `resources_relation`
         | 
| 165 207 | 
             
            - Fixes broken signin form
         | 
| 166 208 |  | 
| 167 209 | 
             
            ### 0.9.7 - 2015-01-07
         | 
| 210 | 
            +
             | 
| 168 211 | 
             
            Features
         | 
| 169 212 | 
             
            - Support for Rails 4.2
         | 
| 170 213 | 
             
            - New form system (https://github.com/varvet/godmin/pull/50)
         | 
| 171 214 |  | 
| 172 215 | 
             
            ### 0.9.6 - 2014-12-18
         | 
| 216 | 
            +
             | 
| 173 217 | 
             
            Features
         | 
| 174 218 | 
             
            - Bundled [datetimepicker](https://github.com/Eonasdan/bootstrap-datetimepicker/)
         | 
| 175 219 | 
             
            - Exposed JavaScript API
         | 
| @@ -179,18 +223,22 @@ Notes | |
| 179 223 | 
             
            - You can no longer use the `select-tag` class to initialize a select box
         | 
| 180 224 |  | 
| 181 225 | 
             
            ### 0.9.5 - 2014-12-15
         | 
| 226 | 
            +
             | 
| 182 227 | 
             
            Bug fixes
         | 
| 183 228 | 
             
            - Fixes Godmin::FormBuilder issue
         | 
| 184 229 |  | 
| 185 230 | 
             
            ### 0.9.4 - 2014-12-15
         | 
| 231 | 
            +
             | 
| 186 232 | 
             
            Features
         | 
| 187 233 | 
             
            - Added Godmin::FormBuilder
         | 
| 188 234 |  | 
| 189 235 | 
             
            ### 0.9.3 - 2014-12-10
         | 
| 236 | 
            +
             | 
| 190 237 | 
             
            Bug fixes
         | 
| 191 238 | 
             
            - Pagination offset fix
         | 
| 192 239 |  | 
| 193 240 | 
             
            ### 0.9.2 - 2014-12-09
         | 
| 241 | 
            +
             | 
| 194 242 | 
             
            Features
         | 
| 195 243 | 
             
            - Replaces select2 with [selectize](http://brianreavis.github.io/selectize.js/)
         | 
| 196 244 | 
             
            - Adds flash messages (https://github.com/varvet/godmin/issues/26)
         | 
| @@ -203,6 +251,7 @@ Bug fixes | |
| 203 251 | 
             
            - Fixes default permitted params to work with multiword models.
         | 
| 204 252 |  | 
| 205 253 | 
             
            ### 0.9.1 - 2014-11-18
         | 
| 254 | 
            +
             | 
| 206 255 | 
             
            Bug fixes
         | 
| 207 256 | 
             
            - Removed rails executable from /bin folder.
         | 
| 208 257 |  | 
    
        data/Gemfile
    CHANGED
    
    | @@ -12,4 +12,4 @@ gemspec | |
| 12 12 |  | 
| 13 13 | 
             
            # The dummy app loads whatever is specified in this gemfile, therefore
         | 
| 14 14 | 
             
            # we add the admin engine used by the dummy app here
         | 
| 15 | 
            -
            gem "admin", path: "test/dummy/admin", group: [ | 
| 15 | 
            +
            gem "admin", path: "test/dummy/admin", group: %i[test development]
         | 
    
        data/README.md
    CHANGED
    
    | @@ -4,7 +4,9 @@ | |
| 4 4 | 
             
            [](https://travis-ci.org/varvet/godmin)
         | 
| 5 5 | 
             
            [](https://codeclimate.com/github/varvet/godmin)
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 7 | 
            +
            **If you are looking for the current stable version, which is Rails 4+ compatible, see the [v1.5](https://github.com/varvet/godmin/tree/v1.5) branch**
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Godmin is an admin framework for Rails 5+. Use it to build dedicated admin sections for your apps, or stand alone admin apps such as internal tools. It has support for common features such as scoping, filtering and performing batch actions on your models. Check out the [demo app](http://godmin-sandbox.herokuapp.com) and its [source code](https://github.com/varvet/godmin-sandbox) to get a feel for how it works.
         | 
| 8 10 |  | 
| 9 11 | 
             
            Godmin differs from tools like [ActiveAdmin](http://activeadmin.info/) and [RailsAdmin](https://github.com/sferik/rails_admin) in how admin sections are created. Rather than being DSL-based, Godmin is a set of opt-in modules and helpers that can be applied to regular Rails apps and engines. An admin section built with Godmin is just that, a regular Rails app or Rails engine, with regular routes, controllers and views. That means there is less to learn, because you already know most of it, and fewer constraints on what you can do. After all, administrators are users too, and what better way to provide them with a tailor made experience than building them a Rails app?
         | 
| 10 12 |  | 
| @@ -143,6 +145,15 @@ It inserts a `navbar_item` in the `app/views/shared/_navigation.html.erb` partia | |
| 143 145 | 
             
            <%= navbar_item Article %>
         | 
| 144 146 | 
             
            ```
         | 
| 145 147 |  | 
| 148 | 
            +
            If Godmin was installed inside an engine, it creates a model class:
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            ```ruby
         | 
| 151 | 
            +
            module Admin
         | 
| 152 | 
            +
              class Article < ::Article
         | 
| 153 | 
            +
              end
         | 
| 154 | 
            +
            end
         | 
| 155 | 
            +
            ```
         | 
| 156 | 
            +
             | 
| 146 157 | 
             
            It creates a controller:
         | 
| 147 158 |  | 
| 148 159 | 
             
            ```ruby
         | 
| @@ -740,9 +751,19 @@ end | |
| 740 751 |  | 
| 741 752 | 
             
            The admin section is now authenticated using Devise.
         | 
| 742 753 |  | 
| 754 | 
            +
            ### Disable authentication
         | 
| 755 | 
            +
             | 
| 756 | 
            +
            If you want to disable authentication for a single controller or controller action, use the following `before_action`:
         | 
| 757 | 
            +
             | 
| 758 | 
            +
            ```ruby
         | 
| 759 | 
            +
            class ArticlesController < ApplicationController
         | 
| 760 | 
            +
              prepend_before_action :disable_authentication
         | 
| 761 | 
            +
            end
         | 
| 762 | 
            +
            ```
         | 
| 763 | 
            +
             | 
| 743 764 | 
             
            ## Authorization
         | 
| 744 765 |  | 
| 745 | 
            -
            In order to enable authorization, authentication must first be enabled. See the previous section. The Godmin authorization system  | 
| 766 | 
            +
            In order to enable authorization, authentication must first be enabled. See the previous section. The Godmin authorization system uses [Pundit](https://github.com/elabs/pundit).
         | 
| 746 767 |  | 
| 747 768 | 
             
            Add the authorization module to the application controller:
         | 
| 748 769 |  | 
| @@ -802,8 +823,8 @@ end | |
| 802 823 | 
             
            That is, everyone can list and view articles, only editors can create them, and only unpublished articles can be updated and destroyed.
         | 
| 803 824 |  | 
| 804 825 | 
             
            ### Handle unauthorized access
         | 
| 805 | 
            -
             | 
| 806 | 
            -
            If you want to change this behaviour you can rescue the error yourself in the appropriate `ApplicationController`:
         | 
| 826 | 
            +
             | 
| 827 | 
            +
            When a user is not authorized to access a resource, a `Pundit::NotAuthorizedError` is raised. By default this error is rescued by Godmin and turned into a status code `403 Forbidden` response. If you want to change this behaviour you can rescue the error yourself in the appropriate `ApplicationController`:
         | 
| 807 828 |  | 
| 808 829 | 
             
            ```ruby
         | 
| 809 830 | 
             
            class ApplicationController < ActionController::Base
         | 
| @@ -812,13 +833,14 @@ class ApplicationController < ActionController::Base | |
| 812 833 | 
             
              include Godmin::Authorization
         | 
| 813 834 |  | 
| 814 835 | 
             
              # Renders 404 page and returns status code 404.
         | 
| 815 | 
            -
              rescue_from NotAuthorizedError do
         | 
| 836 | 
            +
              rescue_from Pundit::NotAuthorizedError do
         | 
| 816 837 | 
             
                render file: "#{Rails.root}/public/404.html", status: 404, layout: false
         | 
| 817 838 | 
             
              end
         | 
| 818 839 | 
             
            end
         | 
| 819 840 | 
             
            ```
         | 
| 820 841 |  | 
| 821 842 | 
             
            ### Override policy object
         | 
| 843 | 
            +
             | 
| 822 844 | 
             
            If you wish to specify what policy to use manually, override the following method in your model. It does not have to be an ActiveRecord object, but any object will do.
         | 
| 823 845 |  | 
| 824 846 | 
             
            ```ruby
         | 
| @@ -830,6 +852,7 @@ end | |
| 830 852 | 
             
            ```
         | 
| 831 853 |  | 
| 832 854 | 
             
            ### Batch action authorization
         | 
| 855 | 
            +
             | 
| 833 856 | 
             
            Batch actions must be authorized in your policy if you are using Godmin's built in authorization functionality. The policy method is called with the relation containing all records to be processed.
         | 
| 834 857 |  | 
| 835 858 | 
             
            ```ruby
         | 
| @@ -840,6 +863,16 @@ class ArticlePolicy < Godmin::Authorization::Policy | |
| 840 863 | 
             
            end
         | 
| 841 864 | 
             
            ```
         | 
| 842 865 |  | 
| 866 | 
            +
            ### Disable authorization
         | 
| 867 | 
            +
             | 
| 868 | 
            +
            If you want to disable authorization for a single controller or controller action, use the following `before_action`:
         | 
| 869 | 
            +
             | 
| 870 | 
            +
            ```ruby
         | 
| 871 | 
            +
            class ArticlesController < ApplicationController
         | 
| 872 | 
            +
              prepend_before_action :disable_authorization
         | 
| 873 | 
            +
            end
         | 
| 874 | 
            +
            ```
         | 
| 875 | 
            +
             | 
| 843 876 | 
             
            ## Localization
         | 
| 844 877 |  | 
| 845 878 | 
             
            Godmin supports localization out of the box. For a list of translatable strings, [look here](https://github.com/varvet/godmin/blob/master/config/locales/en.yml).
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -39,11 +39,11 @@ namespace :sandbox do | |
| 39 39 | 
             
                Bundler.with_clean_env do
         | 
| 40 40 | 
             
                  Dir.mktmpdir do |dir|
         | 
| 41 41 | 
             
                    Dir.chdir(dir)
         | 
| 42 | 
            -
                    system("git clone  | 
| 42 | 
            +
                    system("git clone https://github.com/varvet/godmin-sandbox.git")
         | 
| 43 43 | 
             
                    if $CHILD_STATUS.success?
         | 
| 44 44 | 
             
                      Dir.chdir("godmin-sandbox")
         | 
| 45 45 | 
             
                      system("rm -rf *")
         | 
| 46 | 
            -
                      system("rails new . -d postgresql -m #{template_path} --without-engine")
         | 
| 46 | 
            +
                      system("rails new . -d postgresql -m #{template_path} --without-engine --skip-spring")
         | 
| 47 47 | 
             
                      if $CHILD_STATUS.success?
         | 
| 48 48 | 
             
                        system("git add --all")
         | 
| 49 49 | 
             
                        system("git commit -m '#{message}'")
         | 
    
        data/gemfiles/rails_5.gemfile
    CHANGED
    
    
    
        data/godmin.gemspec
    CHANGED
    
    | @@ -10,8 +10,8 @@ Gem::Specification.new do |gem| | |
| 10 10 | 
             
              gem.authors     = ["Jens Ljungblad", "Linus Pettersson", "Varvet"]
         | 
| 11 11 | 
             
              gem.email       = ["info@varvet.se"]
         | 
| 12 12 | 
             
              gem.homepage    = "https://github.com/varvet/godmin"
         | 
| 13 | 
            -
              gem.summary     = "Godmin is an admin framework for Rails  | 
| 14 | 
            -
              gem.description = "Godmin is an admin framework for Rails  | 
| 13 | 
            +
              gem.summary     = "Godmin is an admin framework for Rails 5+"
         | 
| 14 | 
            +
              gem.description = "Godmin is an admin framework for Rails 5+. Use it to build dedicated admin sections for your apps, or stand alone admin apps such as internal tools."
         | 
| 15 15 | 
             
              gem.license     = "MIT"
         | 
| 16 16 |  | 
| 17 17 | 
             
              gem.files         = `git ls-files`.split($/)
         | 
| @@ -19,22 +19,25 @@ Gem::Specification.new do |gem| | |
| 19 19 | 
             
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 20 20 | 
             
              gem.require_paths = ["lib"]
         | 
| 21 21 |  | 
| 22 | 
            -
              gem.add_dependency "bcrypt", " | 
| 23 | 
            -
              gem.add_dependency "bootstrap_form", "~> 2.4"
         | 
| 22 | 
            +
              gem.add_dependency "bcrypt", [">= 3.0", "< 4.0"]
         | 
| 24 23 | 
             
              gem.add_dependency "bootstrap-sass", "~> 3.3"
         | 
| 25 | 
            -
              gem.add_dependency " | 
| 24 | 
            +
              gem.add_dependency "bootstrap_form", "~> 2.4"
         | 
| 26 25 | 
             
              gem.add_dependency "csv_builder", "~> 2.1"
         | 
| 27 | 
            -
              gem.add_dependency "jquery-rails", [">=  | 
| 26 | 
            +
              gem.add_dependency "jquery-rails", [">= 4.0", "< 5.0"]
         | 
| 28 27 | 
             
              gem.add_dependency "momentjs-rails", "~> 2.8"
         | 
| 29 | 
            -
              gem.add_dependency " | 
| 30 | 
            -
              gem.add_dependency " | 
| 28 | 
            +
              gem.add_dependency "pundit", [">= 1.1", "< 2.0"]
         | 
| 29 | 
            +
              gem.add_dependency "rails", [">= 5.0", "< 7.0"]
         | 
| 30 | 
            +
              gem.add_dependency "sass-rails", [">= 5.0", "< 7.0"]
         | 
| 31 31 | 
             
              gem.add_dependency "selectize-rails", "~> 0.12"
         | 
| 32 32 |  | 
| 33 | 
            -
              gem.add_development_dependency "appraisal" | 
| 34 | 
            -
              gem.add_development_dependency " | 
| 35 | 
            -
              gem.add_development_dependency " | 
| 36 | 
            -
              gem.add_development_dependency " | 
| 37 | 
            -
              gem.add_development_dependency " | 
| 38 | 
            -
              gem.add_development_dependency " | 
| 39 | 
            -
              gem.add_development_dependency " | 
| 33 | 
            +
              gem.add_development_dependency "appraisal"
         | 
| 34 | 
            +
              gem.add_development_dependency "bootsnap"
         | 
| 35 | 
            +
              gem.add_development_dependency "byebug"
         | 
| 36 | 
            +
              gem.add_development_dependency "capybara"
         | 
| 37 | 
            +
              gem.add_development_dependency "minitest"
         | 
| 38 | 
            +
              gem.add_development_dependency "minitest-reporters"
         | 
| 39 | 
            +
              gem.add_development_dependency "poltergeist"
         | 
| 40 | 
            +
              gem.add_development_dependency "pry"
         | 
| 41 | 
            +
              gem.add_development_dependency "puma"
         | 
| 42 | 
            +
              gem.add_development_dependency "sqlite3"
         | 
| 40 43 | 
             
            end
         |