--- /dev/null
+class Admin::BroadcastMessagesController < Admin::ApplicationController
+ before_filter :broadcast_messages
+
+ def index
+ @broadcast_message = BroadcastMessage.new
+ end
+
+ def create
+ @broadcast_message = BroadcastMessage.new(params[:broadcast_message])
+
+ if @broadcast_message.save
+ redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.'
+ else
+ render :index
+ end
+ end
+
+ protected
+
+ def broadcast_messages
+ @broadcast_messages ||= BroadcastMessage.order("starts_at DESC").page(params[:page])
+ end
+end
attr_accessible :alert_type, :ends_at, :message, :starts_at
validates :message, presence: true
+ validates :starts_at, presence: true
+ validates :ends_at, presence: true
end
--- /dev/null
+%h3.page-title
+ Broadcast Messages
+%p.light
+ Broadcast messages displayed for every user and can be used to notify application about scheduled maintenance.
+%hr
+
+= form_for [:admin, @broadcast_message] do |f|
+ -if @broadcast_message.errors.any?
+ .alert.alert-error
+ - @broadcast_message.errors.full_messages.each do |msg|
+ %p= msg
+ .control-group
+ = f.label :message
+ .controls
+ = f.text_area :message, class: "input-xxlarge", rows: 2, required: true
+ .control-group
+ = f.label :starts_at
+ .controls.datetime-controls
+ = f.datetime_select :starts_at
+ .control-group
+ = f.label :ends_at
+ .controls.datetime-controls
+ = f.datetime_select :ends_at
+ .form-actions
+ = f.submit "Add broadcast message", class: "btn btn-create"
+
+-if @broadcast_messages.any?
+ %ul.bordered-list
+ - @broadcast_messages.each do |broadcast_message|
+ %li
+ .pull-right
+ - if broadcast_message.starts_at
+ %strong
+ #{broadcast_message.starts_at.to_s(:short)}
+ \...
+ - if broadcast_message.ends_at
+ %strong
+ #{broadcast_message.ends_at.to_s(:short)}
+ .message= broadcast_message.message
+
+ = paginate @broadcast_messages
get :test
end
+ resources :broadcast_messages, only: [:index, :create]
resource :logs, only: [:show]
resource :background_jobs, controller: 'background_jobs', only: [:show]
resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]