concerto_template_scheduling 0.0.2 → 0.0.3

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: 7dbea6fcdda26efbf1615878235a429154a3ef29
4
- data.tar.gz: 12130a5497e4e03d32e6a914dbc5f0644283263e
3
+ metadata.gz: c1671432ba95646459fd39f3cd5560d32997e33c
4
+ data.tar.gz: 73973e1c52d452cd42afd07be0c61ed11987188d
5
5
  SHA512:
6
- metadata.gz: 024db2bf0d6fa0de6c8b828f63dc27adb5b64cec3e499f8c706acbcc366376034da188d7bba4fb5e5a50260ba1164397a7cbbb5f4917ad3fd59391fc747067ce
7
- data.tar.gz: 31740b8f0cc9732b7b70d1d37246a7aa0e0c400410dfe9ce82252402065ae66ade1afc437057d15ec9f92bdf9afed45267eb8ed3de8539cce24fd7223c56a34c
6
+ metadata.gz: 0f149b6f566baa2caa01da99013f38137d69e7a23325e46b3a2b9a95a14ef22e3a124ef7ffe87375a91f5108980807f91126593979c913251198ae015f276d61
7
+ data.tar.gz: 2be7e85debbf625d1c7ab4206574d06e704ab0659d662ec7df270c09b16cfbf800d122148ff4df4536e1fb2841acc2942590f344a673702532579c7619045c9e
@@ -10,4 +10,5 @@
10
10
  // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
+ //= require recurring_select
13
14
  //= require_tree .
@@ -9,5 +9,6 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
+ *= require recurring_select
12
13
  *= require_tree .
13
14
  */
@@ -60,6 +60,10 @@ module ConcertoTemplateScheduling
60
60
  auth! :action => :update, :object => @schedule.screen
61
61
  respond_to do |format|
62
62
  if @schedule.save
63
+ process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name,
64
+ :template_id => @schedule.template.id, :template_name => @schedule.template.name },
65
+ :key => 'concerto_template_scheduling.schedule.create', :owner => current_user, :action => 'create')
66
+
63
67
  format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' }
64
68
  format.json { render json: @schedule, status: :created, location: @schedule }
65
69
  else
@@ -77,6 +81,10 @@ module ConcertoTemplateScheduling
77
81
 
78
82
  respond_to do |format|
79
83
  if @schedule.update_attributes(schedule_params)
84
+ process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name,
85
+ :template_id => @schedule.template.id, :template_name => @schedule.template.name },
86
+ :key => 'concerto_template_scheduling.schedule.update', :owner => current_user, :action => 'update')
87
+
80
88
  format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }
81
89
  format.json { head :no_content }
82
90
  else
@@ -91,6 +99,9 @@ module ConcertoTemplateScheduling
91
99
  def destroy
92
100
  @schedule = Schedule.find(params[:id])
93
101
  auth! :action => :update, :object => @schedule.screen
102
+ process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name,
103
+ :template_id => @schedule.template.id, :template_name => @schedule.template.name },
104
+ :key => 'concerto_template_scheduling.schedule.destroy', :owner => current_user, :action => 'destroy')
94
105
  @schedule.destroy
95
106
 
96
107
  respond_to do |format|
@@ -1,15 +1,14 @@
1
1
  module ConcertoTemplateScheduling
2
2
  class Schedule < ActiveRecord::Base
3
3
  include ActiveModel::ForbiddenAttributesProtection
4
+ include PublicActivity::Common if defined? PublicActivity::Common
4
5
 
5
6
  DISPLAY_NEVER=0
6
- DISPLAY_ALWAYS=1
7
7
  DISPLAY_AS_SCHEDULED=2
8
8
  DISPLAY_CONTENT_EXISTS=3
9
9
 
10
10
  DISPLAY_WHEN = {
11
11
  I18n.t('concerto_template_scheduling.never') => DISPLAY_NEVER,
12
- I18n.t('concerto_template_scheduling.always') => DISPLAY_ALWAYS,
13
12
  I18n.t('concerto_template_scheduling.as_scheduled') => DISPLAY_AS_SCHEDULED,
14
13
  I18n.t('concerto_template_scheduling.content_exists') => DISPLAY_CONTENT_EXISTS
15
14
  }
@@ -65,7 +64,7 @@ module ConcertoTemplateScheduling
65
64
  # @return [Hash{String => String, Number}] configuration hash.
66
65
  def default_config
67
66
  {
68
- 'display_when' => DISPLAY_ALWAYS,
67
+ 'display_when' => DISPLAY_AS_SCHEDULED,
69
68
  'from_time' => '12:00am',
70
69
  'to_time' => '11:59pm'
71
70
  }
@@ -139,9 +138,7 @@ module ConcertoTemplateScheduling
139
138
  # and it is within the viewing window for the day
140
139
  if Clock.time >= Time.parse(self.config['from_time']) && Clock.time <= Time.parse(self.config['to_time'])
141
140
  # and it is either marked as always shown
142
- if self.config['display_when'].to_i == DISPLAY_ALWAYS
143
- effective = true
144
- elsif self.config['display_when'].to_i == DISPLAY_CONTENT_EXISTS
141
+ if self.config['display_when'].to_i == DISPLAY_CONTENT_EXISTS
145
142
  # or if we detect actual content on the specified feed
146
143
  if !self.feed.nil? && !self.feed.approved_contents.active.where('kind_id != 4').empty?
147
144
  effective = true
@@ -1,3 +1,4 @@
1
+ <%= stylesheet_link_tag "concerto_template_scheduling/application" %>
1
2
  <%= javascript_include_tag "concerto_template_scheduling/application" %>
2
3
 
3
4
  <%= form_for(@schedule) do |f| %>
@@ -36,8 +36,7 @@
36
36
  <%= l(schedule.start_time.to_date, :format => :short) %> - <%= l(schedule.end_time.to_date, :format => :short) %>
37
37
  <% end %> <b><%= schedule.is_effective? ? t(:active) : '' %></b>
38
38
  </p>
39
- <p><%= schedule.config['from_time'] %> - <%= schedule.config['to_time'] %></p>
40
- <p><%= t('concerto_template_scheduling.when')%>: <b><%= ConcertoTemplateScheduling::Schedule::DISPLAY_WHEN.key(schedule.config['display_when'].to_i) %></b></p>
39
+ <p><b><%= ConcertoTemplateScheduling::Schedule::DISPLAY_WHEN.key(schedule.config['display_when'].to_i) %></b></p>
41
40
 
42
41
  <% if schedule.config['display_when'].to_i == ConcertoTemplateScheduling::Schedule::DISPLAY_CONTENT_EXISTS %>
43
42
  <p>
@@ -50,6 +49,9 @@
50
49
  <% elsif schedule.config['display_when'].to_i == ConcertoTemplateScheduling::Schedule::DISPLAY_AS_SCHEDULED %>
51
50
  <p><%= schedule.schedule_in_words %></p>
52
51
  <% end %>
52
+ <% if schedule.config['display_when'].to_i != ConcertoTemplateScheduling::Schedule::DISPLAY_NEVER %>
53
+ <p><%= schedule.config['from_time'] %> - <%= schedule.config['to_time'] %></p>
54
+ <% end %>
53
55
  </div>
54
56
  </li>
55
57
  <% end %>
@@ -0,0 +1,17 @@
1
+ <% public_owner = User.find(activity.owner) %>
2
+ <%= link_to public_owner.name, public_owner %> <%=t('.scheduled_template')%>
3
+ <% if ::Template.exists?(activity.parameters[:template_id]) %>
4
+ <%= link_to activity.parameters[:template_name], main_app.template_path(activity.parameters[:template_id]) %>
5
+ <% else %>
6
+ <%= activity.parameters[:template_name] %>
7
+ <% end %>
8
+ <% if activity.trackable && defined?(template_scheduling) %>
9
+ <%= t('concerto_template_scheduling.starting') %>
10
+ <%= link_to l(activity.trackable.start_time.to_date, :format => :short), template_scheduling.schedule_path(activity.trackable) %>
11
+ <% end %>
12
+ <%= t('concerto_template_scheduling.for') %>
13
+ <% if Screen.exists?(activity.parameters[:screen_id]) %>
14
+ <%= link_to activity.parameters[:screen_name], main_app.screen_path(activity.parameters[:screen_id]) %>
15
+ <% else %>
16
+ <%= activity.parameters[:screen_name] %>
17
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <% public_owner = User.find(activity.owner) %>
2
+ <%= link_to public_owner.name, public_owner %> <%=t('.deleted_a_schedule')%>
3
+ <%= t('concerto_template_scheduling.for') %>
4
+ <% if ::Template.exists?(activity.parameters[:template_id]) %>
5
+ <%= link_to activity.parameters[:template_name], main_app.template_path(activity.parameters[:template_id]) %>
6
+ <% else %>
7
+ <%= activity.parameters[:template_name] %>
8
+ <% end %>
9
+ <%= t('concerto_template_scheduling.for') %>
10
+ <% if Screen.exists?(activity.parameters[:screen_id]) %>
11
+ <%= link_to activity.parameters[:screen_name], main_app.screen_path(activity.parameters[:screen_id]) %>
12
+ <% else %>
13
+ <%= activity.parameters[:screen_name] %>
14
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <% public_owner = User.find(activity.owner) %>
2
+ <%= link_to public_owner.name, public_owner %> <%=t('.updated_template')%>
3
+ <% if ::Template.exists?(activity.parameters[:template_id]) %>
4
+ <%= link_to activity.parameters[:template_name], main_app.template_path(activity.parameters[:template_id]) %>
5
+ <% else %>
6
+ <%= activity.parameters[:template_name] %>
7
+ <% end %>
8
+ <% if activity.trackable && defined?(template_scheduling) %>
9
+ <%= t('concerto_template_scheduling.starting') %>
10
+ <%= link_to l(activity.trackable.start_time.to_date, :format => :short), template_scheduling.schedule_path(activity.trackable) %>
11
+ <% end %>
12
+ <%= t('concerto_template_scheduling.for') %>
13
+ <% if Screen.exists?(activity.parameters[:screen_id]) %>
14
+ <%= link_to activity.parameters[:screen_name], main_app.screen_path(activity.parameters[:screen_id]) %>
15
+ <% else %>
16
+ <%= activity.parameters[:screen_name] %>
17
+ <% end %>
@@ -20,12 +20,14 @@ en:
20
20
  as_scheduled: 'As Scheduled'
