chaltron 0.3.2 → 1.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/README.md +2 -1
- data/app/assets/javascripts/chaltron.js +7 -5
- data/app/assets/javascripts/chaltron/datatables.js.coffee +2 -2
- data/app/assets/javascripts/chaltron/navbar.js.coffee +46 -0
- data/app/assets/javascripts/dataTables/dataTables.bootstrap4.min.js +8 -0
- data/app/assets/stylesheets/chaltron.scss +9 -9
- data/app/assets/stylesheets/chaltron/layout.scss +3 -29
- data/app/assets/stylesheets/chaltron/logs.scss +5 -0
- data/app/controllers/chaltron/ldap_controller.rb +5 -5
- data/app/controllers/chaltron/omniauth_callbacks_controller.rb +0 -1
- data/app/controllers/chaltron/sessions_controller.rb +0 -3
- data/app/controllers/chaltron/users_controller.rb +1 -3
- data/app/datatables/log_datatable.rb +3 -2
- data/app/helpers/chaltron/ldap_helper.rb +3 -3
- data/app/helpers/chaltron/logs_helper.rb +4 -13
- data/app/helpers/chaltron/users_helper.rb +20 -2
- data/app/helpers/chaltron_helper.rb +0 -16
- data/app/models/authorizable.rb +1 -1
- data/app/models/log.rb +10 -12
- data/app/models/user.rb +1 -5
- data/app/views/chaltron/ldap/multi_create.html.erb +39 -35
- data/app/views/chaltron/ldap/multi_new.html.erb +36 -30
- data/app/views/chaltron/ldap/search.html.erb +13 -10
- data/app/views/chaltron/logs/index.html.erb +22 -28
- data/app/views/chaltron/logs/show.html.erb +6 -6
- data/app/views/chaltron/users/_form.html.erb +8 -5
- data/app/views/chaltron/users/_side_filters.html.erb +10 -26
- data/app/views/chaltron/users/edit.html.erb +1 -1
- data/app/views/chaltron/users/index.html.erb +29 -31
- data/app/views/chaltron/users/new.html.erb +1 -1
- data/app/views/chaltron/users/self_edit.html.erb +27 -20
- data/app/views/chaltron/users/self_show.html.erb +8 -8
- data/app/views/chaltron/users/show.html.erb +10 -10
- data/app/views/devise/passwords/edit.html.erb +8 -7
- data/app/views/devise/passwords/new.html.erb +10 -7
- data/app/views/devise/sessions/_new_ldap.html.erb +17 -14
- data/app/views/devise/sessions/_new_local.html.erb +10 -7
- data/app/views/devise/sessions/new.html.erb +30 -25
- data/app/views/locales/en.yml +4 -4
- data/app/views/locales/it.yml +2 -2
- data/config/chaltron_navigation.rb +15 -23
- data/config/locales/en.yml +1 -6
- data/config/locales/it.yml +1 -6
- data/config/routes.rb +4 -5
- data/lib/chaltron.rb +1 -24
- data/lib/chaltron/bootstrap_form.rb +1 -1
- data/lib/chaltron/engine.rb +2 -3
- data/lib/chaltron/ldap/connection.rb +34 -93
- data/lib/chaltron/ldap/person.rb +3 -13
- data/lib/chaltron/ldap/user.rb +1 -5
- data/lib/chaltron/version.rb +1 -1
- data/lib/generators/chaltron/install_generator.rb +9 -3
- data/lib/generators/chaltron/templates/app/assets/stylesheets/home.scss +2 -20
- data/lib/generators/chaltron/templates/app/views/home/_carousel.html.erb +18 -18
- data/lib/generators/chaltron/templates/app/views/home/_faq.html.erb +10 -8
- data/lib/generators/chaltron/templates/app/views/home/_panel.html.erb +5 -7
- data/lib/generators/chaltron/templates/app/views/home/index.html.erb +12 -10
- data/lib/generators/chaltron/templates/app/views/home/test.html.erb +3 -5
- data/lib/generators/chaltron/templates/app/views/layouts/_footer.html.erb +7 -9
- data/lib/generators/chaltron/templates/app/views/layouts/_navbar.html.erb +8 -15
- data/lib/generators/chaltron/templates/config/initializers/chaltron.rb +4 -57
- data/lib/generators/chaltron/templates/config/navigation.rb +11 -10
- data/lib/templates/erb/scaffold/_form.html.erb +8 -5
- data/lib/templates/erb/scaffold/edit.html.erb +8 -8
- data/lib/templates/erb/scaffold/index.html.erb +15 -21
- data/lib/templates/erb/scaffold/new.html.erb +2 -6
- data/lib/templates/erb/scaffold/show.html.erb +9 -9
- metadata +24 -25
- data/app/assets/javascripts/dataTables/extras/dataTables.select.min.js +0 -23
- data/app/assets/stylesheets/dataTables/dataTables.bootstrap.css +0 -167
- data/app/assets/stylesheets/dataTables/extras/select.dataTables.css +0 -100
- data/app/models/application_record.rb +0 -3
- data/app/views/chaltron/logs/_log.html.erb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e9ae962f2dd9c241da700b59ffff814b0e10483
|
4
|
+
data.tar.gz: 738cf12df8205c411047c8e245e4580d86b95204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab99ee8301b42f336a2f9f844978787b456fc8ada3bc422cf49ad244a93396a9f63dcbefc7748f7438e535d27de11ee30d979062aade8d5ef98e267e0f34c73e
|
7
|
+
data.tar.gz: 3120ad2fd6985cbeda1e4ace7e7e0eaf319ee6e8cc81af4a80d2907f0f520e5952609bb192cbba90d1ab6f0a38dd98c72ef67fc37064310c2c290bb9b6ccddae
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# Chaltron [](http://badge.fury.io/rb/chaltron) [](http://travis-ci.org/vicvega/chaltron)
|
1
|
+
# Chaltron [](http://badge.fury.io/rb/chaltron) [](http://travis-ci.org/vicvega/chaltron) [](https://gemnasium.com/vicvega/chaltron)
|
2
|
+
|
2
3
|
[](https://coveralls.io/github/vicvega/chaltron?branch=master)
|
3
4
|
[](https://codeclimate.com/github/vicvega/chaltron)
|
4
5
|
[](https://www.pullreview.com/github/vicvega/chaltron/reviews/master)
|
@@ -1,10 +1,12 @@
|
|
1
1
|
//= require jquery
|
2
2
|
//= require jquery_ujs
|
3
|
-
//= require
|
4
|
-
//= require
|
5
|
-
//= require
|
6
|
-
//= require
|
7
|
-
//= require
|
3
|
+
//= require popper
|
4
|
+
//= require bootstrap
|
5
|
+
//= require datatables/jquery.dataTables
|
6
|
+
//= require datatables/dataTables.bootstrap4
|
7
|
+
//= require datatables/extensions/Responsive/dataTables.responsive
|
8
|
+
//= require datatables/extensions/Responsive/responsive.bootstrap4
|
9
|
+
//= require datatables/extensions/Select/dataTables.select
|
8
10
|
//= require nprogress
|
9
11
|
//= require nprogress-turbolinks
|
10
12
|
//= require nprogress-ajax
|
@@ -20,7 +20,6 @@ class DataTableBuilder
|
|
20
20
|
columnDefs: [
|
21
21
|
{ orderable: false, className: 'select-checkbox', targets: 0 }
|
22
22
|
]
|
23
|
-
dom: 'T<"clear">lfrtip'
|
24
23
|
select: { style: 'multi', info: false }
|
25
24
|
})
|
26
25
|
|
@@ -39,7 +38,8 @@ class DataTableBuilder
|
|
39
38
|
{ data: 'category', searchable: false }
|
40
39
|
]
|
41
40
|
columnDefs: [
|
42
|
-
{ orderSequence: ['desc', 'asc'], targets: [ 1 ] }
|
41
|
+
{ orderSequence: ['desc', 'asc'], targets: [ 1 ] },
|
42
|
+
{ className: 'text-center', "targets": [ 0 ] }
|
43
43
|
]
|
44
44
|
})
|
45
45
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class NavbarBuilder
|
2
|
+
|
3
|
+
render: ->
|
4
|
+
@prepend_class(i, 'navbar-nav mr-auto') for i in $('#navigation ul')
|
5
|
+
$('#navigation ul li').addClass('nav-item')
|
6
|
+
$('#navigation ul li a').addClass('nav-link')
|
7
|
+
$('#navigation ul li ul').parent().addClass('dropdown')
|
8
|
+
$('#navigation ul li.dropdown').children('a').addClass('dropdown-toggle').attr(
|
9
|
+
{id: 'navbarDropdown', role: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', 'data-toggle': 'dropdown'}
|
10
|
+
)
|
11
|
+
@render_dropdown_menu i for i in $('#navigation ul li.dropdown')
|
12
|
+
@render_icon_a i for i in $('#navigation ul li a')
|
13
|
+
|
14
|
+
render_dropdown_menu: (item) ->
|
15
|
+
links = jQuery(item).find('ul li a')
|
16
|
+
jQuery(l).addClass('dropdown-item').removeClass('nav-link') for l in links
|
17
|
+
@render_dropdown_links (i) for i in jQuery(item).find('ul')
|
18
|
+
|
19
|
+
render_dropdown_links: (item) ->
|
20
|
+
el = jQuery(item)
|
21
|
+
links = el.find('li a')
|
22
|
+
|
23
|
+
klass = 'dropdown-menu'
|
24
|
+
klass += ' dropdown-menu-right' if el.hasClass('dropdown-menu-right')
|
25
|
+
div = $('<div></div>').addClass('dropdown-menu').attr('aria-labelledby': 'navbarDropdown').append(links)
|
26
|
+
el.replaceWith(div)
|
27
|
+
|
28
|
+
prepend_class: (item, klass) ->
|
29
|
+
el = jQuery(item)
|
30
|
+
if el.attr('class')
|
31
|
+
klass += " #{el.attr('class')}"
|
32
|
+
el.removeClass(jQuery(item).attr('class'))
|
33
|
+
|
34
|
+
el.addClass(klass)
|
35
|
+
|
36
|
+
if el.hasClass('justify-content-end')
|
37
|
+
el.removeClass('mr-auto')
|
38
|
+
|
39
|
+
render_icon_a: (item) ->
|
40
|
+
el = jQuery(item)
|
41
|
+
if el.attr('icon')
|
42
|
+
el.html("<i class=\"fa fa-fw fa-#{el.attr('icon')}\"></i> #{el.text()}")
|
43
|
+
|
44
|
+
$(document).on 'turbolinks:load', ->
|
45
|
+
navbar = new NavbarBuilder
|
46
|
+
navbar.render()
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/*!
|
2
|
+
DataTables Bootstrap 3 integration
|
3
|
+
©2011-2015 SpryMedia Ltd - datatables.net/license
|
4
|
+
*/
|
5
|
+
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d,m){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
6
|
+
renderer:"bootstrap"});b.extend(f.ext.classes,{sWrapper:"dataTables_wrapper container-fluid dt-bootstrap4",sFilterInput:"form-control form-control-sm",sLengthSelect:"form-control form-control-sm",sProcessing:"dataTables_processing card",sPageButton:"paginate_button page-item"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,s,j,n){var o=new f.Api(a),t=a.oClasses,k=a.oLanguage.oPaginate,u=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault();!b(a.currentTarget).hasClass("disabled")&&
|
7
|
+
o.page()!=a.data.action&&o.page(a.data.action).draw("page")};l=0;for(h=f.length;l<h;l++)if(c=f[l],b.isArray(c))q(d,c);else{g=e="";switch(c){case "ellipsis":e="…";g="disabled";break;case "first":e=k.sFirst;g=c+(0<j?"":" disabled");break;case "previous":e=k.sPrevious;g=c+(0<j?"":" disabled");break;case "next":e=k.sNext;g=c+(j<n-1?"":" disabled");break;case "last":e=k.sLast;g=c+(j<n-1?"":" disabled");break;default:e=c+1,g=j===c?"active":""}e&&(i=b("<li>",{"class":t.sPageButton+" "+g,id:0===r&&
|
8
|
+
"string"===typeof c?a.sTableId+"_"+c:null}).append(b("<a>",{href:"#","aria-controls":a.sTableId,"aria-label":u[c],"data-dt-idx":p,tabindex:a.iTabIndex,"class":"page-link"}).html(e)).appendTo(d),a.oApi._fnBindAction(i,{action:c},m),p++)}},i;try{i=b(h).find(d.activeElement).data("dt-idx")}catch(v){}q(b(h).empty().html('<ul class="pagination"/>').children("ul"),s);i!==m&&b(h).find("[data-dt-idx="+i+"]").focus()};return f});
|
@@ -1,20 +1,17 @@
|
|
1
1
|
// Bootstrap
|
2
|
-
$font-size-base: 13px;
|
3
|
-
$navbar-height: 40px;
|
4
|
-
|
5
|
-
@import 'bootstrap-sprockets';
|
6
2
|
@import 'bootstrap';
|
7
|
-
@import 'bootstrap/theme';
|
8
3
|
|
9
4
|
// font-awesome
|
10
5
|
@import 'font-awesome-sprockets';
|
11
6
|
@import 'font-awesome';
|
12
7
|
|
13
8
|
// datatables
|
14
|
-
@import '
|
15
|
-
@import '
|
16
|
-
@import '
|
17
|
-
|
9
|
+
@import 'datatables/dataTables.bootstrap4';
|
10
|
+
@import 'datatables/extensions/Responsive/responsive.bootstrap4';
|
11
|
+
@import 'datatables/extensions/Select/select.bootstrap4';
|
12
|
+
|
13
|
+
// bootstrap_form
|
14
|
+
@import 'rails_bootstrap_forms';
|
18
15
|
|
19
16
|
// minor fix
|
20
17
|
.dataTables_wrapper .dataTables_filter input {
|
@@ -30,3 +27,6 @@ $navbar-height: 40px;
|
|
30
27
|
|
31
28
|
// Core CSS
|
32
29
|
@import 'chaltron/layout';
|
30
|
+
|
31
|
+
// logs
|
32
|
+
@import 'chaltron/logs';
|
@@ -1,10 +1,9 @@
|
|
1
1
|
body {
|
2
|
-
// background-color: #E1E1E1;
|
3
2
|
}
|
4
3
|
|
5
4
|
div#content {
|
6
|
-
margin-top:
|
7
|
-
margin-bottom:
|
5
|
+
margin-top: 2.5rem;
|
6
|
+
margin-bottom: 2.5rem;
|
8
7
|
}
|
9
8
|
|
10
9
|
/**
|
@@ -16,7 +15,7 @@ div#content {
|
|
16
15
|
margin: 0;
|
17
16
|
text-align: center;
|
18
17
|
position: fixed;
|
19
|
-
top:
|
18
|
+
top: 2.5rem;
|
20
19
|
width: 100%;
|
21
20
|
opacity: 0.8;
|
22
21
|
z-index: 100;
|
@@ -35,14 +34,6 @@ div#content {
|
|
35
34
|
@include form-box(650px);
|
36
35
|
}
|
37
36
|
|
38
|
-
/**
|
39
|
-
* Navbar tabs
|
40
|
-
*
|
41
|
-
*/
|
42
|
-
.nav-tabs {
|
43
|
-
margin-bottom: 15px;
|
44
|
-
}
|
45
|
-
|
46
37
|
#nprogress .spinner {
|
47
38
|
display: block;
|
48
39
|
position: fixed;
|
@@ -50,20 +41,3 @@ div#content {
|
|
50
41
|
top: 12px;
|
51
42
|
right: 5px;
|
52
43
|
}
|
53
|
-
|
54
|
-
/**
|
55
|
-
* Scaffold
|
56
|
-
*
|
57
|
-
*/
|
58
|
-
.side-filters fieldset {
|
59
|
-
margin-bottom: 15px;
|
60
|
-
}
|
61
|
-
|
62
|
-
.form-actions {
|
63
|
-
background-color: whitesmoke;
|
64
|
-
border-top: 1px solid #e5e5e5;
|
65
|
-
margin-bottom: 18px;
|
66
|
-
margin-top: 18px;
|
67
|
-
padding-bottom: 18px;
|
68
|
-
padding-top: 18px;
|
69
|
-
}
|
@@ -15,11 +15,11 @@ class Chaltron::LdapController < ApplicationController
|
|
15
15
|
userid = params[:userid]
|
16
16
|
if userid.present?
|
17
17
|
entry = Chaltron::LDAP::Person.find_by_uid(userid)
|
18
|
-
@entries << entry
|
18
|
+
@entries << entry unless entry.nil?
|
19
19
|
else
|
20
|
-
|
20
|
+
res = Chaltron::LDAP::Person.find_by_fields(find_options)
|
21
|
+
@entries = res
|
21
22
|
end
|
22
|
-
@entries.compact!
|
23
23
|
end
|
24
24
|
|
25
25
|
def multi_create
|
@@ -41,12 +41,12 @@ class Chaltron::LdapController < ApplicationController
|
|
41
41
|
private
|
42
42
|
def find_options
|
43
43
|
department = params[:department]
|
44
|
-
name = params[:
|
44
|
+
name = params[:fullname]
|
45
45
|
limit = params[:limit].to_i
|
46
46
|
|
47
47
|
ret = {}
|
48
48
|
ret[:department] = "*#{department}*" unless department.blank?
|
49
|
-
ret[:
|
49
|
+
ret[:cn] = "*#{name}*" unless name.blank?
|
50
50
|
ret[:limit] = limit.zero? ? default_limit : limit
|
51
51
|
ret
|
52
52
|
end
|
@@ -12,7 +12,6 @@ module Chaltron
|
|
12
12
|
# We only find ourselves here
|
13
13
|
# if the authentication to LDAP was successful.
|
14
14
|
user = Chaltron::LDAP::User.find_or_create(oauth, Chaltron.ldap_allow_all)
|
15
|
-
user = Chaltron.ldap_after_authenticate.call(user, Chaltron::LDAP::Connection.new)
|
16
15
|
if user.nil?
|
17
16
|
redirect_to root_url, alert: I18n.t('chaltron.not_allowed_to_sign_in')
|
18
17
|
else
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'chaltron/ldap/connection'
|
2
|
-
|
3
1
|
class Chaltron::SessionsController < Devise::SessionsController
|
4
2
|
after_action :after_login, only: :create
|
5
3
|
before_action :before_logout, only: :destroy
|
@@ -11,7 +9,6 @@ class Chaltron::SessionsController < Devise::SessionsController
|
|
11
9
|
end
|
12
10
|
|
13
11
|
def before_logout
|
14
|
-
Chaltron.ldap_before_logout.call(current_user, Chaltron::LDAP::Connection.new) if current_user.ldap_user?
|
15
12
|
info I18n.t('chaltron.logs.logout', user: current_user.display_name)
|
16
13
|
end
|
17
14
|
end
|
@@ -81,9 +81,7 @@ class Chaltron::UsersController < ApplicationController
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self_update_params
|
84
|
-
|
85
|
-
allowed << :email if current_user.provider.nil?
|
86
|
-
params.require(:user).permit(allowed)
|
84
|
+
params.require(:user).permit(:email, :fullname)
|
87
85
|
end
|
88
86
|
|
89
87
|
def filter_params
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class LogDatatable < AjaxDatatablesRails::Base
|
2
2
|
|
3
|
-
def_delegators :@view, :link_to, :
|
3
|
+
def_delegators :@view, :link_to, :content_tag, :bootstrap_severity, :current_ability
|
4
4
|
|
5
5
|
def view_columns
|
6
6
|
# Declare strings in this format: ModelName.column_name
|
@@ -18,7 +18,8 @@ class LogDatatable < AjaxDatatablesRails::Base
|
|
18
18
|
def data
|
19
19
|
records.map do |log|
|
20
20
|
{
|
21
|
-
severity:
|
21
|
+
severity: content_tag(:span, I18n.t("chaltron.logs.severity.#{log.severity}"),
|
22
|
+
class: "badge badge-#{bootstrap_severity(log.severity)}"),
|
22
23
|
date: I18n.l(log.created_at, format: :short),
|
23
24
|
message: link_to(log.message, log),
|
24
25
|
category: I18n.t("chaltron.logs.category.#{log.category}")
|
@@ -2,8 +2,8 @@ module Chaltron::LdapHelper
|
|
2
2
|
|
3
3
|
def display_entry_name(entry)
|
4
4
|
if User.exists?(username: entry.username)
|
5
|
-
(entry.name + ' 
|
6
|
-
|
5
|
+
(entry.name + ' ').html_safe +
|
6
|
+
content_tag(:span, I18n.t('chaltron.users.already_present'), class: 'badge badge-danger')
|
7
7
|
else
|
8
8
|
entry.name
|
9
9
|
end
|
@@ -12,7 +12,7 @@ module Chaltron::LdapHelper
|
|
12
12
|
def display_entry_email(entry)
|
13
13
|
mail = entry.email
|
14
14
|
if mail.blank?
|
15
|
-
|
15
|
+
content_tag(:span, I18n.t('chaltron.users.missing_field'), class: 'badge badge-danger')
|
16
16
|
else
|
17
17
|
mail
|
18
18
|
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
module Chaltron::LogsHelper
|
2
|
-
def display_panel(log, &block)
|
3
|
-
klass = "panel panel-#{bootstrap_severity(log.severity)}"
|
4
|
-
content_tag :div, capture(&block), class: klass
|
5
|
-
end
|
6
|
-
|
7
2
|
def bootstrap_severity(severity)
|
8
3
|
case severity.to_s
|
9
|
-
when '
|
10
|
-
|
11
|
-
when '
|
12
|
-
|
13
|
-
when 'debug'
|
14
|
-
'info'
|
15
|
-
else
|
16
|
-
'primary'
|
4
|
+
when 'info' then 'primary'
|
5
|
+
when 'error' then 'danger'
|
6
|
+
when 'debug' then 'info'
|
7
|
+
else 'default'
|
17
8
|
end
|
18
9
|
end
|
19
10
|
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
module Chaltron::UsersHelper
|
2
2
|
def display_username(user)
|
3
3
|
if user == current_user
|
4
|
-
link_to(user.username, user) + ' 
|
5
|
-
|
4
|
+
link_to(user.username, user) + ' '.html_safe +
|
5
|
+
content_tag(:span, I18n.t('chaltron.users.it_s_you'), class: 'badge badge-success')
|
6
6
|
else
|
7
7
|
link_to user.username, user
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
11
|
+
def display_side_filter_link(url, active, text, count)
|
12
|
+
|
13
|
+
klass = 'list-group-item list-group-item-action'
|
14
|
+
klass += ' active' if active
|
15
|
+
|
16
|
+
badge_klass = 'badge badge-pill float-right'
|
17
|
+
if active
|
18
|
+
badge_klass += ' badge-light'
|
19
|
+
else
|
20
|
+
badge_klass += ' badge-primary'
|
21
|
+
end
|
22
|
+
|
23
|
+
link_to url, class: klass do
|
24
|
+
content_tag(:span, count, class: badge_klass) + text
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
10
28
|
end
|
@@ -33,17 +33,6 @@ module ChaltronHelper
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
37
|
-
# Badge and label helpers
|
38
|
-
#
|
39
|
-
def badge(*args)
|
40
|
-
badge_label(:badge, *args)
|
41
|
-
end
|
42
|
-
|
43
|
-
def tag_label(*args)
|
44
|
-
badge_label(:label, *args)
|
45
|
-
end
|
46
|
-
|
47
36
|
#
|
48
37
|
# Get current revision
|
49
38
|
#
|
@@ -61,9 +50,4 @@ module ChaltronHelper
|
|
61
50
|
end
|
62
51
|
end
|
63
52
|
|
64
|
-
def badge_label(what, value, type = nil)
|
65
|
-
klass = [what]
|
66
|
-
klass << "#{what}-#{type}" if type.present?
|
67
|
-
content_tag :span, value, class: "#{klass.join(' ')}"
|
68
|
-
end
|
69
53
|
end
|
data/app/models/authorizable.rb
CHANGED
data/app/models/log.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
class Log <
|
2
|
-
Severities = %w(
|
1
|
+
class Log < ActiveRecord::Base
|
2
|
+
Severities = %w( info debug error )
|
3
3
|
|
4
4
|
validates_presence_of :severity, :message
|
5
5
|
validates_inclusion_of :severity, in: Severities
|
6
6
|
|
7
|
-
before_validation :change_severity
|
8
|
-
|
9
7
|
after_create :to_syslog if Chaltron.enable_syslog
|
10
8
|
|
11
9
|
private
|
12
|
-
|
13
|
-
def change_severity
|
14
|
-
self.severity = :emerg if self.severity && self.severity.to_sym == :panic
|
15
|
-
self.severity = :err if self.severity && self.severity.to_sym == :error
|
16
|
-
self.severity = :warning if self.severity && self.severity.to_sym == :warn
|
17
|
-
end
|
18
|
-
|
19
10
|
def to_syslog
|
11
|
+
syslog_method =
|
12
|
+
case self.severity
|
13
|
+
when 'info' then :notice
|
14
|
+
when 'debug' then :debug
|
15
|
+
when 'error' then :err
|
16
|
+
else :info
|
17
|
+
end
|
20
18
|
Syslog.open(Rails.application.class.parent.to_s, Syslog::LOG_PID, Chaltron.syslog_facility) do |s|
|
21
|
-
s.send(
|
19
|
+
s.send(syslog_method, self.category.upcase + ' - ' + self.message)
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
data/app/models/user.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class User <
|
1
|
+
class User < ActiveRecord::Base
|
2
2
|
include Authorizable
|
3
3
|
# Include default devise modules. Others available are:
|
4
4
|
# :registerable, :confirmable, :lockable and :omniauthable
|
@@ -26,8 +26,4 @@ class User < ApplicationRecord
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def ldap_user?
|
30
|
-
provider == 'ldap'
|
31
|
-
end
|
32
|
-
|
33
29
|
end
|