2015-09-09 17:05:32 +08:00
|
|
|
class SystemMessagesController < ApplicationController
|
2015-12-31 17:08:27 +08:00
|
|
|
|
2015-09-09 17:05:32 +08:00
|
|
|
# before_filter :message_author, :only => [:show]
|
|
|
|
#
|
|
|
|
# def message_author
|
|
|
|
# if(!User.current.logged? && !token.nil?)
|
|
|
|
#
|
|
|
|
# User.current =try_to_autologin1
|
|
|
|
# end
|
|
|
|
# if @system_messages
|
|
|
|
# render_403 :message => :notice_not_authorized_message
|
|
|
|
# else
|
|
|
|
# deny_access
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
def index
|
2015-09-17 16:07:41 +08:00
|
|
|
@system_messages = SystemMessage.all
|
2015-09-09 17:05:32 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# def show
|
|
|
|
# @system_messages = SystemMessage.find(params[:id])
|
|
|
|
# end
|
|
|
|
|
|
|
|
# GET /products/new
|
|
|
|
# def new
|
|
|
|
# @product = Product.new
|
|
|
|
# end
|
|
|
|
|
|
|
|
# GET /products/1/edit
|
|
|
|
# def edit
|
|
|
|
# end
|
|
|
|
|
|
|
|
# POST /products
|
|
|
|
# POST /products.json
|
|
|
|
def create
|
2015-09-09 17:43:33 +08:00
|
|
|
unless User.current.admin?
|
|
|
|
render_403
|
|
|
|
return
|
|
|
|
end
|
2015-09-09 17:05:32 +08:00
|
|
|
@system_messages = SystemMessage.new
|
2015-09-17 16:07:41 +08:00
|
|
|
@system_messages.description = params[:system_message][:description]
|
2015-09-17 16:23:09 +08:00
|
|
|
@system_messages.subject = params[:system_message][:subject]
|
2015-09-09 17:05:32 +08:00
|
|
|
@system_messages.user_id = User.current.id
|
2016-01-04 10:36:27 +08:00
|
|
|
# @system_messages.save_attachments(params[:attachments])
|
2015-09-09 17:05:32 +08:00
|
|
|
respond_to do |format|
|
|
|
|
if @system_messages.save
|
2015-09-18 14:08:09 +08:00
|
|
|
format.html {redirect_to user_system_messages_path(User.current)}
|
2015-09-09 17:05:32 +08:00
|
|
|
flash[:notice] = l(:notice_successful_message)
|
2015-09-11 15:39:46 +08:00
|
|
|
else
|
2015-09-17 14:41:03 +08:00
|
|
|
if params[:system_messages][:description].empty?
|
2015-09-11 15:39:46 +08:00
|
|
|
flash[:error] = l(:label_content_blank_fail)
|
|
|
|
else
|
|
|
|
flash[:error] = l(:label_admin_message_fail)
|
|
|
|
end
|
|
|
|
format.html {redirect_to admin_messages_path}
|
2015-09-09 17:05:32 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PATCH/PUT /products/1
|
|
|
|
# PATCH/PUT /products/1.json
|
|
|
|
# def update
|
|
|
|
# respond_to do |format|
|
|
|
|
# if @product.update(product_params)
|
|
|
|
# format.html { redirect_to @product, notice: 'Product was successfully updated.' }
|
|
|
|
# format.json { render :show, status: :ok, location: @product }
|
|
|
|
# else
|
|
|
|
# format.html { render :edit }
|
|
|
|
# format.json { render json: @product.errors, status: :unprocessable_entity }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
# DELETE /products/1
|
|
|
|
# DELETE /products/1.json
|
|
|
|
# def destroy
|
|
|
|
# @system_messages.destroy
|
|
|
|
# respond_to do |format|
|
|
|
|
# format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
|
|
|
|
# format.json { head :no_content }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
# private
|
|
|
|
# # Use callbacks to share common setup or constraints between actions.
|
|
|
|
# def set_product
|
|
|
|
# @product = Product.find(params[:id])
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# # Never trust parameters from the scary internet, only allow the white list through.
|
|
|
|
# def message_params
|
|
|
|
# params.require(:admin_system_messages).permit(:content)
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
end
|