21
21
  content_exists: 'Content Exists on Feed'
22
22
  effective: 'Currently in Effect? '
23
+ for: 'for'
23
24
  never: 'Never'
24
25
  from_time_must_precede_to_time: "'From Time' must precede 'To Time'"
25
26
  must_be_selected: 'must be selected'
26
27
  valid: 'Active'
27
28
  when: 'When'
28
29
  schedule_must_be_defined: 'Scheduling Criteria must be defined when "Use Template When" is "As Scheduled"'
30
+ starting: 'starting'
29
31
 
30
32
  schedules:
31
33
  edit:
@@ -60,3 +62,13 @@ en:
60
62
  templates:
61
63
  in_use_by:
62
64
  scheduled_for_the_following_screens: 'Scheduled for the following screens'
65
+
66
+ public_activity:
67
+ concerto_template_scheduling:
68
+ schedule:
69
+ create:
70
+ scheduled_template: 'scheduled template '
71
+ destroy:
72
+ deleted_a_schedule: 'deleted a scheduled template '
73
+ update:
74
+ updated_template: 'updated schedule for template '
@@ -1,3 +1,4 @@
1
+ require 'recurring_select'
1
2
  module ConcertoTemplateScheduling
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace ConcertoTemplateScheduling
@@ -37,13 +38,11 @@ module ConcertoTemplateScheduling
37
38
 
38
39
  # influence which template is the effective template for a screen
39
40
 
40
- add_controller_hook "Screen", :effective_template, :before do
41
- # self is the screen model instance
42
- if @template.nil?
43
- schedules = Schedule.active.where(:screen_id => self.id)
44
- schedules.reject! {|s| !s.is_effective? }
45
- @template = schedules.first.template if !schedules.empty?
46
- end
41
+ add_controller_hook "Screen", :frontend_display, :before do
42
+ # sets the template to the "effective" template
43
+ schedules = Schedule.active.where(:screen_id => self.id)
44
+ schedules.reject! {|s| !s.is_effective? }
45
+ self.template = schedules.first.template if !schedules.empty?
47
46
  end
48
47
 
49
48
  # delete schedules when a screen is deleted
@@ -1,3 +1,3 @@
1
1
  module ConcertoTemplateScheduling
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerto_template_scheduling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Frederickson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -90,6 +90,9 @@ files:
90
90
  - app/views/concerto_template_scheduling/schedules/show.html.erb
91
91
  - app/views/concerto_template_scheduling/screens/_screen_link.html.erb
92
92
  - app/views/concerto_template_scheduling/templates/_in_use_by.html.erb
93
+ - app/views/public_activity/concerto_template_scheduling/schedule/_create.html.erb
94
+ - app/views/public_activity/concerto_template_scheduling/schedule/_destroy.html.erb
95
+ - app/views/public_activity/concerto_template_scheduling/schedule/_update.html.erb
93
96
  - config/locales/en.yml
94
97
  - config/routes.rb
95
98
  - db/migrate/20140118205731_create_concerto_template_scheduling_schedules.rb