symphonia 4.1.3 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +27 -1
- data/app/assets/javascripts/symphonia/application.js +3 -3
- data/app/assets/javascripts/symphonia/symphonia_bootstrap_dialog.js +23 -23
- data/app/assets/stylesheets/symphonia/_font_awesome.scss +8 -6
- data/app/assets/stylesheets/symphonia/_layout.scss +33 -1
- data/app/assets/stylesheets/symphonia/basic.scss +3 -99
- data/app/assets/stylesheets/symphonia/filters.scss +3 -5
- data/app/assets/stylesheets/symphonia/symphonia_bootstrap.scss +1 -1
- data/app/controllers/symphonia/accounts_controller.rb +7 -3
- data/app/controllers/symphonia/application_controller.rb +2 -1
- data/app/controllers/symphonia/users_controller.rb +17 -29
- data/app/helpers/symphonia/application_helper.rb +48 -26
- data/app/models/symphonia/preference.rb +5 -5
- data/app/models/symphonia/user.rb +3 -35
- data/app/models/symphonia/user_ability.rb +46 -0
- data/app/views/common/403.html.erb +4 -3
- data/app/views/layouts/symphonia/application.html.erb +4 -4
- data/app/views/symphonia/accounts/_detail.html.erb +21 -18
- data/app/views/symphonia/common/_filters.html.erb +15 -15
- data/app/views/symphonia/common/_share_links.html.erb +2 -3
- data/app/views/symphonia/users/_form.html.erb +1 -6
- data/app/views/symphonia/users/show.html.erb +15 -20
- data/config/locales/cs.yml +3 -2
- data/db/migrate/20130714140500_create_users.rb +0 -2
- data/db/seeds.rb +3 -3
- data/lib/generators/symphonia/entity_controller/entity_controller_generator.rb +2 -2
- data/lib/generators/symphonia/entity_controller/templates/{controller.rb → controller.rb.tt} +0 -0
- data/lib/symphonia/admin_constraint.rb +1 -1
- data/lib/symphonia/base_controller.rb +9 -17
- data/lib/symphonia/controller_extensions.rb +5 -15
- data/lib/symphonia/engine.rb +12 -43
- data/lib/symphonia/form_builder.rb +17 -16
- data/lib/symphonia/menu_manager.rb +15 -11
- data/lib/symphonia/model_attributes/attribute.rb +3 -3
- data/lib/symphonia/object.rb +9 -9
- data/lib/symphonia/spec_helper.rb +8 -4
- data/lib/symphonia/user_management.rb +1 -1
- data/lib/symphonia/version.rb +1 -1
- data/lib/symphonia.rb +12 -9
- data/spec/factories/factories.rb +0 -4
- data/spec/models/user_spec.rb +39 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/support/stub_users.rb +7 -7
- metadata +41 -140
- data/app/controllers/symphonia/roles_controller.rb +0 -39
- data/app/models/symphonia/role.rb +0 -55
- data/app/views/symphonia/roles/_form.html.erb +0 -26
- data/app/views/symphonia/roles/edit.html.erb +0 -5
- data/app/views/symphonia/roles/index.html.erb +0 -6
- data/app/views/symphonia/roles/new.html.erb +0 -4
- data/app/views/symphonia/roles/show.html.erb +0 -11
- data/db/migrate/20130714140501_create_roles.rb +0 -18
- data/db/migrate/20210509141420_roles_change_permissions_to_json.rb +0 -18
- data/db/migrate/20210509180525_roles_change_permissions_to_native_json.rb +0 -7
- data/lib/symphonia/permissions.rb +0 -93
- data/spec/controllers/roles_controller_spec.rb +0 -12
- data/spec/models/role_spec.rb +0 -13
- data/spec/requests/roles_spec.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71cb8a41bead7977d784fbb826c54a059b74f9cc75f43de46e67bbb8fd547cea
|
4
|
+
data.tar.gz: aa49eb8c8b095422abd9bb3c65105c3bfc79bf3cb82d2e8ea6655751cc9f15a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a480e8c8c1e1a31c887c313fc6bd682774cc397277ff7edf10da58583d59badca233903adb447d131d98b704573d2dbdd8fd90e61465ae146eb126a4e85c36
|
7
|
+
data.tar.gz: bc42c7d29dcb974fee96e7749315449c77f44843a2b8cde034a5964dc4aec0c9fdfa25a5224605165b75453e24a23b6ca53d35ef59b2e3c620e1b00f6fe11216
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
## [4.2.0] - 2022-04-07
|
9
|
+
### Removed
|
10
|
+
- awesome_nested_set dependency
|
11
|
+
### Changed
|
12
|
+
- start with Ruby3 support
|
13
|
+
|
8
14
|
## [4.1.3] - 2022-03-02
|
9
15
|
### Changed
|
10
16
|
- update sidekiq
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Symphonia
|
2
|
-
|
2
|
+
|
3
|
+
simple core toolkit for my rails apps
|
3
4
|
|
4
5
|
## Installation
|
5
6
|
|
@@ -13,6 +14,7 @@ after `bundle install` run post-installation: `rails g symphonia:setup`
|
|
13
14
|
|
14
15
|
> Setup prepare `config/initializers/settings.rb`, create `spec/spec_helper.rb`, add stylesheets and javascripts references and copy basic layout.
|
15
16
|
|
17
|
+
## Configuration
|
16
18
|
|
17
19
|
## Upgrade to v4.0
|
18
20
|
1. update Gemfile:
|
@@ -30,3 +32,27 @@ And `bundle update`
|
|
30
32
|
export THOR_MERGE=vimdiff
|
31
33
|
rails app:update
|
32
34
|
```
|
35
|
+
## Upgrade to v5.0
|
36
|
+
Version 5 remove sprockets bootstrap, font-awesome and others CSS/JS things. It expect that assets will be managed by webpacker (or similar) FE technology.
|
37
|
+
|
38
|
+
Also remove `Role` model and whole permissions custom logic. Its replace standardized CanCanCan gem (https://github.com/CanCanCommunity/cancancan/tree/develop/docs)
|
39
|
+
|
40
|
+
### Sprockets fallback
|
41
|
+
For fallback add to Gemfile
|
42
|
+
```ruby
|
43
|
+
gem "bootstrap", "~> 4.6"
|
44
|
+
gem "jquery-rails"
|
45
|
+
gem "jquery-ui-rails"
|
46
|
+
gem "listen"
|
47
|
+
gem "sass-rails"
|
48
|
+
gem "turbolinks"
|
49
|
+
gem 'font-awesome-sass', '~> 6.2.0'
|
50
|
+
```
|
51
|
+
in your "app/assets/stylessheets/general.scss" make sure symphonia is imported
|
52
|
+
```scss
|
53
|
+
@import 'symphonia/basic';
|
54
|
+
@import 'symphonia/layout';
|
55
|
+
```
|
56
|
+
|
57
|
+
### CanCanCan
|
58
|
+
For user there is `Symphonia::UserAbility` which defined permissions for User model + for admin add basic CRUD operation for `:all`.
|
@@ -7,8 +7,8 @@
|
|
7
7
|
//= require symphonia/_core
|
8
8
|
//= require symphonia/Sortable
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
// require bootstrap-datepicker/core
|
11
|
+
// require bootstrap-datepicker/locales/bootstrap-datepicker.cs.js
|
12
12
|
|
13
13
|
//= require_self
|
14
14
|
//= require symphonia/symphonia_bootstrap_dialog
|
@@ -155,4 +155,4 @@ SymphoniaCheckboxes = {
|
|
155
155
|
|
156
156
|
return input;
|
157
157
|
}
|
158
|
-
};
|
158
|
+
};
|
@@ -1,42 +1,42 @@
|
|
1
1
|
/**
|
2
2
|
* Symphonia modal dialog pop-up.
|
3
3
|
* @param {String} id
|
4
|
-
* @param {Object}
|
5
|
-
* @param {String}
|
6
|
-
* @param {Boolean}
|
7
|
-
* @param {String}
|
8
|
-
* @param {String}
|
9
|
-
* @param {String}
|
10
|
-
* @param {Boolean}
|
4
|
+
* @param {Object} opts
|
5
|
+
* @param {String} opts.title - Title of dialog window.
|
6
|
+
* @param {Boolean} opts.force - If dialog element exists, will remove and replace new one.
|
7
|
+
* @param {String} opts.text - Text for body of dialog window.
|
8
|
+
* @param {String} opts.html - Content (html) for body of dialog window.
|
9
|
+
* @param {String} opts.submit - Text of submit button. If provided generate submit button.
|
10
|
+
* @param {Boolean} opts.large - Use Large modal
|
11
11
|
*/
|
12
|
-
SymphoniaDialog = function (id,
|
13
|
-
|
12
|
+
SymphoniaDialog = function (id, opts) {
|
13
|
+
const options = $.extend(opts, {});
|
14
14
|
if (options["force"] === undefined)
|
15
15
|
options["force"] = true;
|
16
16
|
|
17
17
|
this.id = id || 'ajax_modal';
|
18
|
-
|
18
|
+
const m = document.getElementById(this.id);
|
19
19
|
|
20
20
|
// var currentDialog = document.getElementById(this.id + "__symphonia_dialog");
|
21
21
|
// if (currentDialog) {
|
22
22
|
// currentDialog.remove();
|
23
23
|
// }
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
const dialog = document.createElement("div");
|
26
|
+
const modalDialog = document.createElement("div");
|
27
27
|
modalDialog.className = "modal-dialog";
|
28
28
|
if (options["large"]) {
|
29
29
|
modalDialog.classList.add("modal-lg")
|
30
30
|
}
|
31
31
|
dialog.setAttribute("role", "document");
|
32
32
|
|
33
|
-
|
33
|
+
const content = document.createElement("div");
|
34
34
|
content.className = "modal-content";
|
35
|
-
|
35
|
+
const heading = document.createElement("div");
|
36
36
|
heading.className = "modal-header";
|
37
|
-
|
37
|
+
const modalTitle = document.createElement("h5");
|
38
38
|
modalTitle.className = "modal-title";
|
39
|
-
|
39
|
+
const body = document.createElement("div");
|
40
40
|
|
41
41
|
body.className = "modal-body";
|
42
42
|
dialog.id = this.id;
|
@@ -46,7 +46,7 @@ SymphoniaDialog = function (id, options) {
|
|
46
46
|
// =-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-
|
47
47
|
|
48
48
|
this.appendSubmitButton = function (label) {
|
49
|
-
|
49
|
+
const submitButton = document.createElement('button');
|
50
50
|
submitButton.onclick = this.submit;
|
51
51
|
submitButton.innerText = (label === true) && 'Submit' || label;
|
52
52
|
submitButton.className = "btn btn-primary";
|
@@ -54,14 +54,14 @@ SymphoniaDialog = function (id, options) {
|
|
54
54
|
return submitButton;
|
55
55
|
};
|
56
56
|
this.submit = function () {
|
57
|
-
|
57
|
+
const form = dialog.querySelector("form");
|
58
58
|
if (form)
|
59
59
|
form.submit();
|
60
60
|
};
|
61
61
|
this.show = function () {
|
62
62
|
// dialog.find(".modal-body > .modal-content-inner-container").css({'max-height': window.innerHeight - 200});
|
63
63
|
// dialog.find(".modal-body > .modal-content-inner-container").css({'max-height': window.innerHeight - 200});
|
64
|
-
|
64
|
+
const t = dialog.querySelector(".title");
|
65
65
|
if (t && t.innerHTML === '') {
|
66
66
|
this.title = modalTitle.innerHTML;
|
67
67
|
t.remove();
|
@@ -83,7 +83,7 @@ SymphoniaDialog = function (id, options) {
|
|
83
83
|
|
84
84
|
modalTitle.innerText = options.title || '';
|
85
85
|
|
86
|
-
|
86
|
+
const closeButton = document.createElement("button");
|
87
87
|
closeButton.className = "close fa fa-times";
|
88
88
|
closeButton.dataset['dismiss'] = "modal";
|
89
89
|
heading.appendChild(modalTitle);
|
@@ -114,7 +114,7 @@ SymphoniaDialog = function (id, options) {
|
|
114
114
|
dialog.appendChild(modalDialog);
|
115
115
|
|
116
116
|
if (options.force) {
|
117
|
-
|
117
|
+
const currentDialog = document.getElementById(dialog.id);
|
118
118
|
if (currentDialog)
|
119
119
|
currentDialog.remove();
|
120
120
|
}
|
@@ -130,7 +130,7 @@ SymphoniaDialog.prototype.close = function () {
|
|
130
130
|
};
|
131
131
|
window.Symphonia.dialog = {
|
132
132
|
show: function(IDcontainer, options) {
|
133
|
-
|
133
|
+
const modal = new SymphoniaDialog(IDcontainer, options);
|
134
134
|
modal.show();
|
135
135
|
}
|
136
|
-
}
|
136
|
+
}
|
@@ -1,25 +1,27 @@
|
|
1
|
-
@import
|
1
|
+
@import "font-awesome";
|
2
2
|
/* Font awesome aliases */
|
3
3
|
.fa-add {
|
4
|
-
|
4
|
+
//@include fa-icon-solid($fa-var-circle-plus);
|
5
|
+
@extend .fa-circle-plus !optional;
|
5
6
|
}
|
6
7
|
.fa-delete, .fa-del {
|
7
|
-
@
|
8
|
+
@include fa-icon-solid($fa-var-trash-can);
|
8
9
|
}
|
9
10
|
.fa-back {
|
10
|
-
@
|
11
|
+
@include fa-icon-solid($fa-var-chevron-left);
|
11
12
|
}
|
12
13
|
.fa-true {
|
13
14
|
@extend .fa-check !optional;
|
15
|
+
@include fa-icon-solid($fa-var-check);
|
14
16
|
}
|
15
17
|
.fa-false {
|
16
|
-
@
|
18
|
+
@include fa-icon-solid($fa-var-times);
|
17
19
|
}
|
18
20
|
.fa-notice {
|
19
21
|
@extend .fa-check-circle !optional;
|
20
22
|
}
|
21
23
|
.fa-error {
|
22
|
-
@extend .
|
24
|
+
@extend .circle-exclamation !optional;
|
23
25
|
}
|
24
26
|
.alert .fa-info {
|
25
27
|
@extend .fa-info-circle !optional;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
@import "bootstrap";
|
1
|
+
@import "/bootstrap";
|
2
2
|
|
3
3
|
// fixed navbar
|
4
4
|
body > .container {
|
@@ -38,3 +38,35 @@ footer.footer {
|
|
38
38
|
@extend .d-print-none;
|
39
39
|
}
|
40
40
|
}
|
41
|
+
|
42
|
+
/* TABLE */
|
43
|
+
@mixin inactive-row {
|
44
|
+
opacity: 0.5
|
45
|
+
}
|
46
|
+
td.price {
|
47
|
+
text-align: right;
|
48
|
+
}
|
49
|
+
table.table {
|
50
|
+
th a.asc {
|
51
|
+
&:after {
|
52
|
+
content: "\2191";
|
53
|
+
}
|
54
|
+
}
|
55
|
+
th a.desc {
|
56
|
+
&:after {
|
57
|
+
content: "\2193";
|
58
|
+
}
|
59
|
+
}
|
60
|
+
tr.status {
|
61
|
+
&--lock, &--inactive, &--archived {
|
62
|
+
@include inactive-row;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
.buttons {
|
66
|
+
text-align: right;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
/* FORM */
|
71
|
+
.required label, label[required], label.required, .has-error {color: red !important;}
|
72
|
+
.required label:after, label[required]:after, label.required:after { content: '* '}
|
@@ -1,85 +1,13 @@
|
|
1
|
-
@import "_font_awesome";
|
1
|
+
@import "./_font_awesome";
|
2
2
|
|
3
3
|
.page-header.title, .page-header.title h1 {
|
4
4
|
margin-top: 0;
|
5
5
|
}
|
6
|
-
|
7
|
-
opacity: 0.5
|
8
|
-
}
|
6
|
+
|
9
7
|
.reorder, .reorder label {
|
10
8
|
cursor: move;
|
11
9
|
}
|
12
10
|
|
13
|
-
.flash {
|
14
|
-
border: 1px solid;
|
15
|
-
margin: 10px 0px;
|
16
|
-
padding:15px 10px 15px 10px;
|
17
|
-
background-repeat: no-repeat;
|
18
|
-
background-position: 10px center;
|
19
|
-
position:relative;
|
20
|
-
line-height: 30px;
|
21
|
-
&>i.icon:first-child {
|
22
|
-
font-family: FontAwesome;
|
23
|
-
font-size: 30px;
|
24
|
-
|
25
|
-
font-style: normal;
|
26
|
-
position:absolute;
|
27
|
-
top: 50%;
|
28
|
-
margin-top: -15px;
|
29
|
-
}
|
30
|
-
&>span.flash-content {
|
31
|
-
padding-left: 35px;
|
32
|
-
|
33
|
-
}
|
34
|
-
}
|
35
|
-
.info {
|
36
|
-
color: #00529B;
|
37
|
-
background-color: #BDE5F8;
|
38
|
-
}
|
39
|
-
.notice {
|
40
|
-
color: #4F8A10;
|
41
|
-
background-color: #DFF2BF;
|
42
|
-
&>i.icon:first-child:before {
|
43
|
-
content: "\f05d"
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
.nodata, .no-data {
|
48
|
-
@extend .flash;
|
49
|
-
@extend .info;
|
50
|
-
text-align: center;
|
51
|
-
border-width: 3px;
|
52
|
-
}
|
53
|
-
|
54
|
-
div.error_explanation {
|
55
|
-
color: #D63301;
|
56
|
-
background-color: #FFCCBA;
|
57
|
-
border: 1px solid rgba(255,0,0,0.5);
|
58
|
-
position: relative;
|
59
|
-
margin: 0 0 25px 0;
|
60
|
-
h2 {
|
61
|
-
display: none;
|
62
|
-
}
|
63
|
-
ul {
|
64
|
-
margin: 0;
|
65
|
-
li {
|
66
|
-
line-height: 25px;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
&>p {
|
70
|
-
background-color: rgba(255,255,255,0.5);
|
71
|
-
margin: 0;
|
72
|
-
padding: 5px;
|
73
|
-
text-shadow: 0 0 5px #FFFFFF;
|
74
|
-
}
|
75
|
-
&>p:before {
|
76
|
-
font-family: FontAwesome;
|
77
|
-
margin-right: 5px;
|
78
|
-
font-size: 20px;
|
79
|
-
content: "\f071";
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
11
|
#account-extra-details {
|
84
12
|
dt {
|
85
13
|
width: 40%;
|
@@ -115,8 +43,6 @@ td.buttons {
|
|
115
43
|
.contextual {@extend .pull-right !optional}
|
116
44
|
.contextual input, .contextual select {font-size:0.9em;}
|
117
45
|
|
118
|
-
.required label, label[required], label.required, .has-error {color: red !important;}
|
119
|
-
.required label:after, label[required]:after, label.required:after { content: '* '}
|
120
46
|
textarea {width: 99%;}
|
121
47
|
|
122
48
|
#internal_static_page_sign {
|
@@ -142,29 +68,7 @@ textarea {width: 99%;}
|
|
142
68
|
}
|
143
69
|
}
|
144
70
|
}
|
145
|
-
|
146
|
-
text-align: right;
|
147
|
-
}
|
148
|
-
table.table {
|
149
|
-
th a.asc {
|
150
|
-
&:after {
|
151
|
-
content: "\2191";
|
152
|
-
}
|
153
|
-
}
|
154
|
-
th a.desc {
|
155
|
-
&:after {
|
156
|
-
content: "\2193";
|
157
|
-
}
|
158
|
-
}
|
159
|
-
tr.status {
|
160
|
-
&--lock, &--inactive, &--archived {
|
161
|
-
@include inactive-row;
|
162
|
-
}
|
163
|
-
}
|
164
|
-
.buttons {
|
165
|
-
text-align: right;
|
166
|
-
}
|
167
|
-
}
|
71
|
+
|
168
72
|
|
169
73
|
.highlight {
|
170
74
|
animation-duration: 1s;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
@import "layout";
|
2
|
-
@import "bootstrap-datepicker3";
|
2
|
+
// @import "bootstrap-datepicker3";
|
@@ -48,7 +48,7 @@ module Symphonia
|
|
48
48
|
@user.attributes = user_params
|
49
49
|
respond_to do |format|
|
50
50
|
@user.edited_by = User.current.logged_in? && User.current
|
51
|
-
@user.edited_at = Time.
|
51
|
+
@user.edited_at = Time.current
|
52
52
|
if @user.save
|
53
53
|
format.html { redirect_to({ action: 'show' }, notice: t(:text_updated)) }
|
54
54
|
format.json { head :no_content }
|
@@ -104,7 +104,7 @@ module Symphonia
|
|
104
104
|
@user = find_account_by_token(params.require(:id))
|
105
105
|
return render_404 if @user.nil?
|
106
106
|
|
107
|
-
if params[:password]
|
107
|
+
if params[:password].present?
|
108
108
|
@user.password = params[:password]
|
109
109
|
end
|
110
110
|
|
@@ -147,8 +147,12 @@ module Symphonia
|
|
147
147
|
User.current
|
148
148
|
end
|
149
149
|
|
150
|
+
def current_ability
|
151
|
+
@current_ability ||= UserAbility.new current_user
|
152
|
+
end
|
153
|
+
|
150
154
|
def find_account_by_mail(mail)
|
151
|
-
User.
|
155
|
+
User.find_by(email: mail)
|
152
156
|
end
|
153
157
|
|
154
158
|
def find_account_by_token(id)
|
@@ -2,10 +2,10 @@ module Symphonia
|
|
2
2
|
class UsersController < ApplicationController
|
3
3
|
|
4
4
|
helper Symphonia::RendererHelper
|
5
|
+
include ::CanCan::ControllerAdditions
|
5
6
|
|
6
|
-
before_action :
|
7
|
+
before_action :user, except: %i[index new create show]
|
7
8
|
before_action :authorize, except: [:show]
|
8
|
-
before_action -> { menu_item(:my_account) }, only: %i[current edit_current update_current]
|
9
9
|
|
10
10
|
def index
|
11
11
|
@query = Symphonia::User.query.new
|
@@ -22,8 +22,8 @@ module Symphonia
|
|
22
22
|
|
23
23
|
def show
|
24
24
|
@user = Symphonia::User.find(params[:id]) if params[:id]
|
25
|
-
@user ||=
|
26
|
-
authorize
|
25
|
+
@user ||= current_user
|
26
|
+
authorize! :show, @user
|
27
27
|
respond_to do |format|
|
28
28
|
format.html
|
29
29
|
format.json { render json: @user, except: %w[crypted_password password_salt persistence_token perishable_token] }
|
@@ -32,7 +32,6 @@ module Symphonia
|
|
32
32
|
|
33
33
|
def new
|
34
34
|
@user = Symphonia::User.new
|
35
|
-
@roles = Symphonia::Role.sorted
|
36
35
|
respond_to do |format|
|
37
36
|
format.html
|
38
37
|
end
|
@@ -46,27 +45,18 @@ module Symphonia
|
|
46
45
|
format.xml { render xml: @user, status: :created, location: @user }
|
47
46
|
format.json { render json: @user, status: :created, location: @user }
|
48
47
|
else
|
49
|
-
format.html
|
50
|
-
@roles = Symphonia::Role.sorted
|
51
|
-
render action: 'new'
|
52
|
-
end
|
48
|
+
format.html { render action: 'new' }
|
53
49
|
format.xml { render xml: @user.errors, status: :unprocessable_entity }
|
54
50
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
|
-
def edit
|
60
|
-
@roles = Role.all
|
61
|
-
end
|
55
|
+
def edit; end
|
62
56
|
|
63
57
|
def update
|
64
58
|
@user.attributes = user_params
|
65
|
-
@user.admin = params[:admin] if params[:admin] &&
|
66
|
-
if params[:role_id].present? && Symphonia::User.current.admin?
|
67
|
-
@role = Role.find(params[:role_id])
|
68
|
-
@user.role = @role
|
69
|
-
end
|
59
|
+
@user.admin = params[:admin] if params[:admin] && current_user.admin?
|
70
60
|
respond_to do |format|
|
71
61
|
@user.edited_by = current_user
|
72
62
|
@user.edited_at = DateTime.now
|
@@ -74,10 +64,7 @@ module Symphonia
|
|
74
64
|
format.html { redirect_back_or_default user_path(@user), notice: t(:text_updated) }
|
75
65
|
format.any(:json, :xml) { head :no_content }
|
76
66
|
else
|
77
|
-
format.html
|
78
|
-
@roles = Symphonia::Role.sorted
|
79
|
-
render action: 'edit'
|
80
|
-
end
|
67
|
+
format.html { render action: 'edit' }
|
81
68
|
format.xml { render xml: @user.errors, status: :unprocessable_entity }
|
82
69
|
format.json { render json: @user.errors, status: :unprocessable_entity }
|
83
70
|
end
|
@@ -114,22 +101,23 @@ module Symphonia
|
|
114
101
|
|
115
102
|
private
|
116
103
|
|
117
|
-
def
|
118
|
-
@user
|
104
|
+
def user
|
105
|
+
@user ||= Symphonia::User.find(params[:id])
|
119
106
|
end
|
120
107
|
|
121
108
|
def authorize
|
122
|
-
|
123
|
-
true
|
124
|
-
else
|
125
|
-
super
|
126
|
-
end
|
109
|
+
authorize! action_name.to_sym, @user
|
127
110
|
end
|
128
111
|
|
129
112
|
def user_params
|
130
113
|
allowed = [:login, :first_name, :last_name, :password, :password_confirmation, :email, :mail, preference_ids: []]
|
131
|
-
allowed
|
114
|
+
allowed << :admin if current_user.admin?
|
132
115
|
params.require(:user).permit(allowed)
|
133
116
|
end
|
117
|
+
|
118
|
+
def current_ability
|
119
|
+
@current_ability ||= UserAbility.new current_user
|
120
|
+
end
|
121
|
+
|
134
122
|
end
|
135
123
|
end
|