socialforge/app/controllers/system_messages_controller.rb

98 lines
2.6 KiB
Ruby
Raw Normal View History

class SystemMessagesController < ApplicationController
# 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
@system_messages = SystemMessage.all
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
@system_messages = SystemMessage.new
@system_messages.description = params[:system_message][:description]
2015-09-17 16:23:09 +08:00
@system_messages.subject = params[:system_message][:subject]
@system_messages.user_id = User.current.id
2016-01-04 10:36:27 +08:00
# @system_messages.save_attachments(params[:attachments])
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)}
flash[:notice] = l(:notice_successful_message)
else
2015-09-17 14:41:03 +08:00
if params[:system_messages][:description].empty?
flash[:error] = l(:label_content_blank_fail)
else
flash[:error] = l(:label_admin_message_fail)
end
format.html {redirect_to admin_messages_path}
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