tb_core 1.3.7 → 1.3.9

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
  SHA1:
3
- metadata.gz: 9e447994850df42f2d94bace466371bcc952a6bb
4
- data.tar.gz: 3d2363bf502fdfc50ce228186bfd403ab7401498
3
+ metadata.gz: 7071129edfa67883164c13d28337400840d8977b
4
+ data.tar.gz: aee125137d5a1b6c5bd033480eccbf555fddf2fa
5
5
  SHA512:
6
- metadata.gz: 7f5a259c7068627afd84e7fccb1e45704660d5db6e814e8295a20d2d5318b86f30f92750e1602ee805700a2ca2abcac5ec3074fc300a48eae176e84060a3da9c
7
- data.tar.gz: 53bb1073d4757b407f1d2a0ddffbff390c45a4c2b00579eabb09e5b9502b83e3f14badb3b5500434afc68bb198419e078a789b2e0cd745f158f14cc31c00173f
6
+ metadata.gz: 474dd7c6e09fd2a1228387c2281a2156658b52b3eb3a05f634827cfa1f8d5efeda720dd0ccffa1306293ec87dea42567239ccde4ed5d0157f67431792bfa40fc
7
+ data.tar.gz: d6ed5438c32dc90b131dc4bf6f907a0dac1de00fc17a48d01e043578b7f873263731e647ccf2526f55a18950f41e8022e3868c72a44bd4abbb6dda285cbe895f
@@ -1,10 +1,11 @@
1
1
  class Admin::UsersController < Admin::ApplicationController
2
+ require 'csv'
2
3
 
3
4
  belongs_to_app :users
4
5
  add_breadcrumb "Users", :admin_users_path
5
6
  before_action :load_user, :only => [:edit, :update, :show, :destroy]
6
7
  after_action :send_credentials_email, :only => [:create, :update]
7
- respond_to :html
8
+ respond_to :html, :csv
8
9
 
9
10
  def index
10
11
  @spud_users = SpudUser.ordered.paginate(:page => params[:page], :per_page => 15)
@@ -18,6 +19,13 @@ class Admin::UsersController < Admin::ApplicationController
18
19
  respond_with @user
19
20
  end
20
21
 
22
+ def export
23
+ users = SpudUser.all
24
+ export_columns = %w(created_at first_name last_name email last_login_at)
25
+ file_name = Spud::Core.site_name + ' Users Export.csv'
26
+ send_data users.as_csv(export_columns), :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => "attachment; filename=#{file_name}"
27
+ end
28
+
21
29
  def new
22
30
  @user = SpudUser.new
23
31
  respond_with @user do |format|
@@ -13,16 +13,22 @@
13
13
 
14
14
  def create
15
15
  @user_session = SpudUserSession.new(params[:spud_user_session])
16
- logged_in = @user_session.save()
17
- respond_with @user_session do |format|
18
- format.html{
19
- if logged_in
16
+ if @user_session.save()
17
+ respond_with @user_session do |format|
18
+ format.html{
20
19
  flash[:notice] = "Login successful!"
21
20
  redirect_back_or_default('/')
22
- else
21
+ }
22
+ format.json{
23
+ render json: {success: true}
24
+ }
25
+ end
26
+ else
27
+ respond_with @user_session do |format|
28
+ format.html{
23
29
  render 'new'
24
- end
25
- }
30
+ }
31
+ end
26
32
  end
27
33
  end
28
34
 
@@ -36,6 +36,12 @@ class Spud::SpudUserModel < ActiveRecord::Base
36
36
  return "#{self.first_name} #{self.last_name}"
37
37
  end
38
38
 
39
+ def email_formatted
40
+ address = Mail::Address.new(email)
41
+ address.display_name = full_name
42
+ return address.format
43
+ end
44
+
39
45
  def full_name_with_email
40
46
  return "#{full_name} (#{email})"
41
47
  end
@@ -112,6 +118,15 @@ class Spud::SpudUserModel < ActiveRecord::Base
112
118
  end
113
119
  end
114
120
 
121
+ def self.as_csv(column_names, options = {})
122
+ CSV.generate do |csv|
123
+ csv << column_names
124
+ all.each do |item|
125
+ csv << item.attributes.values_at(*column_names)
126
+ end
127
+ end
128
+ end
129
+
115
130
  private
116
131
 
117
132
  def set_login_to_email
@@ -2,7 +2,7 @@
2
2
 
3
3
  <%= tb_form_error_header(f.object) %>
4
4
 
5
- <h4>User Details</h4>
5
+ <%= f.tb_sub_title 'User Details' %>
6
6
 
7
7
  <% if !Spud::Core.config.use_email_as_login %>
8
8
  <%= f.tb_text_field :login %>
@@ -14,7 +14,7 @@
14
14
 
15
15
  <%= render :partial => 'form_additions', :locals => {:f => f} %>
16
16
 
17
- <h4>Credentials</h4>
17
+ <%= f.tb_sub_title 'Credentials' %>
18
18
 
19
19
  <%= f.tb_password_field :password %>
20
20
  <%= f.tb_password_field :password_confirmation %>
@@ -42,7 +42,7 @@
42
42
  </div>
43
43
  </div>
44
44
 
45
- <h4>Permissions</h4>
45
+ <%= f.tb_sub_title 'Permissions' %>
46
46
 
47
47
  <%= f.tb_check_box :super_admin, :help_block => 'The super administrator bypasses all permissions and roles.' %>
48
48
  <%= f.tb_select :spud_role_id, options_from_collection_for_select(SpudRole.all, :id, :name, f.object.spud_role_id), {:include_blank => 'No Role'} %>
@@ -2,6 +2,7 @@
2
2
  <%= render :partial => '/layouts/admin/search', :locals => {:search_path => admin_users_path} %>
3
3
  <%= link_to 'Roles', admin_roles_path, :class => 'btn btn-default admin-role-btn' %>
4
4
  <%= link_to "New User", new_admin_user_path, :class => "btn btn-primary admin-user-add-btn", :title => "New User" %>
5
+ <%= link_to "Export", export_admin_users_path, :class => "btn btn-primary admin-user-add-btn", :title => "New User" %>
5
6
  <% end %>
6
7
 
7
8
  <%= content_for :detail do %>
data/config/routes.rb CHANGED
@@ -12,7 +12,9 @@ Rails.application.routes.draw do
12
12
  put 'change_sort' => 'dashboard#change_sort'
13
13
 
14
14
  root :to => "dashboard#index"
15
- resources :users, :controller
15
+ resources :users do
16
+ get 'export', :on => :collection
17
+ end
16
18
  resources :roles
17
19
 
18
20
  get 'setup' => 'setup#new'
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.3.7"
3
+ VERSION = "1.3.9"
4
4
  end
5
5
  end
@@ -24,6 +24,13 @@ describe SpudUser, :type => :model do
24
24
  end
25
25
  end
26
26
 
27
+ describe '#email_formatted' do
28
+ it 'should return an email formtted for sending' do
29
+ user = FactoryGirl.create(:spud_user)
30
+ expect(user.email_formatted).to eq("#{user.full_name} <#{user.email}>")
31
+ end
32
+ end
33
+
27
34
  it { should_not allow_value('').for(:login) }
28
35
  it { should validate_length_of(:login).is_at_least(3) }
29
36
  it { should validate_length_of(:password).is_at_least(4) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails