concerto_hardware 0.6 → 0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 186d33539240543220c3e8bf64bb23faa40d8012
4
- data.tar.gz: 64915da3b071bd54ace66a802a73dc1e529f7106
3
+ metadata.gz: f1de2ff162fbfe44a96e2e7a3a186884558c818d
4
+ data.tar.gz: 32d526c912f7106a368aa00f68d10e6bb2bcd5a7
5
5
  SHA512:
6
- metadata.gz: e3204c8e5869116dfb1e6d30adb64ec67bf5a284ffa3fcc05d4f0f1789b1f935003472eabdcfcdcc85918e74231f906dbd511a0aa3368a90b9598db44f6a4f9d
7
- data.tar.gz: 1ddcb546b46c215edb5a6561a51abc5c44483aa6424f89381aa08fdc2410098609708c89f72cbac1fde6ac5715be388123f54e1c5c2e96ffc07bbf4716d21769
6
+ metadata.gz: d9ebf4129523305e383b03c265149063714351a9ec0f7f175b674baeb64e908ba8e7113b0e677cf8635f8c5e654c563030b2bc182688fb10c534503127a6552b
7
+ data.tar.gz: 4d238f151e2199e50c85e9a2b88116f81f76b83ebbc6da55a43ce549730dc46cd20ace2b85f923ec99e7e8e919d5dbc5a7d6e57bcf24cf8fcf61add3c4892ece
@@ -0,0 +1,20 @@
1
+ module ConcertoHardware
2
+ # Congratulations! You've found this engine's secret sauce.
3
+ # In a regular isolated engine, the engine's ApplicationController
4
+ # inherits from ActionController::Base. We're using the the main app's
5
+ # ApplicationController, making the isolation a little less strict.
6
+ # For example, we get the layout from the main Concerto app.
7
+ # Note that links back to the main application will need to directly
8
+ # reference the main_app router.
9
+ helper_method :current_accessor2
10
+ class ApplicationController < ::ApplicationController
11
+ def current_ability
12
+ # Use the Ability class defined in this engine's namespace.
13
+ # It is designed to also include the rules from the main app.
14
+ @current_ability ||= ConcertoHardware::Ability.new(current_accessor)
15
+ end
16
+ def current_accessor2
17
+ current_accessor
18
+ end
19
+ end
20
+ end
@@ -41,7 +41,8 @@ class PlayersController < ConcertoHardware::ApplicationController
41
41
  format.html # show.html.erb
42
42
  format.json {
43
43
  render :json => @player.to_json(
44
- :include => { :screen => { :only => :name } }
44
+ :include => { :screen => { :only => :name } },
45
+ :methods => [:time_zone]
45
46
  )
46
47
  }
47
48
  end
@@ -0,0 +1,43 @@
1
+ module ConcertoHardware
2
+ # The enigne's Ability class simply extends the existing Ability
3
+ # class for the application. We rely on the fact that it already
4
+ # includes CanCan::Ability.
5
+ class Ability < ::Ability
6
+ def initialize(accessor)
7
+ super # Get the main application's rules
8
+ # The main app will delegate to user_abilities, etc.
9
+ # Note the inherited rules give Admins rights to manage everything
10
+ end
11
+
12
+ def user_abilities(user)
13
+ super # Get the user rules from the main applications
14
+
15
+ # For debugging you may want to make all Players readable
16
+ # can :read, Player
17
+
18
+ # Let's defer to Concerto's rules for Screen Permissions.
19
+ # This will apply to both users browsing the hardware info
20
+ # as well as public screens in public instances accessing their data.
21
+ # - Right now, only admins can create players (TODO)
22
+ # - It may become desirable in the future for reading to be
23
+ # restricted or curtailed if a lot of sensitive data is stored here.
24
+ can :read, Player do |player|
25
+ !player.screen.nil? and can? :read, player.screen
26
+ end
27
+ can :update, Player do |player|
28
+ !player.screen.nil? and can? :update, player.screen
29
+ end
30
+ can :delete, Player do |player|
31
+ !player.screen.nil? and can? :delete, player.screen
32
+ end
33
+ end # user_abilities
34
+
35
+ def screen_abilities(screen)
36
+ super
37
+ # A logged-in screen can read its own Player information.
38
+ can :read, Player, :screen_id => screen.id
39
+ # In the future it may also need to write reporting data, so
40
+ # this will need to be expanded.
41
+ end # screen_abilities
42
+ end # class Ability
43
+ end # module ConcertoHardware
@@ -201,6 +201,24 @@ module ConcertoHardware
201
201
  return ConcertoConfig[:poll_interval].to_i
202
202
  end
203
203
 
204
+ # Get the timezone that has been configured for this screen,
205
+ # using in the standard region/city format.
206
+ # Example: "America/New York"
207
+ # This is used in the Player API for Bandshell.
208
+ def time_zone
209
+ # The concerto config and screen config are stored in
210
+ # ActiveSupport::TimeZone's "friendly" time zone format:
211
+ # "Eastern Time (US & Canada)"
212
+ if screen.nil? or screen.time_zone.nil?
213
+ pretty_time_zone = ConcertoConfig[:system_time_zone]
214
+ else
215
+ pretty_time_zone = screen.time_zone
216
+ end
217
+ # Now just backtrack to the canonical name which will
218
+ # be useful to the players.
219
+ ActiveSupport::TimeZone::MAPPING[pretty_time_zone]
220
+ end
221
+
204
222
  def as_json(options)
205
223
  json = super(options)
206
224
  json["screen_on_off"] = ActiveSupport::JSON.decode(self.screen_on_off)
@@ -0,0 +1,49 @@
1
+ <section class="viewblock">
2
+ <header class="viewblock-header">
3
+ <h1 class="default-padding">
4
+ <%= t(:all_model, :model => ConcertoHardware::Player.model_name.human.pluralize) %>
5
+ </h1>
6
+ </header>
7
+ <div class="viewblock-cont">
8
+ <table>
9
+ <tr>
10
+ <th><%= ConcertoHardware::Player.human_attribute_name(:ip_address) %></th>
11
+ <th><%= ConcertoHardware::Player.human_attribute_name(:screen_id) %></th>
12
+ <th><%= ConcertoHardware::Player.human_attribute_name(:activated) %></th>
13
+ <th>Actions</th>
14
+ </tr>
15
+
16
+ <% @players.each do |player| %>
17
+ <tr>
18
+ <td><%= player.ip_address %></td>
19
+ <td><%= player.screen.name %></td>
20
+ <td><%= player.activated %></td>
21
+
22
+ <td>
23
+ <% if can? :read, player %>
24
+ <%= link_to t(:show, :model => ConcertoHardware::Player.model_name.human), player, :class => "btn" %>
25
+ <% end %>
26
+ <% if can? :edit, player %>
27
+ <%= link_to t(:edit, :model => ConcertoHardware::Player.model_name.human), edit_player_path(player), :class => "btn" %>
28
+ <% end %>
29
+ <% if can? :delete, player %>
30
+ <%= link_to t(:destroy, :model => ConcertoHardware::Player), player,
31
+ :data => { :confirm => t(:are_you_sure_delete_model_key, :model =>ConcertoHardware::Player.model_name.human, :key => player.screen.name) }, :method => :delete, :class => "btn" %>
32
+ <% end %>
33
+ </td>
34
+ </tr>
35
+ <% end %>
36
+ </table>
37
+ </div>
38
+ </section>
39
+ <div class="default-padding">
40
+ <%# for demo purposes: %>
41
+ Note: the poll interval is currently set to <%=ConcertoConfig[:poll_interval]%> seconds.<br/>
42
+ <% [::Ability.new(current_accessor2), ConcertoHardware::Ability.new(current_accessor2)].each do |ma| %>
43
+ The ability class is <%=ma.class%>.<br/>
44
+ Screen: <%= ConcertoHardware::Player.find(4).screen.name %>.<br/>
45
+ Can read screen: <%=ma.can? :read, ConcertoHardware::Player.find(4).screen%>.<br/>
46
+ Can read player: <%=ma.can? :read, ConcertoHardware::Player.find(4)%>.<br/>
47
+ <%end%>
48
+ </div>
49
+
@@ -1,3 +1,3 @@
1
1
  module ConcertoHardware
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
@@ -0,0 +1,3 @@
1
+ module ConcertoHardware
2
+ VERSION = "0.6"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerto_hardware
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Concerto Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -41,15 +41,18 @@ files:
41
41
  - app/assets/stylesheets/concerto_hardware/players.css.scss
42
42
  - app/assets/stylesheets/scaffolds.css.scss
43
43
  - app/controllers/concerto_hardware/application_controller.rb
44
+ - app/controllers/concerto_hardware/application_controller.rb~
44
45
  - app/controllers/concerto_hardware/players_controller.rb
45
46
  - app/helpers/players_helper.rb
46
47
  - app/models/concerto_hardware/ability.rb
48
+ - app/models/concerto_hardware/ability.rb~
47
49
  - app/models/concerto_hardware/player.rb
48
50
  - app/views/concerto_hardware/players/_form.html.erb
49
51
  - app/views/concerto_hardware/players/_show_body.html.erb
50
52
  - app/views/concerto_hardware/players/_show_header.html.erb
51
53
  - app/views/concerto_hardware/players/edit.html.erb
52
54
  - app/views/concerto_hardware/players/index.html.erb
55
+ - app/views/concerto_hardware/players/index.html.erb~
53
56
  - app/views/concerto_hardware/players/new.html.erb
54
57
  - app/views/concerto_hardware/players/show.html.erb
55
58
  - app/views/concerto_hardware/screens/_screen_link.html.erb
@@ -61,6 +64,7 @@ files:
61
64
  - lib/concerto_hardware/engine.rb
62
65
  - lib/concerto_hardware/time_accessible.rb
63
66
  - lib/concerto_hardware/version.rb
67
+ - lib/concerto_hardware/version.rb~
64
68
  - test/fixtures/players.yml
65
69
  - test/functional/players_controller_test.rb
66
70
  - test/unit/helpers/players_helper_test.rb
@@ -85,12 +89,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
89
  version: '0'
86
90
  requirements: []
87
91
  rubyforge_project:
88
- rubygems_version: 2.4.5
92
+ rubygems_version: 2.2.2
89
93
  signing_key:
90
94
  specification_version: 4
91
95
  summary: A Rails Engine for managing Bandshell-powered Concerto hardware
92
96
  test_files:
93
- - test/fixtures/players.yml
94
- - test/functional/players_controller_test.rb
95
- - test/unit/helpers/players_helper_test.rb
96
97
  - test/unit/player_test.rb
98
+ - test/unit/helpers/players_helper_test.rb
99
+ - test/functional/players_controller_test.rb
100
+ - test/fixtures/players.yml