From 370e71a5712de7dc6364b8f5acaa3ef0c9fd481b Mon Sep 17 00:00:00 2001 From: Brian Michalski Date: Mon, 18 Mar 2013 21:24:56 -0700 Subject: [PATCH] Add client time for #348. --- app/models/client_time.rb | 16 ++++++++++++++++ config/routes.rb | 1 + public/frontend_js/contents/client_time.js | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/models/client_time.rb diff --git a/app/models/client_time.rb b/app/models/client_time.rb new file mode 100644 index 000000000..69b064f24 --- /dev/null +++ b/app/models/client_time.rb @@ -0,0 +1,16 @@ +class ClientTime < Content + + DISPLAY_NAME = 'Client Time' + + after_initialize :set_kind + + # Validations + validates :duration, :numericality => { :greater_than => 0, :less_than => 60 } + + # Automatically set the kind for the content + # if it is new. + def set_kind + return unless new_record? + self.kind = Kind.where(:name => 'Text').first + end +end diff --git a/config/routes.rb b/config/routes.rb index 2057d8515..0eff3c4f6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,6 +88,7 @@ resources :tickers, :controller => :contents, :except => [:index, :show], :path => "content" resources :html_texts, :controller => :contents, :except => [:index, :show], :path => "content" + resources :client_times, :controller => :contents, :except => [:index, :show], :path => "content" #Set a non-restful route to the dashboard match 'dashboard/' => 'dashboard#index' diff --git a/public/frontend_js/contents/client_time.js b/public/frontend_js/contents/client_time.js index a8320ca2d..307dd535c 100644 --- a/public/frontend_js/contents/client_time.js +++ b/public/frontend_js/contents/client_time.js @@ -27,7 +27,7 @@ concerto.frontend.Content.ClientTime = function(data) { goog.inherits(concerto.frontend.Content.ClientTime, concerto.frontend.Content); // Register the content type. -concerto.frontend.ContentTypeRegistry['TimeDisplay'] = +concerto.frontend.ContentTypeRegistry['ClientTime'] = concerto.frontend.Content.ClientTime;