text_marquee/app/controllers/admin/text_marquees_controller.rb

83 lines
2.1 KiB
Ruby
Raw Normal View History

2015-04-30 09:50:09 +00:00
class Admin::TextMarqueesController < OrbitAdminController
def index
@tags = @module_app.tags
2016-05-12 11:46:24 +00:00
uac = @module_app.categories.enabled.authorized(current_user) if @user_authorized_categories.nil?
2015-04-30 09:50:09 +00:00
categories = @module_app.categories.enabled
@filter_fields = filter_fields(categories, @tags)
2016-05-12 11:46:24 +00:00
@categories = uac.collect{|c|[c.title, c.id]}
2015-04-30 09:50:09 +00:00
@table_fields = [:title, :category]
@marquees = Marquee.where(:title.ne => "")
.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag"))
@marquees = @marquees.page(params[:page]).per(10)
if request.xhr?
render :partial => "index"
end
end
def create
marquee = Marquee.new(marquee_variables)
marquee.save
end
def update
marquee = Marquee.find(params[:id])
marquee.update_attributes(marquee_variables)
marquee.save
end
def show
@table_fields = [:title, :link]
@marquee = Marquee.find(params[:id])
end
def destroy
marquee = Marquee.find(params[:id])
marquee.destroy
redirect_to admin_text_marquees_path
end
def newtext
@marquee = Marquee.find(params[:text_marquee_id])
@marquee_text = MarqueeText.new
end
def edittext
@marquee_text = MarqueeText.find(params[:text_marquee_id])
@marquee = @marquee_text.marquee
end
def deletetext
marquee_text = MarqueeText.find(params[:text_marquee_id])
marquee = marquee_text.marquee
marquee_text.destroy
redirect_to admin_text_marquee_path(marquee)
end
def createtext
@marquee = Marquee.find(params[:text_marquee_id])
marquee_text = MarqueeText.new(marquee_text_variables)
marquee_text.marquee = @marquee.id
marquee_text.save
redirect_to admin_text_marquee_path(@marquee)
end
def updatetext
marquee_text = MarqueeText.find(params[:text_marquee_id])
marquee_text.update_attributes(marquee_text_variables)
marquee_text.save
redirect_to admin_text_marquee_path(marquee_text.marquee)
end
private
def marquee_variables
params.require(:marquee).permit!
end
def marquee_text_variables
params.require(:marquee_text).permit!
end
end