Commit dd501aa7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Broadcast messages scaffold in admin area

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f1ecf53c
...@@ -49,3 +49,9 @@ fieldset legend { ...@@ -49,3 +49,9 @@ fieldset legend {
font-size: 16px; font-size: 16px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.datetime-controls {
select {
width: 100px;
}
}
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
...@@ -2,4 +2,6 @@ class BroadcastMessage < ActiveRecord::Base ...@@ -2,4 +2,6 @@ class BroadcastMessage < ActiveRecord::Base
attr_accessible :alert_type, :ends_at, :message, :starts_at attr_accessible :alert_type, :ends_at, :message, :starts_at
validates :message, presence: true validates :message, presence: true
validates :starts_at, presence: true
validates :ends_at, presence: true
end end
%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
...@@ -86,6 +86,7 @@ Gitlab::Application.routes.draw do ...@@ -86,6 +86,7 @@ Gitlab::Application.routes.draw do
get :test get :test
end end
resources :broadcast_messages, only: [:index, :create]
resource :logs, only: [:show] resource :logs, only: [:show]
resource :background_jobs, controller: 'background_jobs', only: [:show] resource :background_jobs, controller: 'background_jobs', only: [:show]
resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment