class Admin::TopicsController < Admin::EPapersController def initialize super @app_title = "e_paper" end def index @paper = Paper.find(params[:paper_id]) @topics = @paper.topics.order_by(sort).page(params[:page]).per(10) @table_fields = ["e_paper.title","title","start_date"] end def edit @topic = Topic.find(params[:id]) if can_edit_or_delete?(@topic.paper) @paper = @topic.paper else render_401 end end def update @topic = Topic.find(params[:id]) @topic.update_attributes(topic_params) redirect_to params[:referer_url] end def new @paper = Paper.find(params[:paper_id]) @topic = Topic.new if can_edit_or_delete?(@paper) @tags = @module_app.tags || [] else render_401 end end def create topic = Topic.new(topic_params) topic.save redirect_to params[:referer_url] end def destroy @topic = Topic.find params[:id] if can_edit_or_delete?(@topic.paper) @paper = @topic.paper @topic.destroy end redirect_to admin_e_paper_path(@paper.id, :page => params[:page]) end private def topic_params params.require(:topic).permit! end end